Skip to content

Commit 21bf603

Browse files
authored
Centralise linting config in .pre-commit-config.yaml (#15210)
This makes it easier to maintain the configurations for the various linting tools we use in CI. It also makes it easier for contributors to run the linting tools locally. `black`, `isort` and `flake8` are all very fast checks, so I think it makes sense to just run them all together in `runtests.py`. With this PR, the following three invocations will all be equivalent: ``` pre-commit run --all-files python runtests.py lint tox -e lint ``` Closes #15076
1 parent 1d144f0 commit 21bf603

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

runtests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@
5050
# Self type check
5151
"self": [executable, "-m", "mypy", "--config-file", "mypy_self_check.ini", "-p", "mypy"],
5252
# Lint
53-
"lint": ["flake8", "-j3"],
54-
"format-black": ["black", "."],
55-
"format-isort": ["isort", "."],
53+
"lint": ["pre-commit", "run", "--all-files"],
5654
# Fast test cases only (this is the bulk of the test suite)
5755
"pytest-fast": ["pytest", "-q", "-k", f"not ({' or '.join(ALL_NON_FAST)})"],
5856
# Test cases that invoke mypy (with small inputs)

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ flake8-bugbear==23.3.23; python_version >= "3.8" # must match version in .pre-co
88
flake8-noqa==1.3.1; python_version >= "3.8" # must match version in .pre-commit-config.yaml
99
isort[colors]==5.12.0; python_version >= "3.8" # must match version in .pre-commit-config.yaml
1010
lxml>=4.9.1; (python_version<'3.11' or sys_platform!='win32') and python_version<'3.12'
11+
pre-commit
1112
psutil>=4.0
1213
# pytest 6.2.3 does not support Python 3.10
1314
pytest>=6.2.4

tox.ini

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ commands =
4141
[testenv:lint]
4242
description = check the code style
4343
skip_install = true
44-
commands =
45-
flake8 {posargs}
46-
black --check --diff --color .
47-
isort --check --diff --color .
44+
commands = pre-commit run --all-files --show-diff-on-failure
4845

4946
[testenv:type]
5047
description = type check ourselves

0 commit comments

Comments
 (0)