Skip to content

Commit d36818c

Browse files
committed
Add a black check to pre-commit
- Add the psf/black-pre-commit-mirror pre-commit hook but have it just check and report violations rather than fixing them automatically (to avoid inconsistency with all the other hooks, and also so that the linting instructions and CI lint workflow can remain the same and automatically do the black check). - Remove the "black" environment from tox.ini, since it is now part of the linting done in the "lint" environment. (But README.md remains the same, as it documented actually auto-formatting with black, which is still done the same way.) - Add missing "exclude" keys for the shellcheck and black pre-commit hooks to explicitly avoid traversing into the submodules.
1 parent b88d07e commit d36818c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: .pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
repos:
2+
- repo: https://github.com/psf/black-pre-commit-mirror
3+
rev: 23.9.1
4+
hooks:
5+
- id: black
6+
args: [--check, --diff]
7+
exclude: ^git/ext/
8+
29
- repo: https://github.com/PyCQA/flake8
310
rev: 6.1.0
411
hooks:
@@ -14,6 +21,7 @@ repos:
1421
hooks:
1522
- id: shellcheck
1623
args: [--color]
24+
exclude: ^git/ext/
1725

1826
- repo: https://github.com/pre-commit/pre-commit-hooks
1927
rev: v4.4.0

Diff for: tox.ini

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
requires = tox>=4
3-
env_list = py{37,38,39,310,311,312}, lint, mypy, black
3+
env_list = py{37,38,39,310,311,312}, lint, mypy
44

55
[testenv]
66
description = Run unit tests
@@ -20,11 +20,6 @@ base_python = py39
2020
commands = mypy -p git
2121
ignore_outcome = true
2222

23-
[testenv:black]
24-
description = Check style with black
25-
base_python = py39
26-
commands = black --check --diff .
27-
2823
# Run "tox -e html" for this. It is deliberately excluded from env_list, as
2924
# unlike the other environments, this one writes outside the .tox/ directory.
3025
[testenv:html]

0 commit comments

Comments
 (0)