Skip to content

Commit e1f4252

Browse files
authored
Merge pull request #256 from Borda/lint/ruff
lint: switch black+import+flake8 -> Ruff
2 parents bfd02a1 + 5c68d13 commit e1f4252

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
repos:
3-
- repo: https://github.com/psf/black-pre-commit-mirror
4-
rev: 24.2.0
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.2.2
55
hooks:
6-
- id: black
7-
args: [--safe, --quiet, --target-version, py38]
6+
- id: ruff-format
7+
args: ["--preview"]
8+
- id: ruff
9+
args: ["--exit-non-zero-on-fix"]
810
- repo: https://github.com/pre-commit/pre-commit-hooks
911
rev: v4.5.0
1012
hooks:
@@ -15,22 +17,6 @@ repos:
1517
- id: check-yaml
1618
- id: debug-statements
1719
language_version: python3
18-
- repo: https://github.com/PyCQA/flake8
19-
rev: 7.0.0
20-
hooks:
21-
- id: flake8
22-
language_version: python3
23-
additional_dependencies: [flake8-typing-imports>=1.9.0]
24-
- repo: https://github.com/asottile/reorder_python_imports
25-
rev: v3.12.0
26-
hooks:
27-
- id: reorder-python-imports
28-
args: ['--application-directories=.:src', --py3-plus]
29-
- repo: https://github.com/asottile/pyupgrade
30-
rev: v3.15.1
31-
hooks:
32-
- id: pyupgrade
33-
args: [--py38-plus]
3420
- repo: https://github.com/sphinx-contrib/sphinx-lint
3521
rev: v0.9.1
3622
hooks:

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,29 @@ requires = [
33
"setuptools >= 40.0",
44
]
55
build-backend = "setuptools.build_meta"
6+
7+
8+
9+
[tool.ruff]
10+
fix = true
11+
# todo: drop when migrated project metadata from setup.cfg
12+
target-version = "py38"
13+
lint.select = [
14+
"E", # https://pypi.org/project/pyflakes/
15+
"W", # https://pypi.org/project/pycodestyle/
16+
"F", # https://pypi.org/project/pyflakes/
17+
"I", # https://pypi.org/project/isort/
18+
"S", # https://pypi.org/project/flake8-bandit/
19+
"UP", # https://pypi.org/project/upgrade-checker/
20+
]
21+
22+
[tool.ruff.lint.per-file-ignores]
23+
"test_*.py" = ["S101", "S311"]
24+
25+
[tool.ruff.lint.pydocstyle]
26+
# Use Google-style docstrings.
27+
convention = "google"
28+
29+
[tool.ruff.lint.mccabe]
30+
# Unlike Flake8, default to a complexity level of 10.
31+
max-complexity = 10

pytest_rerunfailures.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def evaluate_condition(item, mark, condition: object) -> bool:
184184
try:
185185
filename = f"<{mark.name} condition>"
186186
condition_code = compile(condition, filename, "eval")
187-
result = eval(condition_code, globals_)
187+
result = eval(condition_code, globals_) # noqa: S307
188188
except SyntaxError as exc:
189189
msglines = [
190190
"Error evaluating %r condition" % mark.name,
@@ -361,9 +361,7 @@ def __init__(self):
361361

362362
def _hash(self, crashitem: str) -> str:
363363
if crashitem not in self.hmap:
364-
self.hmap[crashitem] = hashlib.sha1(
365-
crashitem.encode(),
366-
).hexdigest()[:10]
364+
self.hmap[crashitem] = hashlib.sha1(crashitem.encode()).hexdigest()[:10] # noqa: S324
367365

368366
return self.hmap[crashitem]
369367

0 commit comments

Comments
 (0)