Skip to content

Commit 3264406

Browse files
Enforce ruff rules
1 parent 06cd021 commit 3264406

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,58 @@ test-command = "python -m unittest discover -v {project}/tests"
7979
addopts = "--capture=no --assert=plain --strict-markers --tb=native --import-mode=importlib"
8080
testpaths = "tests"
8181
filterwarnings = "default"
82+
83+
[tool.ruff.lint]
84+
extend-select = [
85+
"B",
86+
"C4",
87+
"EXE",
88+
"ISC",
89+
"PIE",
90+
"PYI",
91+
"SLOT",
92+
"PERF",
93+
"SIM",
94+
"FLY",
95+
"PERF",
96+
"W",
97+
"PLC",
98+
"PLE",
99+
"PLR",
100+
"UP",
101+
"FURB",
102+
"RUF",
103+
]
104+
ignore = [
105+
"B007", # Loop control variable not used within loop body
106+
"B011", # Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
107+
"PYI026", # Use `typing_extensions.TypeAlias` for type alias
108+
"SIM105", # Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass`
109+
"SIM108", # Use ternary operator instead of `if`-`else`-block
110+
"PLC0415", # `import` should be at the top-level of a file
111+
"PLE0605", # Invalid format for `__all__`, must be `tuple` or `list`
112+
"PLR09", # Too many [...]
113+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable*
114+
"RUF005", # Consider using unpacking operator instead of concatenation
115+
"RUF006", # Store a reference to the return value
116+
"RUF059", # Unpacked variable is never used
117+
"RUF100", # Unused blanket `noqa` directive
118+
]
119+
120+
[tool.ruff.lint.extend-per-file-ignores]
121+
"setup.py" = [
122+
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
123+
"C408", # Unnecessary `dict()` call (rewrite as a literal)
124+
"E402", # Module level import not at top of file
125+
]
126+
"tests/**" = [
127+
"B018", # Found useless expression. Either assign it to a variable or remove it.
128+
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
129+
"B023", # Function definition does not bind loop variable
130+
"C408", # Unnecessary `dict()` call (rewrite as a literal)
131+
"E731", # Do not assign a `lambda` expression, use a `def`
132+
"PERF203", # `try`-`except` within a loop incurs performance overhead
133+
"SIM115", # Use a context manager for opening files
134+
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
135+
"RUF012", # Mutable default value for class attribute
136+
]

0 commit comments

Comments
 (0)