@@ -32,13 +32,21 @@ exclude = [
32
32
# are invoked via separate runs of ruff in pre-commit:
33
33
# see our .pre-commit-config.yaml file for details
34
34
exclude = [" **/test_cases/**/*.py" ]
35
+ # We still use flake8-pyi and flake8-noqa to check these (see .flake8 config file);
36
+ # tell ruff not to flag these as e.g. "unused noqa comments"
37
+ external = [" F821" , " NQA" , " Y" ]
35
38
select = [
36
39
" B" , # flake8-bugbear
37
40
" FA" , # flake8-future-annotations
38
41
" I" , # isort
42
+ " RUF" , # Ruff-specific and unused-noqa
39
43
" UP" , # pyupgrade
40
- # Only enable rules that have safe autofixes:
41
- " F401" , # Remove unused imports
44
+ # Flake8 base rules
45
+ " E" , # pycodestyle Error
46
+ " F" , # Pyflakes
47
+ " W" , # pycodestyle Warning
48
+ # PYI: only enable rules that always autofix, avoids duplicate # noqa with flake8-pyi
49
+ # See https://github.com/plinss/flake8-noqa/issues/22
42
50
" PYI009" , # use `...`, not `pass`, in empty class bodies
43
51
" PYI010" , # function bodies must be empty
44
52
" PYI012" , # class bodies must not contain `pass`
@@ -51,15 +59,43 @@ select = [
51
59
" PYI058" , # use `Iterator` as the return type for `__iter__` methods
52
60
]
53
61
ignore = [
62
+ # ##
63
+ # Rules that can conflict with the formatter (Black)
64
+ # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
65
+ # ##
66
+ " E111" , # indentation-with-invalid-multiple
67
+ " E114" , # indentation-with-invalid-multiple-comment
68
+ " E117" , # over-indented
69
+ " W191" , # tab-indentation
70
+ # ##
71
+ # Rules we don't want or don't agree with
72
+ # ##
54
73
# Slower and more verbose https://github.com/astral-sh/ruff/issues/7871
55
74
" UP038" , # Use `X | Y` in `isinstance` call instead of `(X, Y)`
75
+ # Used for direct, non-subclass type comparison, for example: `type(val) is str`
76
+ # see https://github.com/astral-sh/ruff/issues/6465
77
+ " E721" , # Do not compare types, use `isinstance()`
78
+ # ##
79
+ # False-positives, but already checked by type-checkers
80
+ # ##
81
+ # Ruff doesn't support multi-file analysis yet: https://github.com/astral-sh/ruff/issues/5295
82
+ " RUF013" , # PEP 484 prohibits implicit `Optional`
56
83
]
57
84
58
85
[tool .ruff .lint .per-file-ignores ]
59
86
"*.pyi" = [
60
87
# Most flake8-bugbear rules don't apply for third-party stubs like typeshed.
61
88
# B033 could be slightly useful but Ruff doesn't have per-file select
62
89
" B" , # flake8-bugbear
90
+ # Rules that are out of the control of stub authors:
91
+ " E501" , # Line too long
92
+ " E741" , # ambiguous variable name
93
+ " F403" , # `from . import *` used; unable to detect undefined names
94
+ # False positives in stubs
95
+ " F821" , # Undefined name: https://github.com/astral-sh/ruff/issues/3011
96
+ # Stubs can sometimes re-export entire modules.
97
+ # Issues with using a star-imported name will be caught by type-checkers.
98
+ " F405" , # may be undefined, or defined from star imports
63
99
]
64
100
65
101
[tool .ruff .lint .isort ]
0 commit comments