Skip to content

Commit 3bdf538

Browse files
committed
DEVELOPER.md + ruff.toml
1 parent 1d82d71 commit 3bdf538

2 files changed

Lines changed: 47 additions & 5 deletions

File tree

‎DEVELOPER.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CI runs Ruff (config in `ruff.toml`) in `.github/workflows/run-validations.yml`.
3030
ruff check .
3131
```
3232

33-
`ruff check` is enforced on the whole repository, except `tests`, `scripts` and `src`. Ruff is pinned to `0.17.*` and runs in preview mode so the pycodestyle indentation, whitespace and blank-line rules stay enabled. Security rules (`S`, the flake8-bandit port) are enabled, with `assert` allowed. Formatting is not checked in CI.
33+
`ruff check` covers the whole repository except `tests`, `scripts` and `src`. Ruff is pinned to `0.17.*` and runs in preview mode. Enabled rule sets: `E`, `F`, `W` (pycodestyle, Pyflakes), `S` (security, `assert` allowed), `B` (bugbear), `PL` (Pylint), `SIM` (simplify) and `C90` (complexity). Disabled rules are commented in `ruff.toml`; remove baseline entries as they are fixed. Formatting is not checked in CI.
3434

3535
## Vulnerability scan
3636

‎ruff.toml‎

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,54 @@ extend-exclude = ["scripts", "src", "tests", ".cache", ".idea", ".tox", "venv"]
33

44
[lint]
55
preview = true
6-
select = ["E", "F", "W", "S"]
6+
select = ["E", "F", "W", "S", "B", "PL", "SIM", "C90"]
77
ignore = [
8-
"E402", # module-level import not at top
9-
"F811", # redefinition of unused name
10-
"S101", # assert
8+
"E402", # module-level import not at top
9+
"F811", # redefinition of unused name
10+
"S101", # assert
11+
"PLR0904", # too many public methods
12+
"PLR0911", # too many return statements
13+
"PLR0912", # too many branches
14+
"PLR0913", # too many arguments
15+
"PLR0914", # too many local variables
16+
"PLR0915", # too many statements
17+
"PLR0916", # too many boolean expressions
18+
"PLR0917", # too many positional arguments
19+
"PLR2004", # magic value in comparison
20+
"PLR6301", # method could be a function (no self use)
21+
"PLW0717", # too many statements in try clause
22+
"B006", # mutable argument default
23+
"B018", # useless expression
24+
"B028", # warnings.warn without explicit stacklevel
25+
"B903", # class that could be a dataclass/namedtuple
26+
"B904", # raise inside except without `from`
27+
"B909", # mutating a collection while iterating over it
28+
"SIM102", # nested ifs that can be collapsed
29+
"SIM105", # try/except/pass that can use contextlib.suppress
30+
"SIM108", # if/else block that can be a ternary
31+
"SIM113", # manual loop counter instead of enumerate
32+
"SIM114", # if branches with identical bodies
33+
"SIM115", # open() without a context manager
34+
"SIM118", # `key in dict.keys()`
35+
"SIM211", # `False if x else True` instead of `not x`
36+
"SIM300", # Yoda condition
37+
"SIM401", # if/else that can be dict.get
38+
"PLC0414", # useless import alias
39+
"PLC0415", # import outside top level
40+
"PLC1901", # comparison to empty string
41+
"PLE0307", # __str__ returning non-str
42+
"PLR1722", # exit() instead of sys.exit()
43+
"PLR5501", # else + if that can be elif
44+
"PLR6201", # list/tuple literal in membership test (use set)
45+
"PLW0108", # unnecessary lambda
46+
"PLW0127", # self-assigning variable
47+
"PLW0128", # redeclared assigned name
48+
"PLW1508", # non-string default for os.getenv
49+
"PLW1514", # open() without explicit encoding
1150
]
1251

52+
[lint.mccabe]
53+
max-complexity = 25 # baseline: highest existing is 25, lower as functions are refactored
54+
1355
[lint.per-file-ignores]
1456
"examples/**" = ["S104", "S108", "S110"] # demo code: bind-all, temp file, try/except/pass

0 commit comments

Comments
 (0)