-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
.ruff.toml
437 lines (414 loc) · 16.6 KB
/
.ruff.toml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
target-version = "py311" # Pin Ruff to Python 3.11
line-length = 88
output-format = "full"
extend-exclude = [
"tests/roots/*",
"tests/js/roots/*",
"build/*",
"doc/_build/*",
"doc/usage/extensions/example*.py",
]
[lint]
preview = true
ignore = [
# flake8-annotations
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `{name}`
# flake8-unused-arguments ('ARG')
"ARG001", # Unused function argument: `{name}`
"ARG002", # Unused method argument: `{name}`
"ARG003", # Unused class method argument: `{name}`
"ARG005", # Unused lambda argument: `{name}`
# flake8-commas ('COM')
"COM812", # Trailing comma missing
# pycodestyle
"E741", # Ambiguous variable name: `{name}`
# pyflakes
"F841", # Local variable `{name}` is assigned to but never used
# flake8-logging-format
"G003", # Logging statement uses `+`
# refurb
"FURB101", # `open` and `read` should be replaced by `Path(...).read_text(...)`
"FURB103", # `open` and `write` should be replaced by `Path(...).write_text(...)`
# perflint
"PERF203", # `try`-`except` within a loop incurs performance overhead
# flake8-pie ('PIE')
"PIE790", # Unnecessary `pass` statement
# pylint ('PLC')
"PLC0415", # `import` should be at the top-level of a file
"PLC2701", # Private name import `{name}` from external module `{module}`
# pylint ('PLR')
"PLR0904", # Too many public methods ({methods} > {max_methods})
"PLR0911", # Too many return statements ({returns} > {max_returns})
"PLR0912", # Too many branches ({branches} > {max_branches})
"PLR0913", # Too many arguments in function definition ({c_args} > {max_args})
"PLR0914", # Too many local variables ({current_amount}/{max_amount})
"PLR0915", # Too many statements ({statements} > {max_statements})
"PLR0916", # Too many Boolean expressions ({expressions} > {max_expressions})
"PLR0917", # Too many positional arguments ({c_pos}/{max_pos})
"PLR1702", # Too many nested blocks ({nested_blocks} > {max_nested_blocks})
"PLR2004", # Magic value used in comparison, consider replacing `{value}` with a constant variable
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
"PLR6104", # Use `{operator}` to perform an augmented assignment directly
"PLR6301", # Method `{method_name}` could be a function, class method, or static method
# pylint ('PLW')
"PLW2901", # Outer {outer_kind} variable `{name}` overwritten by inner {inner_kind} target
# flake8-pyi ('PYI')
"PYI025", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin
# flake8-bandit ('S')
"S101", # Use of `assert` detected
"S110", # `try`-`except`-`pass` detected, consider logging the exception
"S404", # `subprocess` module is possibly insecure
"S405", # `xml.etree` methods are vulnerable to XML attacks
"S603", # `subprocess` call: check for execution of untrusted input
# flake8-simplify
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM108", # Use ternary operator `{contents}` instead of `if`-`else`-block
# pyupgrade
"UP031", # Use format specifiers instead of percent format
"UP032", # Use f-string instead of `format` call
]
external = [ # Whitelist for RUF100 unknown code warnings
"E704",
"SIM113",
]
select = [
# flake8-builtins ('A')
# NOT YET USED
# airflow ('AIR')
# Airflow is not used in Sphinx
# flake8-annotations ('ANN')
"ANN",
# flake8-unused-arguments ('ARG')
"ARG",
# flake8-async ('ASYNC')
"ASYNC",
# flake8-bugbear ('B')
"B",
# flake8-blind-except ('BLE')
# NOT YET USED
# flake8-comprehensions ('C4')
"C4",
# mccabe ('C90')
# "C901", # `{name}` is too complex ({complexity} > {max_complexity})
# flake8-commas ('COM')
"COM", # Trailing comma prohibited
# flake8-copyright ('CPY')
# NOT YET USED
# pydocstyle ('D')
# "D100", # Missing docstring in public module
# "D101", # Missing docstring in public class
# "D102", # Missing docstring in public method
# "D103", # Missing docstring in public function
# "D104", # Missing docstring in public package
# "D105", # Missing docstring in magic method
"D106", # Missing docstring in public nested class
# "D107", # Missing docstring in `__init__`
# "D200", # One-line docstring should fit on one line
"D201", # No blank lines allowed before function docstring (found {num_lines})
"D202", # No blank lines allowed after function docstring (found {num_lines})
"D204", # 1 blank line required after class docstring
# "D205", # 1 blank line required between summary line and description
"D206", # Docstring should be indented with spaces, not tabs
"D207", # Docstring is under-indented
"D208", # Docstring is over-indented
"D209", # Multi-line docstring closing quotes should be on a separate line
"D210", # No whitespaces allowed surrounding docstring text
"D211", # No blank lines allowed before class docstring
# "D212", # Multi-line docstring summary should start at the first line
# "D213", # Multi-line docstring summary should start at the second line
# "D214", # Section is over-indented ("{name}")
# "D215", # Section underline is over-indented ("{name}")
"D300", # Use triple double quotes `"""`
"D301", # Use `r"""` if any backslashes in a docstring
# "D400", # First line should end with a period
# "D401", # First line of docstring should be in imperative mood: "{first_line}"
"D402", # First line should not be the function's signature
"D403", # First word of the first line should be capitalized: `{}` -> `{}`
# "D404", # First word of the docstring should not be "This"
"D405", # Section name should be properly capitalized ("{name}")
# "D406", # Section name should end with a newline ("{name}")
# "D407", # Missing dashed underline after section ("{name}")
"D408", # Section underline should be in the line following the section's name ("{name}")
"D409", # Section underline should match the length of its name ("{name}")
"D410", # Missing blank line after section ("{name}")
"D411", # Missing blank line before section ("{name}")
# "D412", # No blank lines allowed between a section header and its content ("{name}")
# "D413", # Missing blank line after last section ("{name}")
"D414", # Section has no content ("{name}")
# "D415", # First line should end with a period, question mark, or exclamation point
"D416", # Section name should end with a colon ("{name}")
"D417", # Missing argument description in the docstring for `{definition}`: `{name}`
"D418", # Function decorated with `@overload` shouldn't contain a docstring
"D419", # Docstring is empty
# flake8-django ('DJ')
# Django is not used in Sphinx
# flake8-datetimez ('DTZ')
"DTZ",
# pycodestyle ('E')
"E",
# flake8-errmsg ('EM')
"EM",
# eradicate ('ERA')
# NOT YET USED
# flake8-executable ('EXE')
"EXE",
# pyflakes ('F')
"F",
# flake8-future-annotations ('FA')
"FA",
# flake8-fastapi ('FAST')
# FastAPI is not used in Sphinx
# flake8-boolean-trap ('FBT')
# NOT YET USED
# flake8-fixme ('FIX')
# NOT YET USED
# flynt ('FLY')
"FLY",
# refurb ('FURB')
"FURB",
# flake8-logging-format ('G')
"G",
# isort ('I')
"I",
# flake8-import-conventions ('ICN')
"ICN", # flake8-import-conventions
# flake8-no-pep420 ('INP')
"INP",
# flake8-gettext ('INT')
"INT",
# flake8-implicit-str-concat ('ISC')
# NOT YET USED
# flake8-logging ('LOG')
"LOG",
# pep8-naming ('N')
# NOT YET USED
# numpy-specific rules ('NPY')
# Numpy is not used in Sphinx
# pandas-vet ('PD')
# Pandas is not used in Sphinx
# perflint ('PERF')
"PERF",
# pygrep-hooks ('PGH')
"PGH",
# flake8-pie ('PIE')
"PIE",
# pylint ('PL', 'PLC', 'PLE', 'PLR', 'PLW')
"PL",
# flake8-pytest-style ('PT')
"PT",
# flake8-use-pathlib ('PTH')
# NOT YET USED
"PYI",
# Stub files are not used in Sphinx
# flake8-quotes ('Q')
# "Q000", # Double quotes found but single quotes preferred
# "Q001", # Single quote multiline found but double quotes preferred
"Q002", # Single quote docstring found but double quotes preferred
"Q003", # Change outer quotes to avoid escaping inner quotes
"Q004", # Unnecessary escape on inner quote character
# flake8-return ('RET')
"RET501", # Do not explicitly `return None` in function if it is the only possible return value
"RET502", # Do not implicitly `return None` in function able to return non-`None` value
# "RET503", # Missing explicit `return` at the end of function able to return non-`None` value
# "RET504", # Unnecessary assignment to `{name}` before `return` statement
# "RET505", # Unnecessary `{branch}` after `return` statement
# "RET506", # Unnecessary `{branch}` after `raise` statement
"RET507", # Unnecessary `{branch}` after `continue` statement
"RET508", # Unnecessary `{branch}` after `break` statement
# flake8-raise ('RSE')
"RSE",
# ruff-specific rules ('RUF')
# "RUF001", # String contains ambiguous {}. Did you mean {}?
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
# "RUF003", # Comment contains ambiguous {}. Did you mean {}?
"RUF005", # Consider `{expression}` instead of concatenation
"RUF006", # Store a reference to the return value of `{expr}.{method}`
"RUF007", # Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs
"RUF008", # Do not use mutable default values for dataclass attributes
"RUF009", # Do not perform function call `{name}` in dataclass defaults
"RUF010", # Use explicit conversion flag
# "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
# "RUF015", # Prefer `next({iterable})` over single element slice
"RUF016", # Slice in indexed access to type `{value_type}` uses type `{index_type}` instead of an integer
"RUF017", # Avoid quadratic list summation
"RUF018", # Avoid assignment expressions in `assert` statements
"RUF019", # Unnecessary key check before dictionary access
"RUF020", # `{never_like} | T` is equivalent to `T`
# "RUF021", # Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
# "RUF022", # `__all__` is not sorted
# "RUF023", # `{}.__slots__` is not sorted
"RUF024", # Do not pass mutable objects as values to `dict.fromkeys`
"RUF026", # `default_factory` is a positional-only argument to `defaultdict`
# "RUF027", # Possible f-string without an `f` prefix
# "RUF028", # This suppression comment is invalid because {}
# "RUF029", # Function `{name}` is declared `async`, but doesn't `await` or use `async` features.
"RUF030", # `print()` expression in `assert` statement is likely unintentional
# "RUF031", # Use parentheses for tuples in subscripts.
"RUF032", # `Decimal()` called with float literal argument
"RUF033", # `__post_init__` method with argument defaults
"RUF034", # Useless if-else condition
# "RUF100", # Unused `noqa` directive
"RUF101", # `{original}` is a redirect to `{target}`
"RUF200", # Failed to parse pyproject.toml: {message}
# flake8-bandit ('S')
"S",
# flake8-simplify ('SIM')
"SIM", # flake8-simplify
# flake8-self ('SLF')
# NOT YET USED
# flake8-slots ('SLOT')
"SLOT",
# flake8-debugger ('T10')
"T10",
# flake8-print ('T20')
"T20",
# flake8-type-checking ('TCH')
"TCH",
# flake8-todos ('TD')
# "TD001", # Invalid TODO tag: `{tag}`
# "TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
# "TD003", # Missing issue link on the line following this TODO
# "TD004", # Missing colon in TODO
# "TD005", # Missing issue description after `TODO`
"TD006", # Invalid TODO capitalization: `{tag}` should be `TODO`
"TD007", # Missing space after colon in TODO
# flake8-tidy-imports ('TID')
"TID",
# flake8-trio ('TRIO')
# Trio is not used in Sphinx
# tryceratops ('TRY')
# NOT YET USED
# pyupgrade ('UP')
"UP",
# pycodestyle ('W')
"W",
# flake8-2020 ('YTT')
"YTT",
]
[lint.per-file-ignores]
"doc/*" = [
"ANN", # documentation doesn't need annotations
"TC001", # documentation doesn't need type-checking blocks
]
"doc/conf.py" = ["INP001", "W605"]
"doc/development/tutorials/examples/*" = ["I002", "INP001"]
# allow print() in the tutorial
"doc/development/tutorials/examples/recipe.py" = [
"FURB118",
"T201"
]
"sphinx/domains/**" = ["FURB113"]
"tests/test_domains/test_domain_cpp.py" = ["FURB113"]
# from .flake8
"sphinx/*" = ["E241"]
# whitelist ``print`` for stdout messages
"sphinx/_cli/__init__.py" = ["T201"]
# allow use of ``pickle``
"sphinx/{application,builders/__init__,environment/__init__,ext/coverage,search/__init__,versioning}.py" = [
"S301",
"S403",
]
# whitelist ``print`` for stdout messages
"sphinx/cmd/build.py" = ["T201"]
"sphinx/cmd/make_mode.py" = ["T201"]
"sphinx/cmd/quickstart.py" = ["T201"]
"sphinx/environment/collectors/toctree.py" = ["B026"]
"sphinx/environment/adapters/toctree.py" = ["B026"]
# whitelist ``print`` for stdout messages
"sphinx/ext/intersphinx/_cli.py" = ["T201"]
# whitelist ``token`` in docstring parsing
"sphinx/ext/napoleon/docstring.py" = ["S105"]
# whitelist ``print`` for stdout messages
"sphinx/testing/fixtures.py" = ["T201"]
# Ruff bug: https://github.com/astral-sh/ruff/issues/6540
"sphinx/transforms/i18n.py" = ["PGH004"]
# Function wrappers
"sphinx/ext/autodoc/importer.py" = ["D402"]
"sphinx/util/requests.py" = ["D402"]
"sphinx/search/*" = ["E501"]
# whitelist ``token`` in date format parsing
"sphinx/util/i18n.py" = ["S105"]
# whitelist ``token`` in literal parsing
"sphinx/writers/html5.py" = ["S105"]
"tests/*" = [
"E501",
"ANN", # tests don't need annotations
"D402",
"PLC1901", # whitelist comparisons to the empty string ('')
"S301", # allow use of ``pickle``
"S403", # allow use of ``pickle``
"T201", # whitelist ``print`` for tests
]
# these tests need old ``typing`` generic aliases
"tests/test_util/test_util_typing.py" = ["UP006", "UP007", "UP035"]
"tests/test_util/typing_test_data.py" = ["FA100", "I002", "PYI030", "UP006", "UP007", "UP035"]
"utils/*" = [
"T201", # whitelist ``print`` for stdout messages
"ANN", # utilities don't need annotations
]
[lint.pycodestyle]
max-line-length = 95
[lint.flake8-quotes]
inline-quotes = "single"
[lint.isort]
forced-separate = [
"tests",
]
required-imports = [
"from __future__ import annotations",
]
[format]
preview = true
quote-style = "single"
exclude = [
"sphinx/addnodes.py",
"sphinx/application.py",
"sphinx/builders/latex/constants.py",
"sphinx/config.py",
"sphinx/domains/__init__.py",
"sphinx/domains/c/_parser.py",
"sphinx/domains/c/_ids.py",
"sphinx/domains/c/__init__.py",
"sphinx/domains/c/_symbol.py",
"sphinx/domains/c/_ast.py",
"sphinx/domains/changeset.py",
"sphinx/domains/citation.py",
"sphinx/domains/cpp/_parser.py",
"sphinx/domains/cpp/_ids.py",
"sphinx/domains/cpp/__init__.py",
"sphinx/domains/cpp/_symbol.py",
"sphinx/domains/cpp/_ast.py",
"sphinx/domains/index.py",
"sphinx/domains/javascript.py",
"sphinx/domains/math.py",
"sphinx/domains/python/_annotations.py",
"sphinx/domains/python/__init__.py",
"sphinx/domains/python/_object.py",
"sphinx/domains/rst.py",
"sphinx/domains/std/__init__.py",
"sphinx/ext/autodoc/__init__.py",
"sphinx/ext/autodoc/directive.py",
"sphinx/ext/autodoc/importer.py",
"sphinx/ext/autodoc/mock.py",
"sphinx/ext/autodoc/preserve_defaults.py",
"sphinx/ext/autodoc/type_comment.py",
"sphinx/ext/autodoc/typehints.py",
"sphinx/ext/autosectionlabel.py",
"sphinx/ext/autosummary/__init__.py",
"sphinx/ext/coverage.py",
"sphinx/ext/doctest.py",
"sphinx/ext/duration.py",
"sphinx/ext/extlinks.py",
"sphinx/ext/githubpages.py",
"sphinx/ext/graphviz.py",
"sphinx/ext/ifconfig.py",
"sphinx/ext/imgconverter.py",
"sphinx/ext/imgmath.py",
"sphinx/ext/inheritance_diagram.py",
"sphinx/ext/linkcode.py",
"sphinx/ext/mathjax.py",
"sphinx/ext/todo.py",
"sphinx/ext/viewcode.py",
"sphinx/registry.py",
]