Skip to content

Commit d128bc5

Browse files
committed
Add reorder-python-imports and autoflake hooks
Also: - Change the order of the hooks, so those that change code but do not care about formatting run first, then black, and finally checkers like mypy. - Drop 'linting' environment: not needed anymore given we are using pre-commit.ci. - Do not run 'docs' on CI: we already use readthedocs.io for that (but keep tox environment for local execution).
1 parent 38561d7 commit d128bc5

File tree

3 files changed

+35
-39
lines changed

3 files changed

+35
-39
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ jobs:
3131
"ubuntu-py311",
3232
"ubuntu-pypy3",
3333
"ubuntu-benchmark",
34-
35-
"linting",
36-
"docs",
3734
]
3835

3936
include:
@@ -87,14 +84,6 @@ jobs:
8784
python: "3.8"
8885
os: ubuntu-latest
8986
tox_env: "benchmark"
90-
- name: "linting"
91-
python: "3.8"
92-
os: ubuntu-latest
93-
tox_env: "linting"
94-
- name: "docs"
95-
python: "3.8"
96-
os: ubuntu-latest
97-
tox_env: "docs"
9887

9988
steps:
10089
- uses: actions/checkout@v3

.pre-commit-config.yaml

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 22.10.0
2+
- repo: https://github.com/PyCQA/autoflake
3+
rev: v1.7.7
44
hooks:
5-
- id: black
6-
args: [--safe, --quiet]
7-
- repo: https://github.com/asottile/blacken-docs
8-
rev: v1.12.1
5+
- id: autoflake
6+
name: autoflake
7+
args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
8+
language: python
9+
files: \.py$
10+
- repo: https://github.com/asottile/reorder_python_imports
11+
rev: v3.9.0
912
hooks:
10-
- id: blacken-docs
11-
additional_dependencies: [black==22.10.0]
13+
- id: reorder-python-imports
14+
args: ['--application-directories=.:src', --py37-plus]
1215
- repo: https://github.com/pre-commit/pre-commit-hooks
1316
rev: v2.1.0
1417
hooks:
1518
- id: trailing-whitespace
1619
- id: end-of-file-fixer
1720
- id: flake8
1821
additional_dependencies: [flake8-typing-imports]
19-
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v0.990
22+
- repo: https://github.com/pre-commit/pygrep-hooks
23+
rev: v1.9.0
2124
hooks:
22-
- id: mypy
23-
files: ^(src/|testing/)
24-
args: []
25-
additional_dependencies: [pytest]
25+
- id: rst-backticks
26+
- repo: https://github.com/asottile/pyupgrade
27+
rev: v3.2.2
28+
hooks:
29+
- id: pyupgrade
30+
args: [--py37-plus]
31+
- repo: https://github.com/psf/black
32+
rev: 22.10.0
33+
hooks:
34+
- id: black
35+
args: [--safe, --quiet]
36+
- repo: https://github.com/asottile/blacken-docs
37+
rev: v1.12.1
38+
hooks:
39+
- id: blacken-docs
40+
additional_dependencies: [black==22.10.0]
2641
- repo: local
2742
hooks:
2843
- id: rst
@@ -31,12 +46,10 @@ repos:
3146
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
3247
language: python
3348
additional_dependencies: [pygments, restructuredtext_lint]
34-
- repo: https://github.com/pre-commit/pygrep-hooks
35-
rev: v1.9.0
36-
hooks:
37-
- id: rst-backticks
38-
- repo: https://github.com/asottile/pyupgrade
39-
rev: v3.2.2
49+
- repo: https://github.com/pre-commit/mirrors-mypy
50+
rev: v0.990
4051
hooks:
41-
- id: pyupgrade
42-
args: [--py37-plus]
52+
- id: mypy
53+
files: ^(src/|testing/)
54+
args: []
55+
additional_dependencies: [pytest]

tox.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ deps=
2020
pytest
2121
pytest-benchmark
2222

23-
[testenv:linting]
24-
skip_install = true
25-
basepython = python3
26-
deps = pre-commit
27-
commands = pre-commit run --all-files --show-diff-on-failure
28-
2923
[testenv:docs]
3024
deps =
3125
sphinx

0 commit comments

Comments
 (0)