Skip to content

Commit 45d4d6a

Browse files
committed
pre-commit: add hooks pyupgrade, autoflake, isort
1 parent 1790683 commit 45d4d6a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99
# - Register git hooks: pre-commit install --install-hooks
1010
#
1111
repos:
12+
# Autoformat: Python code, syntax patterns are modernized
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: v3.3.2
15+
hooks:
16+
- id: pyupgrade
17+
args:
18+
- --py38-plus
19+
20+
# Autoformat: Python code
21+
- repo: https://github.com/PyCQA/autoflake
22+
rev: v2.1.1
23+
hooks:
24+
- id: autoflake
25+
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
26+
args:
27+
- --in-place
28+
29+
# Autoformat: Python code
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.12.0
32+
hooks:
33+
- id: isort
34+
1235
# Autoformat: Python code
1336
- repo: https://github.com/psf/black
1437
rev: "23.3.0"

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ requires = ["setuptools", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55

6+
# autoflake is used for autoformatting Python code
7+
#
8+
# ref: https://github.com/PyCQA/autoflake#readme
9+
#
10+
[tool.autoflake]
11+
ignore-init-module-imports = true
12+
#remove-all-unused-imports = true
13+
remove-duplicate-keys = true
14+
remove-unused-variables = true
15+
16+
17+
# isort is used for autoformatting Python code
18+
#
19+
# ref: https://pycqa.github.io/isort/
20+
#
21+
[tool.isort]
22+
profile = "black"
23+
24+
625
# black is used for autoformatting Python code
726
#
827
# ref: https://black.readthedocs.io/en/stable/

0 commit comments

Comments
 (0)