Skip to content

Commit 320ec21

Browse files
committed
Replace black and isort with ruff
* Use ruff config and Make commands from scancode.io Signed-off-by: Jono Yang <[email protected]>
1 parent df02630 commit 320ec21

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

Makefile

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,24 @@ dev:
1717
@echo "-> Configure the development envt."
1818
./configure --dev
1919

20-
isort:
21-
@echo "-> Apply isort changes to ensure proper imports ordering"
22-
${VENV}/bin/isort --sl -l 100 src tests setup.py
23-
24-
black:
25-
@echo "-> Apply black code formatter"
26-
${VENV}/bin/black -l 100 src tests setup.py
27-
2820
doc8:
2921
@echo "-> Run doc8 validation"
3022
@${ACTIVATE} doc8 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
3123

32-
valid: isort black
24+
valid:
25+
@echo "-> Run Ruff format"
26+
@${ACTIVATE} ruff format
27+
@echo "-> Run Ruff linter"
28+
@${ACTIVATE} ruff check --fix
3329

3430
check:
35-
@echo "-> Run pycodestyle (PEP8) validation"
36-
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,migrations,settings.py,.cache .
37-
@echo "-> Run isort imports ordering validation"
38-
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
39-
@echo "-> Run black validation"
40-
@${ACTIVATE} black --check --check -l 100 src tests setup.py
31+
@echo "-> Run Ruff linter validation (pycodestyle, bandit, isort, and more)"
32+
@${ACTIVATE} ruff check
33+
@echo "-> Run Ruff format validation"
34+
@${ACTIVATE} ruff format --check
35+
@$(MAKE) doc8
36+
@echo "-> Run ABOUT files validation"
37+
@${ACTIVATE} about check etc/
4138

4239
clean:
4340
@echo "-> Clean the Python env"

pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,40 @@ addopts = [
5050
"--strict-markers",
5151
"--doctest-modules"
5252
]
53+
54+
[tool.ruff]
55+
line-length = 88
56+
extend-exclude = []
57+
target-version = "py310"
58+
59+
[tool.ruff.lint]
60+
# Rules: https://docs.astral.sh/ruff/rules/
61+
select = [
62+
"E", # pycodestyle
63+
"W", # pycodestyle warnings
64+
"D", # pydocstyle
65+
"F", # Pyflakes
66+
"UP", # pyupgrade
67+
"S", # flake8-bandit
68+
"I", # isort
69+
"C9", # McCabe complexity
70+
]
71+
ignore = ["D1", "D203", "D205", "D212", "D400", "D415"]
72+
73+
[tool.ruff.lint.isort]
74+
force-single-line = true
75+
sections = { django = ["django"] }
76+
section-order = [
77+
"future",
78+
"standard-library",
79+
"django",
80+
"third-party",
81+
"first-party",
82+
"local-folder",
83+
]
84+
85+
[tool.ruff.lint.mccabe]
86+
max-complexity = 10
87+
88+
[tool.ruff.lint.per-file-ignores]
89+
# Place paths of files to be ignored by ruff here

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ testing =
5454
aboutcode-toolkit >= 7.0.2
5555
pycodestyle >= 2.8.0
5656
twine
57-
black
58-
isort
57+
ruff
5958

6059
docs =
6160
Sphinx>=5.0.2

0 commit comments

Comments
 (0)