Skip to content

Commit 5f9de73

Browse files
authored
Add pre-commit (#460)
* Add pre-commit - add configs to pyproject.toml - add .pre-commit-config.yaml - remove mypy.yml, flak8.yml, pycodestyle.yml - replace os.path with pathlib.path - remove whitespaces - fix new lines - small fixes * fix conf.py
1 parent 36996c2 commit 5f9de73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+145
-137
lines changed

.github/actions/linux_armv7l/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ FROM ghcr.io/nikteliy/manylinux_2_24_armv7l:python3.7
33
COPY entrypoint.sh /entrypoint.sh
44
RUN chmod +x /entrypoint.sh
55

6-
ENTRYPOINT ["/entrypoint.sh"]
6+
ENTRYPOINT ["/entrypoint.sh"]

.github/actions/linux_armv7l/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ runs:
2525
- ${{ inputs.platform }}
2626
- ${{ inputs.makefile }}
2727
- ${{ inputs.python }}
28-
- ${{ inputs.wheeldir }}
28+
- ${{ inputs.wheeldir }}

.github/actions/linux_armv7l/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -o errexit
44
set -o pipefail
55
set -o nounset
66

7-
exec "$INPUT_SCRIPT"
7+
exec "$INPUT_SCRIPT"

.github/actions/manylinux_2_24_aarch64/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ FROM quay.io/pypa/manylinux_2_24_aarch64:latest
33
COPY entrypoint.sh /entrypoint.sh
44
RUN chmod +x /entrypoint.sh
55

6-
ENTRYPOINT ["/entrypoint.sh"]
6+
ENTRYPOINT ["/entrypoint.sh"]

.github/actions/manylinux_2_24_aarch64/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ runs:
2525
- ${{ inputs.platform }}
2626
- ${{ inputs.makefile }}
2727
- ${{ inputs.python }}
28-
- ${{ inputs.wheeldir }}
28+
- ${{ inputs.wheeldir }}

.github/actions/manylinux_2_24_x86_64/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ FROM quay.io/pypa/manylinux_2_24_x86_64:latest
33
COPY /entrypoint.sh /entrypoint.sh
44
RUN chmod +x /entrypoint.sh
55

6-
ENTRYPOINT ["/entrypoint.sh"]
6+
ENTRYPOINT ["/entrypoint.sh"]

.github/actions/manylinux_2_24_x86_64/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ runs:
2525
- ${{ inputs.platform }}
2626
- ${{ inputs.makefile }}
2727
- ${{ inputs.python }}
28-
- ${{ inputs.wheeldir }}
28+
- ${{ inputs.wheeldir }}

.github/actions/prepare_snap7/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
with:
1515
path: snap7-full-1.4.2.7z
1616
key: ${{ inputs.snap7-archive-url }}
17-
17+
1818
- name: Install choco packages
1919
if: steps.snap7-archive.outputs.cache-hit != 'true' && runner.os == 'Windows'
2020
shell: bash
@@ -31,4 +31,4 @@ runs:
3131

3232
- name: Update wheel
3333
shell: bash
34-
run: python3 -m pip install --upgrade pip wheel build
34+
run: python3 -m pip install --upgrade pip wheel build

.github/build_scripts/build_package.sh

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ ${INPUT_PYTHON} -m pip install wheel build auditwheel patchelf
1010
${INPUT_PYTHON} -m build . --wheel -C="--build-option=--plat-name=${INPUT_PLATFORM}"
1111

1212
auditwheel repair dist/*${INPUT_PLATFORM}.whl --plat ${INPUT_PLATFORM} -w ${INPUT_WHEELDIR}
13-

.github/workflows/build-and-test-arm32v7.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3
14-
14+
1515
- name: Prepare snap7 archive
1616
uses: ./.github/actions/prepare_snap7
1717

1818
- name: Set up QEMU
1919
uses: docker/setup-qemu-action@v2
2020
with:
2121
platforms: arm
22-
22+
2323
- name: Build wheel
2424
uses: ./.github/actions/linux_armv7l
2525
with:
@@ -55,14 +55,13 @@ jobs:
5555
uses: docker/setup-qemu-action@v2
5656
with:
5757
platforms: arm
58-
58+
5959
- name: Run tests in docker:arm32v7
6060
run: |
6161
docker run --platform linux/arm/v7 --rm --interactive -v $PWD/tests:/tests \
6262
-v $PWD/pyproject.toml:/pyproject.toml \
6363
-v $PWD/wheelhouse:/wheelhouse \
64-
"arm32v7/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
64+
"arm32v7/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
6565
python -m pip install pytest pytest-asyncio $(ls wheelhouse/*manylinux_2_24_armv7l.whl)
6666
python -m pytest tests/ -m "server or util or client or mainloop or partner"
6767
EOF
68-

.github/workflows/build-and-test-arm64.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3
14-
14+
1515
- name: Prepare snap7 archive
1616
uses: ./.github/actions/prepare_snap7
1717

1818
- name: Set up QEMU
1919
uses: docker/setup-qemu-action@v2
2020
with:
2121
platforms: arm64
22-
22+
2323
- name: Build wheel
2424
uses: ./.github/actions/manylinux_2_24_aarch64
2525
with:
@@ -61,9 +61,8 @@ jobs:
6161
docker run --rm --interactive -v $PWD/tests:/tests \
6262
-v $PWD/pyproject.toml:/pyproject.toml \
6363
-v $PWD/wheelhouse:/wheelhouse \
64-
"arm64v8/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
64+
"arm64v8/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
6565
python3 -m pip install $(ls wheelhouse/*_aarch64.whl)
6666
python3 -m pip install pytest pytest-asyncio
6767
python -m pytest tests/ -m "server or util or client or mainloop or partner"
6868
EOF
69-

.github/workflows/build-and-test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3
14-
14+
1515
- name: Prepare snap7 archive
1616
uses: ./.github/actions/prepare_snap7
1717

@@ -23,7 +23,7 @@ jobs:
2323
makefile: x86_64_linux.mk
2424
python: /opt/python/cp38-cp38/bin/python
2525
wheeldir: wheelhouse/${{ runner.os }}/
26-
26+
2727
- name: Upload artifacts
2828
uses: actions/upload-artifact@v3
2929
with:
@@ -60,7 +60,7 @@ jobs:
6060
steps:
6161
- name: Checkout
6262
uses: actions/checkout@v3
63-
63+
6464
- name: Prepare snap7 archive
6565
uses: ./.github/actions/prepare_snap7
6666

.github/workflows/doc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
- name: Run doc
2222
run: |
2323
cd doc
24-
make html
24+
make html

.github/workflows/docker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
with:
2828
push: true
2929
tags: ${{ steps.meta.outputs.tags }}
30-
labels: ${{ steps.meta.outputs.labels }}
30+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/flake8.yml

-24
This file was deleted.

.github/workflows/mypy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
sudo apt-get update -qq
1616
sudo apt-get install -y python3-pip
1717
- name: Run mypy
18-
run: make mypy
18+
run: make mypy

.github/workflows/osx.yml

-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ jobs:
2020
run: |
2121
pytest -m "server or util or client or mainloop"
2222
sudo pytest -m partner
23-
24-

.github/workflows/pre-commit.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: pre-commit
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
branches: [master]
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v3
13+
- uses: pre-commit/[email protected]

.github/workflows/pycodestyle.yml

-22
This file was deleted.

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ venv/
5858
.vscode/
5959

6060
# DLL
61-
snap7.dll
61+
snap7.dll

.pre-commit-config.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-json
8+
- id: check-toml
9+
- id: check-xml
10+
- id: check-yaml
11+
- id: debug-statements
12+
- id: check-builtin-literals
13+
- id: check-case-conflict
14+
- id: check-docstring-first
15+
- id: detect-private-key
16+
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: 'v1.5.0'
19+
hooks:
20+
- id: mypy
21+
additional_dependencies: [types-setuptools]
22+
files: ^snap7
23+
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: 'v0.0.284'
26+
hooks:
27+
- id: ruff

CHANGES.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ Special thanks for this release to
5353
---
5454

5555
* Drop python 2 support (#214)
56-
* Feature request: ReadSZL() (#196)
56+
* Feature request: ReadSZL() (#196)
5757
* Keep argument format across the functions (#193)
58-
* Drop Python2 Tests (#167)
59-
* Support for S5TIME (#163)
60-
* Add type annotations (#157)
61-
* client.full_upload() return bytearray size 65536 (#127)
62-
* Some client tests segfault on Linux (#26)
58+
* Drop Python2 Tests (#167)
59+
* Support for S5TIME (#163)
60+
* Add type annotations (#157)
61+
* client.full_upload() return bytearray size 65536 (#127)
62+
* Some client tests segfault on Linux (#26)
6363
* Not all functions are implemented yet (#25)
6464

6565
special thanks to [Fabian Beitler](https://github.com/swamper123) and

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
include README.rst
2-

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ test: venv/bin/pytest
3737
sudo venv/bin/pytest tests/test_partner.py # run this as last to prevent pytest cache dir creates as root
3838

3939
clean:
40-
rm -rf venv python_snap7.egg-info .pytest_cache .tox dist .eggs
40+
rm -rf venv python_snap7.egg-info .pytest_cache .tox dist .eggs

README.rst

-2
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@ Special thanks to
3838
* Thomas W for his S7comm wireshark plugin
3939
* `Fabian Beitler <https://github.com/swamper123>`_ and `Nikteliy <https://github.com/nikteliy>`_ for their contributions towards the 1.0 release
4040
* `Lautaro Nahuel Dapino <https://github.com/lautarodapin>`_ for his contributions.
41-
42-

doc/API/client.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Client
22
======
33

44
.. automodule:: snap7.client
5-
:members:
5+
:members:

doc/API/partner.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Partner
22
=======
33

44
.. automodule:: snap7.partner
5-
:members:
5+
:members:

0 commit comments

Comments
 (0)