Repository navigation
Expand file tree
/
Copy pathruff.toml
More file actions
51 lines (47 loc) · 2.58 KB
/
Copy pathruff.toml
File metadata and controls
51 lines (47 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Python linting, so the server is held to a comparable bar to the sensor's clippy -D warnings.
#
# Deliberately NOT a style crusade. Maltrail's Python is long-lived, written in a consistent
# house style, and reformatting it would bury real history under churn for no defect found. What
# is enabled here is the set that catches BUGS: undefined names, unused imports and variables,
# mutable default arguments, bare excepts that swallow control flow, comparison mistakes.
# NOT the project's floor. Maltrail supports Python 3.6 (README, and the CI `floor` job runs the
# whole suite in python:3.6-slim), but py37 is the OLDEST target ruff accepts - it rejects "py36"
# outright. So this is ruff's minimum, not ours, and it does not widen what is linted: none of the
# rules selected below are version-gated. The 3.6 floor is enforced by actually running on 3.6,
# which is what caught the str.isascii() call that emptied the trail set on RHEL 8 / CentOS 7 /
# Leap 15 / Amazon Linux 2.
target-version = "py37"
line-length = 130
exclude = [
"old", # the previous sensor, kept verbatim as the parity oracle
"html",
"misc",
"trails",
".git",
]
[lint]
select = [
"F821", # undefined name — a NameError waiting for the branch that reaches it
"F811", # redefinition of an unused name: the second one silently wins
"F502", # percent-format mistakes, in a codebase built on %-formatting
"F506",
"F522",
"F601", # `x in (1, 2)` written as `x in 1, 2` and similar precedence traps
"E9", # syntax and IO errors
"B006", # mutable default argument — a silent shared-state bug
"B008", # function call in a default argument, evaluated once at import
"PLE", # pylint ERRORS only, never its conventions or refactor suggestions
]
# Measured before choosing: the full F/B/C4/RUF set reports 76 findings here and NOT ONE is a
# defect — comprehension rewrites, unused loop variables, `list()` around a generator, unused
# imports that are deliberate (core/httpd.py imports `_strptime` purely for its side effect, a
# documented CPython thread-safety workaround, and a linter cannot know that).
#
# A gate that starts with 76 known failures teaches people to ignore it, and auto-fixing them
# would mean a large unreviewable diff across working tools. So the selection above is the
# bug-catching subset only, and it passes clean today — which is what makes it enforceable.
# Widening it is a deliberate follow-up, not a drive-by.
ignore = []
[lint.per-file-ignores]
# Tests import for side effects and shadow names on purpose.
"tests/*" = [ "F401", "F811" ]