Files
sphinx/.ruff.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

415 lines
22 KiB
TOML
Raw Normal View History

target-version = "py39" # Pin Ruff to Python 3.9
line-length = 95
show-source = true
[lint]
preview = true
exclude = [
".git",
".tox",
".venv",
"tests/roots/*",
"build/*",
"doc/_build/*",
"sphinx/search/*",
"doc/usage/extensions/example*.py",
]
ignore = [
# pycodestyle
"E741", # Ambiguous variable name: `{name}`
# pyflakes
"F841", # Local variable `{name}` is assigned to but never used
# pylint
"PLC1901", # simplify truthy/falsey string comparisons
]
external = [ # Whitelist for RUF100 unknown code warnings
"E704",
"SIM113",
]
select = [
2023-12-26 03:15:37 +00:00
# flake8-builtins ('A')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# airflow ('AIR')
# Airflow is not used in Sphinx
2023-12-26 03:15:37 +00:00
# flake8-annotations ('ANN')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-unused-arguments ('ARG')
"ARG004", # Unused static method argument: `{name}`
# flake8-async ('ASYNC')
"ASYNC",
2023-12-26 03:15:37 +00:00
# flake8-bugbear ('B')
"B",
2023-12-26 03:15:37 +00:00
# flake8-blind-except ('BLE')
# NOT YET USED
# flake8-comprehensions ('C4')
"C4",
# mccabe ('C90')
# "C901", # `{name}` is too complex ({complexity} > {max_complexity})
2023-12-26 03:15:37 +00:00
# flake8-commas ('COM')
"COM812", # Trailing comma missing
"COM818", # Trailing comma on bare tuple prohibited
"COM819", # Trailing comma prohibited
# pydocstyle ('D')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-django ('DJ')
# Django is not used in Sphinx
2023-12-26 03:15:37 +00:00
# flake8-datetimez ('DTZ')
"DTZ",
2023-12-26 03:15:37 +00:00
# pycodestyle ('E')
"E",
2023-12-26 03:15:37 +00:00
# flake8-errmsg ('EM')
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"EM103", # Exception must not use a `.format()` string directly, assign to variable first
# eradicate ('ERA')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-executable ('EXE')
"EXE",
2023-12-26 03:15:37 +00:00
# pyflakes ('F')
"F",
2023-12-26 03:15:37 +00:00
# flake8-future-annotations ('FA')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-boolean-trap ('FBT')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-fixme ('FIX')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flynt ('FLY')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-logging-format ('G')
"G001", # Logging statement uses `str.format`
# "G002", # Logging statement uses `%`
# "G003", # Logging statement uses `+`
2023-12-26 03:15:37 +00:00
"G004", # Logging statement uses f-string
"G010", # Logging statement uses `warn` instead of `warning`
"G101", # Logging statement uses an `extra` field that clashes with a `LogRecord` field: `{key}`
"G201", # Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)`
"G202", # Logging statement has redundant `exc_info`
# isort ('I')
"I",
2023-12-26 03:15:37 +00:00
# flake8-import-conventions ('ICN')
"ICN001", # `{name}` should be imported as `{asname}`
"ICN002", # `{name}` should not be imported as `{asname}`
"ICN003", # Members of `{name}` should not be imported explicitly
# flake8-no-pep420 ('INP')
"INP001", # File `{filename}` is part of an implicit namespace package. Add an `__init__.py`.
# flake8-gettext ('INT')
"INT001", # f-string is resolved before function call; consider `_("string %s") % arg`
"INT002", # `format` method argument is resolved before function call; consider `_("string %s") % arg`
"INT003", # printf-style format is resolved before function call; consider `_("string %s") % arg`
# flake8-implicit-str-concat ('ISC')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# pep8-naming ('N')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# numpy-specific rules ('NPY')
# Numpy is not used in Sphinx
2023-12-26 03:15:37 +00:00
# pandas-vet ('PD')
# Pandas is not used in Sphinx
2023-12-26 03:15:37 +00:00
# perflint ('PERF')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# pygrep-hooks ('PGH')
"PGH",
2023-12-26 03:15:37 +00:00
# flake8-pie ('PIE')
# "PIE790", # Unnecessary `pass` statement
2023-12-26 03:15:37 +00:00
"PIE794", # Class field `{name}` is defined multiple times
"PIE796", # Enum contains duplicate value: `{value}`
"PIE800", # Unnecessary spread `**`
"PIE804", # Unnecessary `dict` kwargs
"PIE807", # Prefer `list` over useless lambda
"PIE810", # Call `{attr}` once with a `tuple`
# pylint ('PLC')
"PLC0105", # `{kind}` name "{param_name}" does not reflect its {variance}; consider renaming it to "{replacement_name}"
"PLC0131", # `{kind}` cannot be both covariant and contravariant
"PLC0132", # `{kind}` name `{param_name}` does not match assigned variable name `{var_name}`
# "PLC0205", # Class `__slots__` should be a non-string iterable
# "PLC0208", # Use a sequence type instead of a `set` when iterating over values
2023-12-26 03:15:37 +00:00
"PLC0414", # Import alias does not rename original package
"PLC3002", # Lambda expression called directly. Execute the expression inline instead.
# pylint ('PLE')
"PLE0100", # `__init__` method is a generator
"PLE0101", # Explicit return in `__init__`
"PLE0116", # `continue` not supported inside `finally` clause
"PLE0117", # Nonlocal name `{name}` found without binding
"PLE0118", # Name `{name}` is used prior to global declaration on line {line}
"PLE0241", # Duplicate base `{base}` for class `{class}`
"PLE0302", # The special method `{}` expects {}, {} {} given
"PLE0307", # `__str__` does not return `str`
"PLE0604", # Invalid object in `__all__`, must contain only strings
"PLE0605", # Invalid format for `__all__`, must be `tuple` or `list`
"PLE1142", # `await` should be used within an async function
"PLE1205", # Too many arguments for `logging` format string
"PLE1206", # Not enough arguments for `logging` format string
"PLE1300", # Unsupported format character '{}'
"PLE1307", # Format type does not match argument type
"PLE1310", # String `{strip}` call contains duplicate characters (did you mean `{removal}`?)
"PLE1507", # Invalid type for initial `os.getenv` argument; expected `str`
"PLE1700", # `yield from` statement in async function; use `async for` instead
"PLE2502", # Contains control characters that can permit obfuscated code
"PLE2510", # Invalid unescaped character backspace, use "\b" instead
"PLE2512", # Invalid unescaped character SUB, use "\x1A" instead
"PLE2513", # Invalid unescaped character ESC, use "\x1B" instead
"PLE2514", # Invalid unescaped character NUL, use "\0" instead
"PLE2515", # Invalid unescaped character zero-width-space, use "\u200B" instead
# pylint ('PLR')
# "PLR0124", # Name compared with itself, consider replacing `{left} {} {right}`
2023-12-26 03:15:37 +00:00
"PLR0133", # Two constants compared in a comparison, consider replacing `{left_constant} {} {right_constant}`
"PLR0206", # Cannot have defined parameters for properties
"PLR0402", # Use `from {module} import {name}` in lieu of alias
# "PLR0911", # Too many return statements ({returns} > {max_returns})
# "PLR0912", # Too many branches ({branches} > {max_branches})
# "PLR0913", # Too many arguments to function call ({c_args} > {max_args})
# "PLR0915", # Too many statements ({statements} > {max_statements})
2023-12-26 03:15:37 +00:00
"PLR1701", # Merge `isinstance` calls: `{expr}`
"PLR1711", # Useless `return` statement at end of function
# "PLR1714", # Consider merging multiple comparisons: `{expr}`. Use a `set` if the elements are hashable.
2023-12-26 03:15:37 +00:00
"PLR1722", # Use `sys.exit()` instead of `{name}`
# "PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
# "PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
2023-12-26 03:15:37 +00:00
# pylint ('PLW')
"PLW0120", # `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
"PLW0127", # Self-assignment of variable `{name}`
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0131", # Named expression used without context
"PLW0406", # Module `{name}` imports itself
"PLW0602", # Using global for `{name}` but no assignment is done
# "PLW0603", # Using the global statement to update `{name}` is discouraged
2023-12-26 03:15:37 +00:00
"PLW0711", # Exception to catch is the result of a binary `and` operation
"PLW1508", # Invalid type for environment variable default; expected `str` or `None`
"PLW1509", # `preexec_fn` argument is unsafe when using threads
# "PLW2901", # Outer {outer_kind} variable `{name}` overwritten by inner {inner_kind} target
2023-12-26 03:15:37 +00:00
"PLW3301", # Nested `{}` calls can be flattened
# flake8-pytest-style ('PT')
"PT",
2023-12-26 03:15:37 +00:00
# flake8-use-pathlib ('PTH')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-pyi ('PYI')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-quotes ('Q')
# "Q000", # Double quotes found but single quotes preferred
# "Q001", # Single quote multiline found but double quotes preferred
2023-12-26 03:15:37 +00:00
"Q002", # Single quote docstring found but double quotes preferred
"Q003", # Change outer quotes to avoid escaping inner quotes
# 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
2023-12-26 03:15:37 +00:00
"RET507", # Unnecessary `{branch}` after `continue` statement
"RET508", # Unnecessary `{branch}` after `break` statement
# flake8-raise ('RSE')
"RSE102", # Unnecessary parentheses on raised exception
# ruff-specific rules ('RUF')
# "RUF001", # String contains ambiguous {}. Did you mean {}?
2023-12-26 03:15:37 +00:00
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
# "RUF003", # Comment contains ambiguous {}. Did you mean {}?
# "RUF005", # Consider `{expr}` instead of concatenation
2023-12-26 03:15:37 +00:00
"RUF006", # Store a reference to the return value of `asyncio.{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
"RUF011", # Dictionary comprehension uses static key: `{key}`
# "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
# "RUF013", # PEP 484 prohibits implicit `Optional`
# "RUF015", # Prefer `next({iterable})` over single element slice
2023-12-26 03:15:37 +00:00
"RUF016", # Slice in indexed access to type `{value_type}` uses type `{index_type}` instead of an integer.
# "RUF100", # Unused `noqa` directive
2023-12-26 03:15:37 +00:00
"RUF200", # Failed to parse pyproject.toml: {}
# flake8-bandit ('S')
# "S101", # Use of `assert` detected
2023-12-26 03:15:37 +00:00
"S102", # Use of `exec` detected
"S103", # `os.chmod` setting a permissive mask `{mask:#o}` on file or directory
"S104", # Possible binding to all interfaces
# "S105", # Possible hardcoded password assigned to: "{}"
2023-12-26 03:15:37 +00:00
"S106", # Possible hardcoded password assigned to argument: "{}"
"S107", # Possible hardcoded password assigned to function default: "{}"
"S108", # Probable insecure usage of temporary file or directory: "{}"
# "S110", # `try`-`except`-`pass` detected, consider logging the exception
2023-12-26 03:15:37 +00:00
"S112", # `try`-`except`-`continue` detected, consider logging the exception
# "S113", # Probable use of requests call without timeout
# "S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
2023-12-26 03:15:37 +00:00
"S302", # Deserialization with the `marshal` module is possibly dangerous
"S303", # Use of insecure MD2, MD4, MD5, or SHA1 hash function
"S304", # Use of insecure cipher, replace with a known secure cipher such as AES
"S305", # Use of insecure cipher mode, replace with a known secure cipher such as AES
"S306", # Use of insecure and deprecated function (`mktemp`)
# "S307", # Use of possibly insecure function; consider using `ast.literal_eval`
2023-12-26 03:15:37 +00:00
"S308", # Use of `mark_safe` may expose cross-site scripting vulnerabilities
"S310", # Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"S312", # Telnet-related functions are being called. Telnet is considered insecure. Use SSH or some other encrypted protocol.
"S313", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S314", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S315", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S316", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S317", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S318", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S319", # Using `xml` to parse untrusted data is known to be vulnerable to XML attacks; use `defusedxml` equivalents
"S320", # Using `lxml` to parse untrusted data is known to be vulnerable to XML attacks
"S321", # FTP-related functions are being called. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
"S323", # Python allows using an insecure context via the `_create_unverified_context` that reverts to the previous behavior that does not validate certificates or perform hostname checks.
# "S324", # Probable use of insecure hash functions in `hashlib`: `{string}`
2023-12-26 03:15:37 +00:00
"S501", # Probable use of `{string}` call with `verify=False` disabling SSL certificate checks
"S506", # Probable use of unsafe loader `{name}` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`.
"S508", # The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able.
"S509", # You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure.
"S601", # Possible shell injection via Paramiko call; check inputs are properly sanitized
"S602", # `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell`
# "S603", # `subprocess` call: check for execution of untrusted input
2023-12-26 03:15:37 +00:00
"S604", # Function call with `shell=True` parameter identified, security issue
"S605", # Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
"S606", # Starting a process without a shell
# "S607", # Starting a process with a partial executable path
2023-12-26 03:15:37 +00:00
"S608", # Possible SQL injection vector through string-based query construction
"S609", # Possible wildcard injection in call due to `*` usage
"S612", # Use of insecure `logging.config.listen` detected
# "S701", # Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
2023-12-26 03:15:37 +00:00
# flake8-simplify ('SIM')
"SIM101", # Multiple `isinstance` calls for `{name}`, merge into a single call
# "SIM102", # Use a single `if` statement instead of nested `if` statements
# "SIM103", # Return the condition `{condition}` directly
2023-12-26 03:15:37 +00:00
"SIM105", # Use `contextlib.suppress({exception})` instead of `try`-`except`-`pass`
"SIM107", # Don't use `return` in `try`-`except` and `finally`
# "SIM108", # Use ternary operator `{contents}` instead of `if`-`else`-block
2023-12-26 03:15:37 +00:00
"SIM109", # Use `{replacement}` instead of multiple equality comparisons
"SIM110", # Use `{replacement}` instead of `for` loop
"SIM112", # Use capitalized environment variable `{expected}` instead of `{original}`
"SIM114", # Combine `if` branches using logical `or` operator
"SIM115", # Use context handler for opening files
"SIM116", # Use a dictionary instead of consecutive `if` statements
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
"SIM118", # Use `{key} {operator} {dict}` instead of `{key} {operator} {dict}.keys()`
"SIM201", # Use `{left} != {right}` instead of `not {left} == {right}`
"SIM202", # Use `{left} == {right}` instead of `not {left} != {right}`
"SIM208", # Use `{expr}` instead of `not (not {expr})`
"SIM210", # Use `bool({expr})` instead of `True if {expr} else False`
"SIM211", # Use `not {expr}` instead of `False if {expr} else True`
"SIM212", # Use `{expr_else} if {expr_else} else {expr_body}` instead of `{expr_body} if not {expr_else} else {expr_else}`
"SIM220", # Use `False` instead of `{name} and not {name}`
"SIM221", # Use `True` instead of `{name} or not {name}`
"SIM222", # Use `{expr}` instead of `{replaced}`
"SIM223", # Use `{expr}` instead of `{replaced}`
"SIM300", # Yoda conditions are discouraged, use `{suggestion}` instead
"SIM401", # Use `{contents}` instead of an `if` block
"SIM910", # Use `{expected}` instead of `{original}`
# flake8-self ('SLF')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# flake8-slots ('SLOT')
"SLOT000", # Subclasses of `str` should define `__slots__`
"SLOT001", # Subclasses of `tuple` should define `__slots__`
"SLOT002", # Subclasses of `collections.namedtuple()` should define `__slots__`
# flake8-debugger ('T10')
2023-12-26 03:15:37 +00:00
"T100", # Trace found: `{name}` used
# flake8-print ('T20')
2023-12-26 03:15:37 +00:00
"T201", # `print` found
"T203", # `pprint` found
# flake8-type-checking ('TCH')
"TCH001", # Move application import `{}` into a type-checking block
"TCH002", # Move third-party import `{}` into a type-checking block
"TCH003", # Move standard library import `{}` into a type-checking block
"TCH004", # Move import `{qualified_name}` out of type-checking block. Import is used for more than type hinting.
"TCH005", # Found empty type-checking block
# flake8-todos ('TD')
# "TD001", # Invalid TODO tag: `{tag}`
# "TD003", # Missing issue link on the line following this TODO
# "TD004", # Missing colon in TODO
# "TD005", # Missing issue description after `TODO`
2023-12-26 03:15:37 +00:00
"TD006", # Invalid TODO capitalization: `{tag}` should be `TODO`
"TD007", # Missing space after colon in TODO
# flake8-tidy-imports ('TID')
"TID251", # `{name}` is banned: {message}
"TID252", # Relative imports from parent modules are banned
# tryceratops ('TRY')
# NOT YET USED
2023-12-26 03:15:37 +00:00
# pyupgrade ('UP')
"UP001", # `__metaclass__ = type` is implied
"UP003", # Use `{}` instead of `type(...)`
"UP004", # Class `{name}` inherits from `object`
"UP005", # `{alias}` is deprecated, use `{target}`
"UP006", # Use `{to}` instead of `{from}` for type annotation
"UP007", # Use `X | Y` for type annotations
"UP008", # Use `super()` instead of `super(__class__, self)`
"UP009", # UTF-8 encoding declaration is unnecessary
"UP010", # Unnecessary `__future__` import `{import}` for target Python version
"UP011", # Unnecessary parentheses to `functools.lru_cache`
"UP012", # Unnecessary call to `encode` as UTF-8
"UP013", # Convert `{name}` from `TypedDict` functional to class syntax
"UP014", # Convert `{name}` from `NamedTuple` functional to class syntax
"UP015", # Unnecessary open mode parameters
"UP017", # Use `datetime.UTC` alias
"UP018", # Unnecessary `{literal_type}` call (rewrite as a literal)
"UP019", # `typing.Text` is deprecated, use `str`
"UP020", # Use builtin `open`
"UP021", # `universal_newlines` is deprecated, use `text`
"UP022", # Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output`
"UP023", # `cElementTree` is deprecated, use `ElementTree`
"UP024", # Replace aliased errors with `OSError`
"UP025", # Remove unicode literals from strings
"UP026", # `mock` is deprecated, use `unittest.mock`
"UP027", # Replace unpacked list comprehension with a generator expression
"UP028", # Replace `yield` over `for` loop with `yield from`
"UP029", # Unnecessary builtin import: `{import}`
"UP030", # Use implicit references for positional format fields
# "UP031", # Use format specifiers instead of percent format
# "UP032", # Use f-string instead of `format` call
2023-12-26 03:15:37 +00:00
"UP033", # Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`
"UP034", # Avoid extraneous parentheses
"UP035", # Import from `{target}` instead: {names}
"UP036", # Version block is outdated for minimum Python version
"UP037", # Remove quotes from type annotation
"UP038", # Use `X | Y` in `{}` call instead of `(X, Y)`
"UP039", # Unnecessary parentheses after class definition
"UP040", # Type alias `{name}` uses `TypeAlias` annotation instead of the `type` keyword
# pycodestyle ('W')
"W191", # Indentation contains tabs
# "W291", # Trailing whitespace
2023-12-26 03:15:37 +00:00
"W292", # No newline at end of file
"W293", # Blank line contains whitespace
"W505", # Doc line too long ({width} > {limit} characters)
"W605", # Invalid escape sequence: `\{char}`
# flake8-2020 ('YTT')
"YTT",
]
2023-12-26 03:10:23 +00:00
[per-file-ignores]
"doc/conf.py" = ["INP001"]
"doc/development/tutorials/examples/*" = ["INP001"]
# allow print() in the tutorial
"doc/development/tutorials/examples/recipe.py" = ["T201"]
# from .flake8
"sphinx/*" = ["E241"]
# 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.py" = ["T201"]
# 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"]
"tests/*" = [
"E501",
2023-12-26 03:48:22 +00:00
"T201", # whitelist ``print`` for tests
]
# these tests need old ``typing`` generic aliases
"tests/test_util_typing.py" = ["UP006", "UP035"]
"tests/typing_test_data.py" = ["UP006", "UP035"]
# whitelist ``print`` for stdout messages
"utils/*" = ["T201"]
2023-12-26 03:10:23 +00:00
[flake8-quotes]
inline-quotes = "single"