Skip to content

Commit 7a0ec53

Browse files
even-evenvyuroshchin
andauthored
add ruff and typos linters, drop black/isort/flake8 (#195)
* add ruff and typos linters, drop black/isort/flake8 * add ruff and typos linters, drop black/isort/flake8 --------- Co-authored-by: vyuroshchin <[email protected]>
1 parent 55d13ef commit 7a0ec53

File tree

6 files changed

+99
-39
lines changed

6 files changed

+99
-39
lines changed

.pre-commit-config.yaml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
---
22
repos:
3-
- repo: https://github.com/psf/black
4-
rev: 25.11.0
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.14.10
55
hooks:
6-
- id: black
7-
args: [--safe, --quiet, --target-version, py310]
8-
- repo: https://github.com/asottile/blacken-docs
9-
rev: 1.20.0
10-
hooks:
11-
- id: blacken-docs
12-
additional_dependencies: [black==25.11.0]
6+
- id: ruff-format
7+
- id: ruff-check
8+
args: [--fix]
9+
1310
- repo: https://github.com/pre-commit/pre-commit-hooks
1411
rev: v6.0.0
1512
hooks:
@@ -33,26 +30,18 @@ repos:
3330
args:
3431
- --pytest-test-first
3532
language_version: python3
36-
- repo: https://github.com/PyCQA/flake8
37-
rev: 7.0.0
38-
hooks:
39-
- id: flake8
40-
language_version: python3
41-
additional_dependencies: [flake8-typing-imports==1.17.0]
42-
- repo: https://github.com/pycqa/isort
43-
rev: 7.0.0
44-
hooks:
45-
- id: isort
46-
- repo: https://github.com/asottile/pyupgrade
47-
rev: v3.21.1
48-
hooks:
49-
- id: pyupgrade
50-
args: [--keep-percent-format, --py310-plus]
33+
5134
- repo: https://github.com/pre-commit/pygrep-hooks
5235
rev: v1.10.0
5336
hooks:
5437
- id: rst-backticks
38+
5539
- repo: https://github.com/adrienverge/yamllint.git
5640
rev: v1.37.1
5741
hooks:
5842
- id: yamllint
43+
44+
- repo: https://github.com/crate-ci/typos
45+
rev: v1.42.0
46+
hooks:
47+
- id: typos

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ Changelog
394394

395395
x.y.z
396396
-----
397+
- Add ruff and typos linters, drop black/isort/flake8 linters. Thanks Vladimir Roshchin.
397398
- Minimum support Python3.10 and pytest=8.0. Thanks Vladimir Roshchin.
398399
- Add support Python3.13 and Python3.14. Thanks Vladimir Roshchin.
399400
- Detect debuggers registered with sys.monitoring. Thanks Rich Chiodo.

pytest_timeout.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def pytest_report_header(config):
227227

228228
session_timeout = config.getoption("session_timeout")
229229
if session_timeout:
230-
timeout_header.append("session timeout: %ss" % session_timeout)
230+
timeout_header.append(f"session timeout: {session_timeout}s")
231231
if timeout_header:
232232
return timeout_header
233233
return None
@@ -413,7 +413,7 @@ def _parse_marker(marker):
413413
"""
414414
if not marker.args and not marker.kwargs:
415415
raise TypeError("Timeout marker must have at least one argument")
416-
timeout = method = func_only = NOTSET = object()
416+
timeout = method = func_only = NOTSET = object() # noqa: N806
417417
for kw, val in marker.kwargs.items():
418418
if kw == "timeout":
419419
timeout = val
@@ -448,9 +448,8 @@ def _validate_timeout(timeout, where):
448448
return None
449449
try:
450450
return float(timeout)
451-
except ValueError:
452-
msg = f"Invalid timeout {timeout} from {where}"
453-
raise ValueError(msg)
451+
except ValueError as err:
452+
raise ValueError(f"Invalid timeout {timeout} from {where}") from err
454453

455454

456455
def _validate_method(method, where):
@@ -476,8 +475,8 @@ def _validate_disable_debugger_detection(disable_debugger_detection, where):
476475
return None
477476
if not isinstance(disable_debugger_detection, bool):
478477
raise ValueError(
479-
"Invalid disable_debugger_detection value %s from %s"
480-
% (disable_debugger_detection, where)
478+
f"Invalid disable_debugger_detection value {disable_debugger_detection}"
479+
f" from {where}"
481480
)
482481
return disable_debugger_detection
483482

ruff.toml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
exclude = [
2+
".bzr",
3+
".direnv",
4+
".eggs",
5+
".git",
6+
".git-rewrite",
7+
".hg",
8+
".ipynb_checkpoints",
9+
".mypy_cache",
10+
".nox",
11+
".pants.d",
12+
".pyenv",
13+
".pytest_cache",
14+
".pytype",
15+
".ruff_cache",
16+
".svn",
17+
".tox",
18+
".venv",
19+
".vscode",
20+
"__pypackages__",
21+
"_build",
22+
"buck-out",
23+
"build",
24+
"dist",
25+
"migrations",
26+
"node_modules",
27+
"site-packages",
28+
"venv",
29+
]
30+
31+
line-length = 88 # like black
32+
target-version = "py310"
33+
fix = true
34+
unsafe-fixes = true
35+
36+
37+
[lint]
38+
select = [
39+
"E", # pycodestyle
40+
"F", # pyflakes
41+
"I", # isort
42+
"N", # pep8-naming
43+
"UP", # pyupgrade
44+
"B", # bugbear
45+
"C4", # comprehensions
46+
"SIM", # simplify
47+
"TID", # tidy imports
48+
"G", # f-string is forbidden
49+
"T", # print is forbidden
50+
"FURB", # Refurb
51+
"ASYNC", # flake8-async
52+
"PERF", # Perflint
53+
"PLE", # pylint (error)
54+
"T10", # flake8-debugger
55+
"EXE", # flake8-executable
56+
"INT", # flake8-gettext
57+
"ISC", # flake8-implicit-str-concat
58+
"PT", # pytest
59+
"LOG", # logging
60+
"S", # bandit
61+
]
62+
ignore = [
63+
"S311", # Random
64+
]
65+
[lint.per-file-ignores]
66+
"*test_*" = ["S101"] # asserts in tests
67+
68+
[lint.isort]
69+
combine-as-imports = true
70+
force-wrap-aliases = true
71+
split-on-trailing-comma = true
72+
73+
[format]
74+
quote-style = "double"
75+
indent-style = "space"
76+
skip-magic-trailing-comma = false

test_pytest_timeout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_marker_help(pytester):
440440

441441

442442
@pytest.mark.parametrize(
443-
["debugging_module", "debugging_set_trace"],
443+
("debugging_module", "debugging_set_trace"),
444444
[
445445
("pdb", "set_trace()"),
446446
pytest.param(
@@ -484,7 +484,7 @@ def test_foo():
484484

485485

486486
@pytest.mark.parametrize(
487-
["debugging_module", "debugging_set_trace"],
487+
("debugging_module", "debugging_set_trace"),
488488
[
489489
("pdb", "set_trace()"),
490490
pytest.param(

tox.ini

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,5 @@ commands = pytest {posargs}
1616
[testenv:linting]
1717
skip_install = True
1818
basepython = python3
19-
deps = pre-commit>=4.0.0
19+
deps = pre-commit>=4.5.1
2020
commands = pre-commit run --all-files --show-diff-on-failure
21-
22-
23-
[flake8]
24-
disable-noqa = True
25-
max-line-length = 88

0 commit comments

Comments
 (0)