Skip to content

Commit cd204d3

Browse files
authored
Add pre-commit config (#1406)
1 parent e73493a commit cd204d3

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ jobs:
3737
- name: flake8
3838
cmd: flake8
3939
type: lint
40-
- name: isort
41-
cmd: isort --check .
42-
type: lint
43-
- name: black
44-
cmd: black --check --safe --quiet examples/ pymodbus/ test/
40+
- name: precommit (isort and black)
41+
cmd: pre-commit run --all-files
4542
type: lint
4643
- name: docs
4744
cmd: make -C doc/ html

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
# - id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/pycqa/isort
12+
rev: 5.12.0
13+
hooks:
14+
- id: isort
15+
exclude: ^(doc/_build|venv|.venv|.git|pymodbus/client/serial_asyncio)
16+
- repo: https://github.com/psf/black
17+
rev: 22.12.0
18+
hooks:
19+
- id: black
20+
args: [--safe,--quiet]
21+
files: (examples|pymodbus|test)/

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ Then:
224224

225225
pip install -e .
226226

227-
This installs pymodbus in your virtual environment with pointers directly to the pymodbus directory, so any change you make is immediately available as if installed.
227+
pre-commit --install
228+
229+
This installs pymodbus in your virtual environment with pointers directly to the pymodbus directory, so any change you make is immediately available as if installed. It will also install `pre-commit` git hooks.
228230

229231
Either method will install all the required dependencies
230232
(at their appropriate versions) for your current python distribution.

TODO_add_checks

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
1) add .pre-commit and commit-hook
2-
3-
2) new checks
1+
New checks
42
- prettier
5-
- mypy
6-

check_ci.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
66

77

88
codespell
9-
black --safe --quiet examples/ pymodbus/ test/
10-
isort .
9+
pre-commit run --all-files
1110
pylint --recursive=y examples pymodbus test
1211
flake8
1312
mypy pymodbus

examples/v2.5.3/rx_messages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
# Modbus RTU Messages
8989
# ------------------------------------------------------------
9090
# [Address ][ Function Code] [ Data ][ CRC ]
91-
# 1b 1b Nb 2b
91+
# 1b 1b Nb 2b
9292
#
9393
# ./message-parser -b -p rtu -f messages
9494
# ------------------------------------------------------------

examples/v2.5.3/tx_messages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
# Modbus RTU Messages
8989
# ------------------------------------------------------------
9090
# [Address ][ Function Code] [ Data ][ CRC ]
91-
# 1b 1b Nb 2b
91+
# 1b 1b Nb 2b
9292
#
9393
# ./message-parser -b -p rtu -f messages
9494
# ------------------------------------------------------------

pymodbus/repl/client/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _(event):
231231
continue # Control-C pressed. Try again.
232232
except EOFError:
233233
break # Control-D pressed.
234-
except Exception as exc: # Handle all other exceptions pylint: disable=broad-except
234+
except Exception as exc: # pylint: disable=broad-except
235235
click.secho(str(exc), fg="red")
236236

237237
click.secho("GoodBye!", fg="blue")

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ sphinx-rtd-theme==1.1.1
5252
# -------------------------------------------------------------------
5353
# install:development
5454
bandit==1.7.4
55-
black==22.12.0
5655
codespell==2.2.2
5756
coverage==7.1.0
5857
flake8==6.0.0
5958
flake8-docstrings==1.7.0
6059
flake8-noqa==1.3.0
6160
flake8-comprehensions==3.10.1
62-
isort==5.11.4
6361
mypy==1.0.1
62+
pre-commit==3.1.1
6463
pyflakes==3.0.1
6564
pydocstyle==6.3.0
6665
pycodestyle==2.10.0

0 commit comments

Comments
 (0)