Skip to content

Commit 240a6f5

Browse files
committed
- e add ruff to lint checks
ruff auto-fixes already run in GitHub Actions; this adds checks which don't have auto-fixes
1 parent 9811134 commit 240a6f5

2 files changed

Lines changed: 115 additions & 2 deletions

File tree

.mise.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ run = "python -m mypy ."
2222
depends = ["pip-install"]
2323

2424
[tasks.lint]
25-
run = "python -m pylint ."
25+
run = [
26+
"python -m pylint .",
27+
"python -m ruff check .",
28+
]
2629
depends = ["pip-install"]
2730

2831
[tasks.integration]

ruff.toml

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,123 @@ select = [
1111
]
1212
ignore = [
1313
"D", # pydocstyle
14+
"TD", # TODO comments
1415

15-
# [*] we currently have these violations that are fixable if we want
16+
# auto-fixable if we want to enable them in the future
1617
"COM812", # Trailing comma missing
1718
"RET505", # Unnecessary `...` after `return` statement
1819
"SIM300", # Yoda condition detected
1920
"TD006", # Invalid TODO capitalization: `...` should be `TODO`
2021

22+
# requires manual fix
23+
"A001", # Variable `dict` is shadowing a Python builtin
24+
"A002", # Function argument `...` is shadowing a Python builtin
25+
"ANN001", # Missing type annotation for function argument `...`
26+
"ANN002", # Missing type annotation for `...`
27+
"ANN003", # Missing type annotation for `...`
28+
"ANN201", # Missing return type annotation for public function
29+
"ANN202", # Missing return type annotation for private function
30+
"ANN204", # Missing return type annotation for special method `__str__`
31+
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `...`
32+
"ARG001", # Unused function argument: `...`
33+
"ARG005", # Unused lambda argument: `...`
34+
"B006", # Do not use mutable data structures for argument defaults
35+
"B007", # Loop control variable `...` not used within loop body
36+
"B011", # Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
37+
"B020", # Loop control variable `...` overrides iterable it iterates
38+
"B023", # Function definition does not bind loop variable `...`
39+
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
40+
"B905", # `zip()` without an explicit `strict=` parameter
41+
"BLE001", # Do not catch blind exception: `BaseException`
42+
"C417", # Unnecessary `map()` usage
43+
"C901", # `...` is too complex (11 > 10)
44+
"DTZ001", # `datetime.datetime()` called without a `tzinfo` argument
45+
"DTZ005", # `datetime.datetime.now()` called without a `tz` argument
46+
"DTZ006", # `datetime.datetime.fromtimestamp()` called without a `tz` argument
47+
"E402", # Module level import not at top of file
48+
"E501", # Line too long (98 > 88)
49+
"E711", # Comparison to `None` should be `cond is not None`
50+
"E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
51+
"E722", # Do not use bare `except`
52+
"EM101", # Exception must not use a string literal, assign to variable first
53+
"EM102", # Exception must not use an f-string literal, assign to variable first
54+
"ERA001", # Found commented-out code
55+
"EXE001", # Shebang is present but file is not executable
56+
"EXE005", # Shebang should be at the beginning of the file
57+
"F401", # `...` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
58+
"F403", # `...` used; unable to detect undefined names
59+
"F405", # `...` may be undefined, or defined from star imports
60+
"F841", # Local variable `infinity` is assigned to but never used
61+
"FBT001", # Boolean-typed positional argument in function definition
62+
"FBT002", # Boolean default positional argument in function definition
63+
"FBT003", # Boolean positional value in function call
64+
"FBT003", # Boolean positional value in function call
65+
"FIX002", # Line contains TODO, consider resolving the issue
66+
"G004", # Logging statement uses f-string
67+
"INP001", # File `...` is part of an implicit namespace package. Add an `__init__.py`.
68+
"LOG015", # `info()` call on root logger
69+
"N802", # Function name `...` should be lowercase
70+
"N806", # Variable `...` in function should be lowercase
71+
"N818", # Exception name `...` should be named with an Error suffix
72+
"N999", # Invalid module name: '...'
73+
"PERF203", # `try`-`except` within a loop incurs performance overhead
74+
"PIE810", # Call `startswith` once with a `tuple`
75+
"PLC0415", # `import` should be at the top-level of a file
76+
"PLR0913", # Too many arguments in function definition
77+
"PLR1704", # Redefining argument with the local name `number`
78+
"PLR2004", # Magic value used in comparison, consider replacing `4` with a constant variable
79+
"PLW0108", # Lambda may be unnecessary; consider inlining inner function
80+
"PLW1641", # Object does not implement `__hash__` method
81+
"PLW2101", # Threading lock directly created in `with` statement has no effect
82+
"PLW2901", # `for` loop variable `...` overwritten by assignment target
83+
"PT009", # Use a regular `assert` instead of unittest-style `assertTrue`
84+
"PT013", # Incorrect import of `pytest`; use `import pytest` instead
85+
"PT015", # Assertion always fails, replace with `pytest.fail()`
86+
"PT027", # Use `pytest.raises` instead of unittest-style `assertRaises`
87+
"PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
88+
"PTH102", # `os.mkdir()` should be replaced by `Path.mkdir()`
89+
"PTH103", # `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
90+
"PTH107", # `os.remove()` should be replaced by `Path.unlink()`
91+
"PTH110", # `os.path.exists()` should be replaced by `Path.exists()`
92+
"PTH113", # `os.path.isfile()` should be replaced by `Path.is_file()`
93+
"PTH116", # `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()`
94+
"PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator
95+
"PTH119", # `os.path.basename()` should be replaced by `Path.name`
96+
"PTH120", # `os.path.dirname()` should be replaced by `Path.parent`
97+
"PTH122", # `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent`
98+
"PTH123", # `open()` should be replaced by `Path.open()`
99+
"PYI034", # `__enter__` methods in classes like `Storyboard` usually return `self` at runtime
100+
"PYI036", # The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None`
101+
"RET504", # Unnecessary assignment to `...` before `return` statement
102+
"RUF005", # Consider `[*...]` instead of concatenation
103+
"RUF012", # Mutable default value for class attribute
104+
"RUF100", # Unused `noqa` directive (non-enabled: `F401`)
105+
"S101", # Use of `assert` detected
106+
"S110", # `try`-`except`-`pass` detected, consider logging the exception
107+
"S113", # Probable use of `requests` call without timeout
108+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
109+
"S318", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
110+
"S602", # `subprocess` call with `shell=True` identified, security issue
111+
"S603", # `subprocess` call: check for execution of untrusted input
112+
"S607", # Starting a process with a partial executable path
113+
"SIM102", # Use a single `if` statement instead of nested `if` statements
114+
"SIM105", # Use `...` instead of `try`-`except`-`pass`
115+
"SIM110", # Use `return any(...)` instead of `for` loop
116+
"SIM115", # Use a context manager for opening files
117+
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
118+
"SLF001", # Private member accessed: `...`
119+
"T201", # `print` found
120+
"TC001", # Move application import `...` into a type-checking block
121+
"TC003", # Move standard library import `...` into a type-checking block
122+
"TRY002", # Create your own exception
123+
"TRY003", # Avoid specifying long messages outside the exception class
124+
"TRY300", # Consider moving this statement to an `else` block
125+
"TRY301", # Abstract `raise` to an inner function
126+
"UP007", # Use `X | Y` for type annotations
127+
"UP035", # `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead
128+
"W291", # Trailing whitespace
129+
"W293", # Blank line contains whitespace
130+
21131
]
22132

23133
[lint.per-file-ignores]

0 commit comments

Comments
 (0)