Skip to content

Commit f65c361

Browse files
committed
infra: replace flake8 with ruff
As a first step, this ports all of our existing flake8 rules to Ruff. I have omitted pyupgrade for which Ruff has partial support.
1 parent cd06da2 commit f65c361

File tree

7 files changed

+24
-15
lines changed

7 files changed

+24
-15
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ repos:
4343
rev: 5.11.4
4444
hooks:
4545
- id: isort
46-
- repo: https://github.com/PyCQA/flake8
47-
rev: "6.0.0"
46+
- repo: https://github.com/charliermarsh/ruff-pre-commit
47+
rev: v0.0.226
4848
hooks:
49-
- id: flake8
50-
additional_dependencies: ["flake8-bugbear==22.7.1"]
51-
language_version: python3.9
49+
- id: ruff
50+
args: [--force-exclude, --format, grouped, --show-source]
5251
- repo: https://github.com/codespell-project/codespell
5352
rev: "v2.2.2"
5453
hooks:

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,19 @@ lines_after_imports = 2
142142
line_length = 127
143143
known_first_party = "build"
144144
skip = [] # "build" is included in the default skip list
145+
146+
[tool.ruff]
147+
line-length = 127
148+
target-version = "py37"
149+
select = [
150+
"B", # flake8-bugbear
151+
"C4", # flake8-comprehensions
152+
"C9", # mccabe
153+
"E", # pycodestyle
154+
"F", # pyflakes
155+
"W", # pycodestyle
156+
"RUF", # ruff
157+
]
158+
159+
[tool.ruff.mccabe]
160+
max-complexity = 10

tests/packages/test-bad-wheel/backend_bad_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: MIT
22

3-
from setuptools.build_meta import build_sdist # noqa: F401
3+
from setuptools.build_meta import build_sdist as build_sdist
44

55

66
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SPDX-License-Identifier: MIT
22

3-
from setuptools.build_meta import build_sdist, build_wheel # noqa: F401
3+
from setuptools.build_meta import build_sdist as build_sdist, build_wheel as build_wheel

tests/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_build(monkeypatch, project, args, call, tmp_path):
124124

125125
def test_isolation(tmp_dir, package_test_flit, mocker):
126126
try:
127-
import flit_core # noqa: F401
127+
import flit_core # noqa: F401 # imported but unused
128128
except ModuleNotFoundError:
129129
pass
130130
else:

tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_wheel_metadata(package_test_setuptools, isolated):
1717
@pytest.mark.pypy3323bug
1818
def test_wheel_metadata_isolation(package_test_flit):
1919
try:
20-
import flit_core # noqa: F401
20+
import flit_core # noqa: F401 # imported but unused
2121
except ModuleNotFoundError:
2222
pass
2323
else:

tox.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,3 @@ commands =
101101
coverage html -d {toxworkdir}/htmlcov -i
102102
python -m diff_cover.diff_cover_tool --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml
103103
depends = {py311, py310, py39, py38, py37, pypy37, pypy38, pypy39}{,-min}, path
104-
105-
[flake8]
106-
max-line-length = 127
107-
max-complexity = 10
108-
extend-ignore = E203
109-
extend-select = B9

0 commit comments

Comments
 (0)