mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-24 14:17:49 -05:00
Use Ruff rule names in place of codes (#14761)
This commit is contained in:
1 parent
f03a2433a9
commit
943bf0d191
128 files changed
+427
-416
No files matched your search
+146
-148
@@ -17,134 +17,132 @@ quote-style = "single"
|
||||
preview = true
|
||||
ignore = [
|
||||
# flake8-builtins
|
||||
"A001", # Variable `{name}` is shadowing a Python builtin
|
||||
"A002", # Function argument `{name}` is shadowing a Python builtin
|
||||
"A005", # Module `{name}` is shadowing a Python builtin module
|
||||
"builtin-variable-shadowing", # Variable `{name}` is shadowing a Python builtin
|
||||
"builtin-argument-shadowing", # Function argument `{name}` is shadowing a Python builtin
|
||||
"stdlib-module-shadowing", # Module `{name}` is shadowing a Python builtin module
|
||||
# flake8-annotations
|
||||
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `{name}`
|
||||
"any-type", # 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}`
|
||||
"unused-function-argument", # Unused function argument: `{name}`
|
||||
"unused-method-argument", # Unused method argument: `{name}`
|
||||
"unused-class-method-argument", # Unused class method argument: `{name}`
|
||||
"unused-lambda-argument", # Unused lambda argument: `{name}`
|
||||
# flake8-blind-except
|
||||
"BLE001", # Do not catch blind exception: `{name}`
|
||||
"blind-except", # Do not catch blind exception: `{name}`
|
||||
# flake8-commas
|
||||
"COM812", # Trailing comma missing
|
||||
"missing-trailing-comma", # Trailing comma missing
|
||||
# flake8-copyright
|
||||
"CPY001", # Missing copyright notice at top of file
|
||||
"missing-copyright-notice", # Missing copyright notice at top of file
|
||||
# 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
|
||||
"D107", # Missing docstring in `__init__`
|
||||
"D200", # One-line docstring should fit on one line
|
||||
"D205", # 1 blank line required between summary line and description
|
||||
"D400", # First line should end with a period
|
||||
"D401", # First line of docstring should be in imperative mood: "{first_line}"
|
||||
"undocumented-public-module", # Missing docstring in public module
|
||||
"undocumented-public-class", # Missing docstring in public class
|
||||
"undocumented-public-method", # Missing docstring in public method
|
||||
"undocumented-public-function", # Missing docstring in public function
|
||||
"undocumented-public-package", # Missing docstring in public package
|
||||
"undocumented-magic-method", # Missing docstring in magic method
|
||||
"undocumented-public-init", # Missing docstring in `__init__`
|
||||
"unnecessary-multiline-docstring", # One-line docstring should fit on one line
|
||||
"missing-blank-line-after-summary", # 1 blank line required between summary line and description
|
||||
"missing-trailing-period", # First line should end with a period
|
||||
"non-imperative-mood", # First line of docstring should be in imperative mood: "{first_line}"
|
||||
# pydoclint
|
||||
"DOC201", # `return` is not documented in docstring
|
||||
"DOC402", # `yield` is not documented in docstring
|
||||
"DOC501", # Raised exception `{id}` missing from docstring
|
||||
"docstring-missing-returns", # `return` is not documented in docstring
|
||||
"docstring-missing-yields", # `yield` is not documented in docstring
|
||||
"docstring-missing-exception", # Raised exception `{id}` missing from docstring
|
||||
# pycodestyle
|
||||
"E741", # Ambiguous variable name: `{name}`
|
||||
"ambiguous-variable-name", # Ambiguous variable name: `{name}`
|
||||
# eradicate
|
||||
"ERA001", # Found commented-out code
|
||||
"commented-out-code", # Found commented-out code
|
||||
# pyflakes
|
||||
"F841", # Local variable `{name}` is assigned to but never used
|
||||
"unused-variable", # Local variable `{name}` is assigned to but never used
|
||||
# flake8-boolean-trap
|
||||
"FBT001", # Boolean-typed positional argument in function definition
|
||||
"FBT002", # Boolean default positional argument in function definition
|
||||
"FBT003", # Boolean positional value in function call
|
||||
"boolean-type-hint-positional-argument", # Boolean-typed positional argument in function definition
|
||||
"boolean-default-value-positional-argument", # Boolean default positional argument in function definition
|
||||
"boolean-positional-value-in-call", # Boolean positional value in function call
|
||||
# flake8-fixme
|
||||
"FIX001", # Line contains FIXME, consider resolving the issue
|
||||
"FIX002", # Line contains TODO, consider resolving the issue
|
||||
"FIX003", # Line contains XXX, consider resolving the issue
|
||||
"FIX004", # Line contains HACK, consider resolving the issue
|
||||
"line-contains-fixme", # Line contains FIXME, consider resolving the issue
|
||||
"line-contains-todo", # Line contains TODO, consider resolving the issue
|
||||
"line-contains-xxx", # Line contains XXX, consider resolving the issue
|
||||
"line-contains-hack", # Line contains HACK, consider resolving the issue
|
||||
# refurb
|
||||
"FURB101", # `open` and `read` should be replaced by `Path(...).read_text(...)`
|
||||
"FURB103", # `open` and `write` should be replaced by `Path(...).write_text(...)`
|
||||
"read-whole-file", # `open` and `read` should be replaced by `Path(...).read_text(...)`
|
||||
"write-whole-file", # `open` and `write` should be replaced by `Path(...).write_text(...)`
|
||||
# flake8-implicit-str-concat
|
||||
# pep8-naming
|
||||
"N801", # Class name `{name}` should use CapWords convention
|
||||
"N802", # Function name `{name}` should be lowercase
|
||||
"N803", # Argument name `{name}` should be lowercase
|
||||
"N806", # Variable `{name}` in function should be lowercase
|
||||
"N818", # Exception name `{name}` should be named with an Error suffix
|
||||
"invalid-class-name", # Class name `{name}` should use CapWords convention
|
||||
"invalid-function-name", # Function name `{name}` should be lowercase
|
||||
"invalid-argument-name", # Argument name `{name}` should be lowercase
|
||||
"non-lowercase-variable-in-function", # Variable `{name}` in function should be lowercase
|
||||
"error-suffix-on-exception-name", # Exception name `{name}` should be named with an Error suffix
|
||||
# perflint
|
||||
"PERF203", # `try`-`except` within a loop incurs performance overhead
|
||||
"try-except-in-loop", # `try`-`except` within a loop incurs performance overhead
|
||||
# flake8-pie
|
||||
"PIE790", # Unnecessary `pass` statement
|
||||
"unnecessary-placeholder", # Unnecessary `pass` statement
|
||||
# pylint
|
||||
"PLC0415", # `import` should be at the top-level of a file
|
||||
"PLC2701", # Private name import `{name}` from external module `{module}`
|
||||
"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
|
||||
"PLW0717", # Try clause contains too many statements ({} > 5)
|
||||
"PLW2901", # Outer {outer_kind} variable `{name}` overwritten by inner {inner_kind} target
|
||||
"import-outside-top-level", # `import` should be at the top-level of a file
|
||||
"import-private-name", # Private name import `{name}` from external module `{module}`
|
||||
"too-many-public-methods", # Too many public methods ({methods} > {max_methods})
|
||||
"too-many-return-statements", # Too many return statements ({returns} > {max_returns})
|
||||
"too-many-branches", # Too many branches ({branches} > {max_branches})
|
||||
"too-many-arguments", # Too many arguments in function definition ({c_args} > {max_args})
|
||||
"too-many-locals", # Too many local variables ({current_amount}/{max_amount})
|
||||
"too-many-statements", # Too many statements ({statements} > {max_statements})
|
||||
"too-many-boolean-expressions", # Too many Boolean expressions ({expressions} > {max_expressions})
|
||||
"too-many-positional-arguments", # Too many positional arguments ({c_pos}/{max_pos})
|
||||
"too-many-nested-blocks", # Too many nested blocks ({nested_blocks} > {max_nested_blocks})
|
||||
"magic-value-comparison", # Magic value used in comparison, consider replacing `{value}` with a constant variable
|
||||
"collapsible-else-if", # Use `elif` instead of `else` then `if`, to reduce indentation
|
||||
"non-augmented-assignment", # Use `{operator}` to perform an augmented assignment directly
|
||||
"no-self-use", # Method `{method_name}` could be a function, class method, or static method
|
||||
"too-many-statements-in-try-clause", # Try clause contains too many statements ({} > 5)
|
||||
"redefined-loop-name", # Outer {outer_kind} variable `{name}` overwritten by inner {inner_kind} target
|
||||
# flake8-use-pathlib
|
||||
"PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
|
||||
"PTH110", # `os.path.exists()` should be replaced by `Path.exists()`
|
||||
"PTH113", # `os.path.isfile()` should be replaced by `Path.is_file()`
|
||||
"PTH118", # `os.{module}.join()` should be replaced by `Path` with `/` operator
|
||||
"PTH119", # `os.path.basename()` should be replaced by `Path.name`
|
||||
"PTH120", # `os.path.dirname()` should be replaced by `Path.parent`
|
||||
"PTH122", # `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent`
|
||||
"PTH123", # `open()` should be replaced by `Path.open()`
|
||||
"os-path-abspath", # `os.path.abspath()` should be replaced by `Path.resolve()`
|
||||
"os-path-exists", # `os.path.exists()` should be replaced by `Path.exists()`
|
||||
"os-path-isfile", # `os.path.isfile()` should be replaced by `Path.is_file()`
|
||||
"os-path-join", # `os.{module}.join()` should be replaced by `Path` with `/` operator
|
||||
"os-path-basename", # `os.path.basename()` should be replaced by `Path.name`
|
||||
"os-path-dirname", # `os.path.dirname()` should be replaced by `Path.parent`
|
||||
"os-path-splitext", # `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent`
|
||||
"builtin-open", # `open()` should be replaced by `Path.open()`
|
||||
# flake8-pyi ('PYI')
|
||||
"PYI025", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin
|
||||
"unaliased-collections-abc-set-import", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin
|
||||
# flake8-return
|
||||
"RET504", # Unnecessary assignment to `{name}` before `return` statement
|
||||
"RET505", # Unnecessary `{branch}` after `return` statement
|
||||
"RET506", # Unnecessary `{branch}` after `raise` statement
|
||||
"unnecessary-assign", # Unnecessary assignment to `{name}` before `return` statement
|
||||
"superfluous-else-return", # Unnecessary `{branch}` after `return` statement
|
||||
"superfluous-else-raise", # Unnecessary `{branch}` after `raise` statement
|
||||
# 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
|
||||
"assert", # Use of `assert` detected
|
||||
"try-except-pass", # `try`-`except`-`pass` detected, consider logging the exception
|
||||
"suspicious-subprocess-import", # `subprocess` module is possibly insecure
|
||||
"suspicious-xml-etree-import", # `xml.etree` methods are vulnerable to XML attacks
|
||||
"subprocess-without-shell-equals-true", # `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
|
||||
"collapsible-if", # Use a single `if` statement instead of nested `if` statements
|
||||
"if-else-block-instead-of-if-exp", # Use ternary operator `{contents}` instead of `if`-`else`-block
|
||||
# flake8-self
|
||||
"SLF001", # Private member accessed: `{access}`
|
||||
"private-member-access", # Private member accessed: `{access}`
|
||||
# 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
|
||||
"invalid-todo-tag", # Invalid TODO tag: `{tag}`
|
||||
"missing-todo-author", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
|
||||
"missing-todo-link", # Missing issue link on the line following this TODO
|
||||
"missing-todo-colon", # Missing colon in TODO
|
||||
# tryceratops
|
||||
"TRY002", # Create your own exception
|
||||
"TRY300", # Consider moving this statement to an `else` block
|
||||
"raise-vanilla-class", # Create your own exception
|
||||
"try-consider-else", # Consider moving this statement to an `else` block
|
||||
# pyupgrade
|
||||
"UP031", # Use format specifiers instead of percent format
|
||||
"UP032", # Use f-string instead of `format` call
|
||||
"printf-string-formatting", # Use format specifiers instead of percent format
|
||||
"f-string", # Use f-string instead of `format` call
|
||||
# Ruff-specific rules ('RUF')
|
||||
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
|
||||
"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
|
||||
"RUF027", # Possible f-string without an `f` prefix
|
||||
"RUF039", # First argument to {call} is not raw string
|
||||
"RUF052", # Local dummy variable `{}` is accessed
|
||||
"RUF067", # `__init__` module should only contain docstrings and re-exports
|
||||
"RUF069", # Unreliable floating point equality comparison `{}`
|
||||
"RUF105", # `noqa` comment used instead of `{}`
|
||||
"RUF201", # Rule code used instead of name in `{}`
|
||||
"mutable-class-default", # Mutable class attributes should be annotated with `typing.ClassVar`
|
||||
"parenthesize-chained-operators", # Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
|
||||
"unsorted-dunder-all", # `__all__` is not sorted
|
||||
"unsorted-dunder-slots", # `{}.__slots__` is not sorted
|
||||
"missing-f-string-syntax", # Possible f-string without an `f` prefix
|
||||
"unraw-re-pattern", # First argument to {call} is not raw string
|
||||
"used-dummy-variable", # Local dummy variable `{}` is accessed
|
||||
"non-empty-init-module", # `__init__` module should only contain docstrings and re-exports
|
||||
"float-equality-comparison", # Unreliable floating point equality comparison `{}`
|
||||
]
|
||||
external = [ # Whitelist for RUF100 unknown code warnings
|
||||
"SIM113",
|
||||
@@ -174,10 +172,10 @@ select = [
|
||||
"CPY",
|
||||
# pydocstyle ('D')
|
||||
"D",
|
||||
"D212", # Multi-line docstring summary should start at the first line
|
||||
"multi-line-summary-first-line", # Multi-line docstring summary should start at the first line
|
||||
# "D404", # First word of the docstring should not be "This"
|
||||
# "D415", # First line should end with a period, question mark, or exclamation point
|
||||
"D417", # Missing argument description in the docstring for `{definition}`: `{name}`
|
||||
"undocumented-param", # Missing argument description in the docstring for `{definition}`: `{name}`
|
||||
# pydoclint ('DOC')
|
||||
"DOC",
|
||||
# flake8-django ('DJ')
|
||||
@@ -287,104 +285,104 @@ logger-objects = [
|
||||
[lint.per-file-ignores]
|
||||
"doc/*" = [
|
||||
"ANN", # documentation doesn't need annotations
|
||||
"TC001", # documentation doesn't need type-checking blocks
|
||||
"typing-only-first-party-import", # documentation doesn't need type-checking blocks
|
||||
]
|
||||
"doc/conf.py" = [
|
||||
"INP001", # doc/ is not a namespace package
|
||||
"implicit-namespace-package", # doc/ is not a namespace package
|
||||
]
|
||||
"doc/development/tutorials/examples/*" = [
|
||||
"I002", # we don't need the annotations future
|
||||
"INP001", # examples/ is not a namespace package
|
||||
"missing-required-import", # we don't need the annotations future
|
||||
"implicit-namespace-package", # examples/ is not a namespace package
|
||||
]
|
||||
"doc/development/tutorials/examples/recipe.py" = [
|
||||
"FURB118", # keep the tutorial simple: no itemgetter
|
||||
"T201" # allow print() in the tutorial
|
||||
"reimplemented-operator", # keep the tutorial simple: no itemgetter
|
||||
"print" # allow print() in the tutorial
|
||||
]
|
||||
"doc/usage/extensions/example_{google,numpy}.py" = [
|
||||
"D416", # Section name should end with a colon ("{name}")
|
||||
"DOC502", # Raised exception is not explicitly raised: `{id}`
|
||||
"I002", # Missing required import: {name}
|
||||
"INP001", # File {filename} is part of an implicit namespace package. Add an __init__.py.
|
||||
"PLW3201", # Dunder method {name} has no special meaning in Python 3
|
||||
"missing-section-name-colon", # Section name should end with a colon ("{name}")
|
||||
"docstring-extraneous-exception", # Raised exception is not explicitly raised: `{id}`
|
||||
"missing-required-import", # Missing required import: {name}
|
||||
"implicit-namespace-package", # File {filename} is part of an implicit namespace package. Add an __init__.py.
|
||||
"bad-dunder-method-name", # Dunder method {name} has no special meaning in Python 3
|
||||
]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/_cli/__init__.py" = ["T201"]
|
||||
"sphinx/_cli/__init__.py" = ["print"]
|
||||
|
||||
# allow use of ``pickle``
|
||||
"sphinx/{application,builders/__init__,environment/__init__,ext/coverage,search/__init__,versioning}.py" = [
|
||||
"S301",
|
||||
"S403",
|
||||
"suspicious-pickle-usage",
|
||||
"suspicious-pickle-import",
|
||||
]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/cmd/build.py" = ["T201"]
|
||||
"sphinx/cmd/make_mode.py" = ["T201"]
|
||||
"sphinx/cmd/build.py" = ["print"]
|
||||
"sphinx/cmd/make_mode.py" = ["print"]
|
||||
"sphinx/cmd/quickstart.py" = [
|
||||
"PTH",
|
||||
"T201",
|
||||
"print",
|
||||
]
|
||||
|
||||
"sphinx/environment/collectors/toctree.py" = ["B026"]
|
||||
"sphinx/environment/adapters/toctree.py" = ["B026"]
|
||||
"sphinx/environment/collectors/toctree.py" = ["star-arg-unpacking-after-keyword-arg"]
|
||||
"sphinx/environment/adapters/toctree.py" = ["star-arg-unpacking-after-keyword-arg"]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/ext/intersphinx/_cli.py" = ["T201"]
|
||||
"sphinx/ext/intersphinx/_cli.py" = ["print"]
|
||||
|
||||
# whitelist ``token`` in docstring parsing
|
||||
"sphinx/ext/napoleon/docstring.py" = ["S105"]
|
||||
"sphinx/ext/napoleon/docstring.py" = ["hardcoded-password-string"]
|
||||
|
||||
"sphinx/search/*" = ["RUF001"]
|
||||
"sphinx/search/*" = ["ambiguous-unicode-character-string"]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/testing/fixtures.py" = ["T201"]
|
||||
"sphinx/testing/fixtures.py" = ["print"]
|
||||
|
||||
# whitelist ``os.path`` for deprecated ``sphinx.testing.path``
|
||||
"sphinx/testing/path.py" = ["PTH"]
|
||||
|
||||
# whitelist ``token`` in date format parsing
|
||||
"sphinx/util/i18n.py" = ["S105"]
|
||||
"sphinx/util/i18n.py" = ["hardcoded-password-string"]
|
||||
|
||||
# whitelist ``os.path`` for ``sphinx.util.osutil``
|
||||
"sphinx/util/osutil.py" = ["PTH"]
|
||||
|
||||
# whitelist ``token`` in literal parsing
|
||||
"sphinx/writers/html5.py" = ["S105"]
|
||||
"sphinx/writers/html5.py" = ["hardcoded-password-string"]
|
||||
|
||||
"tests/*" = [
|
||||
"E501",
|
||||
"line-too-long",
|
||||
"ANN", # tests don't need annotations
|
||||
"D402",
|
||||
"PLC1901", # whitelist comparisons to the empty string ('')
|
||||
"RUF001", # ambiguous unicode character
|
||||
"S301", # allow use of ``pickle``
|
||||
"S403", # allow use of ``pickle``
|
||||
"T201", # whitelist ``print`` for tests
|
||||
"signature-in-docstring",
|
||||
"compare-to-empty-string", # whitelist comparisons to the empty string ('')
|
||||
"ambiguous-unicode-character-string", # ambiguous unicode character
|
||||
"suspicious-pickle-usage", # allow use of ``pickle``
|
||||
"suspicious-pickle-import", # allow use of ``pickle``
|
||||
"print", # whitelist ``print`` for tests
|
||||
]
|
||||
|
||||
# test roots are not packages
|
||||
"tests/js/roots/*" = ["I002", "INP001"]
|
||||
"tests/js/roots/*" = ["missing-required-import", "implicit-namespace-package"]
|
||||
"tests/roots/*" = [
|
||||
"D403", # permit uncapitalised docstrings
|
||||
"F401", # names may be unused in test roots
|
||||
"I002", # we don't need the annotations future
|
||||
"INP001", # test roots are not packages
|
||||
"first-word-uncapitalized", # permit uncapitalised docstrings
|
||||
"unused-import", # names may be unused in test roots
|
||||
"missing-required-import", # we don't need the annotations future
|
||||
"implicit-namespace-package", # test roots are not packages
|
||||
]
|
||||
|
||||
# these tests need old ``typing`` generic aliases
|
||||
"tests/roots/test-ext-autodoc/target/genericalias.py" = ["UP006", "UP007", "UP035", "UP045"]
|
||||
"tests/test_util/test_util_typing.py" = ["RUF036", "UP006", "UP007", "UP035", "UP045"]
|
||||
"tests/test_util/typing_test_data.py" = ["FA100", "I002", "PYI030", "UP006", "UP007", "UP035", "UP045"]
|
||||
"tests/roots/test-ext-autodoc/target/genericalias.py" = ["non-pep585-annotation", "non-pep604-annotation-union", "deprecated-import", "non-pep604-annotation-optional"]
|
||||
"tests/test_util/test_util_typing.py" = ["none-not-at-end-of-union", "non-pep585-annotation", "non-pep604-annotation-union", "deprecated-import", "non-pep604-annotation-optional"]
|
||||
"tests/test_util/typing_test_data.py" = ["future-rewritable-type-annotation", "missing-required-import", "unnecessary-literal-union", "non-pep585-annotation", "non-pep604-annotation-union", "deprecated-import", "non-pep604-annotation-optional"]
|
||||
|
||||
# these tests need old-style type comments
|
||||
"tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py" = ["PYI033"]
|
||||
"tests/roots/test-ext-autodoc/target/cached_property.py" = ["PYI033"]
|
||||
"tests/roots/test-ext-autodoc/target/properties.py" = ["PYI033"]
|
||||
"tests/roots/test-ext-autodoc/target/typed_vars.py" = ["PYI033"]
|
||||
"tests/roots/test-ext-autodoc/target/typehints.py" = ["PYI033"]
|
||||
"tests/roots/test-ext-autodoc/target/autodoc_type_aliases.py" = ["legacy-type-comment"]
|
||||
"tests/roots/test-ext-autodoc/target/cached_property.py" = ["legacy-type-comment"]
|
||||
"tests/roots/test-ext-autodoc/target/properties.py" = ["legacy-type-comment"]
|
||||
"tests/roots/test-ext-autodoc/target/typed_vars.py" = ["legacy-type-comment"]
|
||||
"tests/roots/test-ext-autodoc/target/typehints.py" = ["legacy-type-comment"]
|
||||
|
||||
"utils/*" = [
|
||||
"T201", # whitelist ``print`` for stdout messages
|
||||
"print", # whitelist ``print`` for stdout messages
|
||||
"ANN", # utilities don't need annotations
|
||||
]
|
||||
|
||||
|
||||
+2
-2
@@ -272,7 +272,7 @@ nitpick_ignore = {
|
||||
|
||||
# -- Extension interface -------------------------------------------------------
|
||||
|
||||
from sphinx import addnodes # NoQA: E402
|
||||
from sphinx import addnodes # ruff: ignore[module-import-not-at-top-of-file]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
@@ -328,7 +328,7 @@ REDIRECT_TEMPLATE = """
|
||||
<a href="{{rel_url}}">If not, click here to continue.</a>
|
||||
</body>
|
||||
</html>
|
||||
""" # NoQA: E501
|
||||
""" # ruff: ignore[line-too-long]
|
||||
|
||||
|
||||
def build_redirects(app: Sphinx, exception: Exception | None) -> None:
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ if _in_development:
|
||||
|
||||
try:
|
||||
if ret := subprocess.run(
|
||||
('git', 'rev-parse', '--short', 'HEAD'), # NoQA: S607
|
||||
('git', 'rev-parse', '--short', 'HEAD'), # ruff: ignore[start-process-with-partial-path]
|
||||
capture_output=True,
|
||||
check=False,
|
||||
cwd=package_dir,
|
||||
|
||||
@@ -43,12 +43,12 @@ def terminal_supports_colour() -> bool:
|
||||
|
||||
|
||||
def disable_colour() -> None:
|
||||
global _COLOURING_DISABLED # NoQA: PLW0603
|
||||
global _COLOURING_DISABLED # ruff: ignore[global-statement]
|
||||
_COLOURING_DISABLED = True
|
||||
|
||||
|
||||
def enable_colour() -> None:
|
||||
global _COLOURING_DISABLED # NoQA: PLW0603
|
||||
global _COLOURING_DISABLED # ruff: ignore[global-statement]
|
||||
_COLOURING_DISABLED = False
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.nodes import document # NoQA: F401
|
||||
from docutils.nodes import document # ruff: ignore[unused-import]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
|
||||
@@ -38,8 +38,8 @@ from sphinx.util.parallel import (
|
||||
)
|
||||
|
||||
# side effect: registers roles and directives
|
||||
from sphinx import directives # NoQA: F401 isort:skip
|
||||
from sphinx import roles # NoQA: F401 isort:skip
|
||||
from sphinx import directives # ruff: ignore[unused-import] isort:skip
|
||||
from sphinx import roles # ruff: ignore[unused-import] isort:skip
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterable, Sequence, Set
|
||||
@@ -258,7 +258,7 @@ class Builder:
|
||||
def cat2relpath(cat: CatalogInfo, srcdir: Path = self.srcdir) -> str:
|
||||
return Path(relpath(cat.mo_path, srcdir)).as_posix()
|
||||
|
||||
logger.info(bold(__('building [mo]: ')) + message) # NoQA: G003
|
||||
logger.info(bold(__('building [mo]: ')) + message) # ruff: ignore[logging-string-concat]
|
||||
for catalog in status_iterator(
|
||||
catalogs,
|
||||
__('writing output... '),
|
||||
@@ -398,7 +398,7 @@ class Builder:
|
||||
:meth:`!write`.
|
||||
"""
|
||||
if summary:
|
||||
logger.info(bold(__('building [%s]: ')) + summary, self.name) # NoQA: G003
|
||||
logger.info(bold(__('building [%s]: ')) + summary, self.name) # ruff: ignore[logging-string-concat]
|
||||
|
||||
# while reading, collect all warnings from docutils
|
||||
with (
|
||||
|
||||
@@ -352,7 +352,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
msg = __(
|
||||
'build_info mismatch, copying .buildinfo to .buildinfo.bak'
|
||||
)
|
||||
logger.info(bold(__('building [html]: ')) + msg) # NoQA: G003
|
||||
logger.info(bold(__('building [html]: ')) + msg) # ruff: ignore[logging-string-concat]
|
||||
|
||||
yield from self.env.found_docs
|
||||
return
|
||||
@@ -367,7 +367,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
# Let users know they have a newer template
|
||||
if template_mtime > old_mtime:
|
||||
logger.info(
|
||||
bold('building [html]: ') # NoQA: G003
|
||||
bold('building [html]: ') # ruff: ignore[logging-string-concat]
|
||||
+ __(
|
||||
'template %s has been changed since the previous build, '
|
||||
'all docs will be rebuilt'
|
||||
@@ -1024,7 +1024,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
) -> str:
|
||||
if 'includehidden' not in kwargs:
|
||||
kwargs['includehidden'] = False
|
||||
if kwargs.get('maxdepth') == '': # NoQA: PLC1901
|
||||
if kwargs.get('maxdepth') == '': # ruff: ignore[compare-to-empty-string]
|
||||
kwargs.pop('maxdepth')
|
||||
toctree = global_toctree_for_doc(
|
||||
self.env, docname, self, tags=self.tags, collapse=collapse, **kwargs
|
||||
|
||||
@@ -7,7 +7,7 @@ import os.path
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import sphinx.builders.latex.nodes # NoQA: F401 # Workaround: import this before writer to avoid ImportError
|
||||
import sphinx.builders.latex.nodes # ruff: ignore[unused-import] # Workaround: import this before writer to avoid ImportError
|
||||
from sphinx import addnodes, highlighting, package_dir
|
||||
from sphinx._cli.util.colour import darkgreen
|
||||
from sphinx.builders import Builder
|
||||
|
||||
@@ -16,7 +16,7 @@ from urllib.parse import quote, unquote, urlparse, urlsplit, urlunparse
|
||||
|
||||
from docutils import nodes
|
||||
from requests.exceptions import (
|
||||
ConnectionError, # NoQA: A004
|
||||
ConnectionError, # ruff: ignore[builtin-import-shadowing]
|
||||
HTTPError,
|
||||
SSLError,
|
||||
TooManyRedirects,
|
||||
@@ -135,9 +135,9 @@ class CheckExternalLinksBuilder(DummyBuilder):
|
||||
msg = f'{res_uri}: {result.message}'
|
||||
else:
|
||||
msg = res_uri
|
||||
logger.info(darkgray('-ignored- ') + msg) # NoQA: G003
|
||||
logger.info(darkgray('-ignored- ') + msg) # ruff: ignore[logging-string-concat]
|
||||
case _Status.WORKING:
|
||||
logger.info(darkgreen('ok ') + f'{res_uri}{result.message}') # NoQA: G003
|
||||
logger.info(darkgreen('ok ') + f'{res_uri}{result.message}') # ruff: ignore[logging-string-concat]
|
||||
case _Status.TIMEOUT:
|
||||
if self.config.verbosity < 0:
|
||||
msg = 'timeout ' + f'{res_uri}{result.message}'
|
||||
@@ -449,7 +449,7 @@ class HyperlinkAvailabilityCheckWorker(Thread):
|
||||
status, info, code = self._check(docname, uri, hyperlink)
|
||||
if status == _Status.RATE_LIMITED:
|
||||
logger.info(
|
||||
darkgray('-rate limited- ') + uri + darkgray(' | sleeping...') # NoQA: G003
|
||||
darkgray('-rate limited- ') + uri + darkgray(' | sleeping...') # ruff: ignore[logging-string-concat]
|
||||
)
|
||||
else:
|
||||
self.rqueue.put(CheckResult(uri, docname, lineno, status, info, code))
|
||||
@@ -517,7 +517,7 @@ class HyperlinkAvailabilityCheckWorker(Thread):
|
||||
req_url = encode_uri(req_url)
|
||||
|
||||
# Get auth info, if any
|
||||
for pattern, auth_info in self.auth: # NoQA: B007 (false positive)
|
||||
for pattern, auth_info in self.auth: # ruff: ignore[unused-loop-control-variable] (false positive)
|
||||
if pattern.match(uri):
|
||||
break
|
||||
else:
|
||||
|
||||
@@ -81,7 +81,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
||||
kwargs['includehidden'] = False
|
||||
elif includehidden.lower() == 'true':
|
||||
kwargs['includehidden'] = True
|
||||
if kwargs.get('maxdepth') == '': # NoQA: PLC1901
|
||||
if kwargs.get('maxdepth') == '': # ruff: ignore[compare-to-empty-string]
|
||||
kwargs.pop('maxdepth')
|
||||
toctree = global_toctree_for_doc(
|
||||
self.env, docname, self, tags=self.tags, collapse=collapse, **kwargs
|
||||
|
||||
+1
-1
@@ -352,7 +352,7 @@ def _parse_logging(
|
||||
warn_file = Path(warnfile).resolve()
|
||||
ensuredir(warn_file.parent)
|
||||
# the caller is responsible for closing this file descriptor
|
||||
warnfp = open(warn_file, 'w', encoding='utf-8') # NoQA: SIM115
|
||||
warnfp = open(warn_file, 'w', encoding='utf-8') # ruff: ignore[open-file-with-context-handler]
|
||||
except Exception as exc:
|
||||
parser.error(__("cannot open warning file '%s': %s") % (warn_file, exc))
|
||||
warning = TeeStripANSI(warning, warnfp) # type: ignore[assignment]
|
||||
|
||||
@@ -37,7 +37,7 @@ try:
|
||||
# MyPy doesn't realise that this raises a ModuleNotFoundError
|
||||
# on Windows, and complains that 'parse_and_bind' is not defined.
|
||||
# This condition is always False at runtime, but tricks type checkers.
|
||||
raise ImportError # NoQA: TRY301
|
||||
raise ImportError # ruff: ignore[raise-within-try]
|
||||
except ImportError:
|
||||
READLINE_AVAILABLE = USE_LIBEDIT = False
|
||||
else:
|
||||
@@ -285,8 +285,8 @@ def ask_user(d: dict[str, Any]) -> None:
|
||||
print()
|
||||
print(
|
||||
__(
|
||||
'Inside the root directory, two more directories will be created; "_templates"\n' # NoQA: E501
|
||||
'for custom HTML templates and "_static" for custom stylesheets and other static\n' # NoQA: E501
|
||||
'Inside the root directory, two more directories will be created; "_templates"\n' # ruff: ignore[line-too-long]
|
||||
'for custom HTML templates and "_static" for custom stylesheets and other static\n' # ruff: ignore[line-too-long]
|
||||
'files. You can enter another prefix (such as ".") to replace the underscore.'
|
||||
)
|
||||
)
|
||||
|
||||
+3
-3
@@ -85,7 +85,7 @@ class ENUM:
|
||||
def __repr__(self) -> str:
|
||||
return f'ENUM({", ".join(sorted(map(repr, self._candidates)))})'
|
||||
|
||||
def match(self, value: str | bool | None | Sequence[str | bool | None]) -> bool: # NoQA: RUF036
|
||||
def match(self, value: str | bool | None | Sequence[str | bool | None]) -> bool: # ruff: ignore[none-not-at-end-of-union]
|
||||
if isinstance(value, (str, bool, types.NoneType)):
|
||||
return value in self._candidates
|
||||
return all(item in self._candidates for item in value)
|
||||
@@ -373,7 +373,7 @@ class Config:
|
||||
msg = __("'%s' must be '0' or '1', got '%s'") % (name, value)
|
||||
raise ConfigError(msg)
|
||||
if isinstance(default, dict):
|
||||
raise ValueError( # NoQA: TRY004
|
||||
raise ValueError( # ruff: ignore[type-check-without-type-error]
|
||||
__(
|
||||
'cannot override dictionary config setting %r, '
|
||||
'ignoring (use %r to set individual elements)'
|
||||
@@ -593,7 +593,7 @@ def eval_config_file(filename: Path, tags: Tags) -> dict[str, Any]:
|
||||
# during executing config file, current dir is changed to ``confdir``.
|
||||
try:
|
||||
code = compile(filename.read_bytes(), filename, 'exec')
|
||||
exec(code, namespace) # NoQA: S102
|
||||
exec(code, namespace) # ruff: ignore[exec-builtin]
|
||||
except SyntaxError as err:
|
||||
msg = __('There is a syntax error in your configuration file: %s\n')
|
||||
raise ConfigError(msg % err) from err
|
||||
|
||||
@@ -85,7 +85,7 @@ def container_wrapper(
|
||||
node = parsed[0]
|
||||
if isinstance(node, nodes.system_message):
|
||||
msg = __('Invalid caption: %s') % node.astext()
|
||||
raise ValueError(msg) # NoQA: TRY004
|
||||
raise ValueError(msg) # ruff: ignore[type-check-without-type-error]
|
||||
if isinstance(node, nodes.Element):
|
||||
caption_node = nodes.caption(node.rawsource, '', *node.children)
|
||||
caption_node.source = literal_node.source
|
||||
|
||||
@@ -178,7 +178,7 @@ class MathDirective(SphinxDirective):
|
||||
node = cast('nodes.math_block', ret[0])
|
||||
|
||||
# assign label automatically if math_number_all enabled
|
||||
if node['label'] == '' or (self.config.math_number_all and not node['label']): # NoQA: PLC1901
|
||||
if node['label'] == '' or (self.config.math_number_all and not node['label']): # ruff: ignore[compare-to-empty-string]
|
||||
seq = self.env.new_serialno('sphinx.ext.math#equations')
|
||||
node['label'] = f'{self.env.current_document.docname}:{seq}'
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# re-export objects for backwards compatibility
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/12295
|
||||
from sphinx.domains.c._ast import ( # NoQA: F401
|
||||
from sphinx.domains.c._ast import ( # ruff: ignore[unused-import]
|
||||
ASTAlignofExpr,
|
||||
ASTArray,
|
||||
ASTAssignmentExpr,
|
||||
|
||||
@@ -865,7 +865,7 @@ class DefinitionParser(BaseParser):
|
||||
self, outer: str | None = None, allow_fallback: bool = True
|
||||
) -> ASTInitializer | None:
|
||||
self.skip_ws()
|
||||
if outer == 'member' and False: # NoQA: SIM223,TD005 # TODO
|
||||
if outer == 'member' and False: # ruff: ignore[expr-and-false, missing-todo-description] # TODO
|
||||
braced_init = self._parse_braced_init_list()
|
||||
if braced_init is not None:
|
||||
return ASTInitializer(braced_init, hasAssign=False)
|
||||
|
||||
@@ -52,7 +52,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# re-export objects for backwards compatibility
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/12295
|
||||
from sphinx.domains.cpp._ast import ( # NoQA: F401
|
||||
from sphinx.domains.cpp._ast import ( # ruff: ignore[unused-import]
|
||||
ASTAlignofExpr,
|
||||
ASTArray,
|
||||
ASTAssignmentExpr,
|
||||
@@ -1064,7 +1064,7 @@ class CPPDomain(Domain):
|
||||
objtypes = self.objtypes_for_role(typ)
|
||||
if objtypes:
|
||||
return decl_typ in objtypes
|
||||
logger.debug(f'Type is {typ}, declaration type is {decl_typ}') # NoQA: G004
|
||||
logger.debug(f'Type is {typ}, declaration type is {decl_typ}') # ruff: ignore[logging-f-string]
|
||||
raise AssertionError
|
||||
|
||||
def _resolve_xref_inner(
|
||||
|
||||
@@ -40,11 +40,11 @@ if TYPE_CHECKING:
|
||||
# re-export objects for backwards compatibility
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/12295
|
||||
|
||||
from sphinx.domains.python._annotations import ( # NoQA: F401
|
||||
from sphinx.domains.python._annotations import ( # ruff: ignore[unused-import]
|
||||
_parse_arglist, # for sphinx-immaterial
|
||||
type_to_xref,
|
||||
)
|
||||
from sphinx.domains.python._object import ( # NoQA: F401
|
||||
from sphinx.domains.python._object import ( # ruff: ignore[unused-import]
|
||||
PyField,
|
||||
PyGroupedField,
|
||||
PyTypedField,
|
||||
|
||||
@@ -607,7 +607,7 @@ def _pseudo_parse_arglist(
|
||||
stack.pop()
|
||||
ends_close -= 1
|
||||
if len(stack) != 1:
|
||||
raise IndexError # NoQA: TRY301
|
||||
raise IndexError # ruff: ignore[raise-within-try]
|
||||
except IndexError:
|
||||
# if there are too few or too many elements on the stack, just give up
|
||||
# and treat the whole argument list as one argument, discarding the
|
||||
|
||||
@@ -634,7 +634,7 @@ class ProductionList(SphinxDirective):
|
||||
def production_group(
|
||||
*,
|
||||
lines: MutableSequence[str],
|
||||
options: dict[str, Any], # NoQA: ARG004
|
||||
options: dict[str, Any], # ruff: ignore[unused-static-method-argument]
|
||||
) -> str:
|
||||
# get production_group
|
||||
if not lines or ':' in lines[0]:
|
||||
|
||||
@@ -1178,7 +1178,7 @@ class _CurrentDocument:
|
||||
return self._extension_data.setdefault(key, default)
|
||||
|
||||
def clear(self) -> None:
|
||||
_CurrentDocument.__init__(self) # NoQA: PLC2801
|
||||
_CurrentDocument.__init__(self) # ruff: ignore[unnecessary-dunder-call]
|
||||
|
||||
def update(self, other: Iterable[tuple[str, Any]] = (), /, **kwargs: Any) -> None:
|
||||
other_dict = dict(other) if not isinstance(other, dict) else other
|
||||
|
||||
@@ -112,7 +112,7 @@ class ImageCollector(EnvironmentCollector):
|
||||
node: Node,
|
||||
) -> None:
|
||||
globbed: dict[str, list[str]] = {}
|
||||
for filename in glob(imgpath): # NoQA: PTH207
|
||||
for filename in glob(imgpath): # ruff: ignore[glob]
|
||||
new_imgpath = _relative_path(Path(filename), srcdir)
|
||||
try:
|
||||
mimetype = guess_mimetype(filename)
|
||||
|
||||
@@ -208,7 +208,7 @@ def is_skipped_package(
|
||||
if not Path(dirname).is_dir():
|
||||
return False
|
||||
|
||||
files = glob.glob(str(Path(dirname, '*.py'))) # NoQA: PTH207
|
||||
files = glob.glob(str(Path(dirname, '*.py'))) # ruff: ignore[glob]
|
||||
regular_package = any(f for f in files if is_initpy(f))
|
||||
if not regular_package and not opts.implicit_namespaces:
|
||||
# *dirname* is not both a regular package and an implicit namespace package
|
||||
|
||||
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.ext.autodoc._property_types import _AutodocObjType
|
||||
|
||||
|
||||
class DummyOptionSpec(dict[str, 'Callable[[str], str]']): # NoQA: FURB189
|
||||
class DummyOptionSpec(dict[str, 'Callable[[str], str]']): # ruff: ignore[subclass-builtin]
|
||||
"""An option_spec allows any options."""
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
@@ -81,7 +81,7 @@ class AutodocDirective(SphinxDirective):
|
||||
)
|
||||
except (KeyError, ValueError, TypeError) as exc:
|
||||
# an option is either unknown or has a wrong type
|
||||
LOGGER.error( # NoQA: TRY400
|
||||
LOGGER.error( # ruff: ignore[error-instead-of-exception]
|
||||
'An option to %s is either unknown or has an invalid value: %s',
|
||||
self.name,
|
||||
exc,
|
||||
|
||||
@@ -217,14 +217,14 @@ def _import_module(modname: str, try_reload: bool = False) -> Any:
|
||||
spec = find_spec(modname)
|
||||
if spec is None:
|
||||
msg = f'No module named {modname!r}'
|
||||
raise ModuleNotFoundError(msg, name=modname) # NoQA: TRY301
|
||||
raise ModuleNotFoundError(msg, name=modname) # ruff: ignore[raise-within-try]
|
||||
spec, pyi_path = _find_type_stub_spec(spec, modname)
|
||||
if skip_pyi or pyi_path is None:
|
||||
module = importlib.import_module(modname)
|
||||
else:
|
||||
if spec.loader is None:
|
||||
msg = 'missing loader'
|
||||
raise ImportError(msg, name=spec.name) # NoQA: TRY301
|
||||
raise ImportError(msg, name=spec.name) # ruff: ignore[raise-within-try]
|
||||
sys.modules[modname] = module = module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
except ImportError:
|
||||
|
||||
@@ -832,7 +832,7 @@ def _should_keep_member(
|
||||
|
||||
if is_private:
|
||||
if has_attr_doc or has_doc:
|
||||
if private_members is None: # NoQA: SIM114
|
||||
if private_members is None: # ruff: ignore[if-with-same-arms]
|
||||
return False
|
||||
elif has_doc and is_filtered_inherited_member:
|
||||
return False
|
||||
|
||||
@@ -30,7 +30,7 @@ class _MockObject:
|
||||
# Attributes listed here should not be mocked and rather raise an Attribute error:
|
||||
__sphinx_empty_attrs__: Set[str] = frozenset(('__typing_subst__',))
|
||||
|
||||
def __new__(cls, *args: Any, **kwargs: Any) -> Any: # NoQA: ARG004
|
||||
def __new__(cls, *args: Any, **kwargs: Any) -> Any: # ruff: ignore[unused-static-method-argument]
|
||||
if len(args) == 3 and isinstance(args[1], tuple):
|
||||
superclass = args[1][-1].__class__
|
||||
if superclass is cls:
|
||||
|
||||
@@ -349,7 +349,7 @@ def _extract_signatures_from_docstrings(
|
||||
stripped_docstrings = [list(l) for l in (docstrings or ())]
|
||||
for i, doclines in enumerate(docstrings):
|
||||
j = 0
|
||||
for j, line in enumerate(doclines): # NoQA: B007
|
||||
for j, line in enumerate(doclines): # ruff: ignore[unused-loop-control-variable]
|
||||
if not line:
|
||||
# no lines in docstring, no match
|
||||
break
|
||||
@@ -583,7 +583,7 @@ def _get_object_for_signature(
|
||||
return obj, False
|
||||
|
||||
if props.obj_type == 'method':
|
||||
if obj == object.__init__ and parent != object: # NoQA: E721
|
||||
if obj == object.__init__ and parent != object: # ruff: ignore[type-comparison]
|
||||
# Classes not having own __init__() method are shown as no arguments.
|
||||
#
|
||||
# Note: The signature of object.__init__() is (self, /, *args, **kwargs).
|
||||
@@ -619,7 +619,7 @@ def _annotate_to_first_argument(
|
||||
if len(sig.parameters) == first_arg_idx:
|
||||
return None
|
||||
|
||||
def dummy(): # type: ignore[no-untyped-def] # NoQA: ANN202
|
||||
def dummy(): # type: ignore[no-untyped-def] # ruff: ignore[missing-return-type-private-function]
|
||||
pass
|
||||
|
||||
params = list(sig.parameters.values())
|
||||
|
||||
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
|
||||
/,
|
||||
) -> None: ...
|
||||
|
||||
class _AutodocBeforeProcessSignatureListener(Protocol): # NoQA: PYI046
|
||||
class _AutodocBeforeProcessSignatureListener(Protocol): # ruff: ignore[unused-private-protocol]
|
||||
# parameter names are non-normative
|
||||
def __call__(
|
||||
self,
|
||||
@@ -35,7 +35,7 @@ if TYPE_CHECKING:
|
||||
/,
|
||||
) -> None: ...
|
||||
|
||||
class _AutodocProcessSignatureListener(Protocol): # NoQA: PYI046
|
||||
class _AutodocProcessSignatureListener(Protocol): # ruff: ignore[unused-private-protocol]
|
||||
# parameter names are non-normative
|
||||
# returns: (args, retann) | None
|
||||
def __call__(
|
||||
@@ -50,7 +50,7 @@ if TYPE_CHECKING:
|
||||
/,
|
||||
) -> tuple[str | None, str | None] | None: ...
|
||||
|
||||
class _AutodocProcessBasesListener(Protocol): # NoQA: PYI046
|
||||
class _AutodocProcessBasesListener(Protocol): # ruff: ignore[unused-private-protocol]
|
||||
# parameter names are non-normative
|
||||
def __call__(
|
||||
self,
|
||||
@@ -62,7 +62,7 @@ if TYPE_CHECKING:
|
||||
/,
|
||||
) -> None: ...
|
||||
|
||||
class _AutodocSkipMemberListener(Protocol): # NoQA: PYI046
|
||||
class _AutodocSkipMemberListener(Protocol): # ruff: ignore[unused-private-protocol]
|
||||
# parameter names are non-normative
|
||||
# returns: skip_member
|
||||
def __call__(
|
||||
|
||||
@@ -87,7 +87,7 @@ def merge_members_option(options: dict[str, Any]) -> None:
|
||||
members.append(member)
|
||||
|
||||
|
||||
class Options(dict[str, Any]): # NoQA: FURB189
|
||||
class Options(dict[str, Any]): # ruff: ignore[subclass-builtin]
|
||||
"""A dict/attribute hybrid that returns None on nonexisting keys."""
|
||||
|
||||
def copy(self) -> Options:
|
||||
|
||||
@@ -617,7 +617,7 @@ class Documenter:
|
||||
self.options.special_members
|
||||
and membername in self.options.special_members
|
||||
):
|
||||
if membername == '__doc__': # NoQA: SIM114
|
||||
if membername == '__doc__': # ruff: ignore[if-with-same-arms]
|
||||
keep = False
|
||||
elif is_filtered_inherited_member(membername, obj):
|
||||
keep = False
|
||||
@@ -636,7 +636,7 @@ class Documenter:
|
||||
keep = True
|
||||
elif want_all and isprivate:
|
||||
if has_doc or self.options.undoc_members:
|
||||
if self.options.private_members is None: # NoQA: SIM114
|
||||
if self.options.private_members is None: # ruff: ignore[if-with-same-arms]
|
||||
keep = False
|
||||
elif is_filtered_inherited_member(membername, obj):
|
||||
keep = False
|
||||
@@ -1378,7 +1378,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
|
||||
if len(sig.parameters) == 0:
|
||||
return None
|
||||
|
||||
def dummy(): # type: ignore[no-untyped-def] # NoQA: ANN202
|
||||
def dummy(): # type: ignore[no-untyped-def] # ruff: ignore[missing-return-type-private-function]
|
||||
pass
|
||||
|
||||
params = list(sig.parameters.values())
|
||||
@@ -2202,7 +2202,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
||||
kwargs.setdefault('short_literals', True)
|
||||
|
||||
try:
|
||||
if self.object == object.__init__ and self.parent != object: # NoQA: E721
|
||||
if self.object == object.__init__ and self.parent != object: # ruff: ignore[type-comparison]
|
||||
# Classes not having own __init__() method are shown as no arguments.
|
||||
#
|
||||
# Note: The signature of object.__init__() is (self, /, *args, **kwargs).
|
||||
@@ -2361,7 +2361,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
||||
if len(sig.parameters) == 1:
|
||||
return None
|
||||
|
||||
def dummy(): # type: ignore[no-untyped-def] # NoQA: ANN202
|
||||
def dummy(): # type: ignore[no-untyped-def] # ruff: ignore[missing-return-type-private-function]
|
||||
pass
|
||||
|
||||
params = list(sig.parameters.values())
|
||||
|
||||
@@ -27,12 +27,12 @@ class _Sentinel:
|
||||
def __or__(self, other: object) -> _SpecialForm:
|
||||
from typing import Union
|
||||
|
||||
return Union[self, other] # NoQA: UP007 # ty: ignore[invalid-type-form, invalid-return-type]
|
||||
return Union[self, other] # ruff: ignore[non-pep604-annotation-union] # ty: ignore[invalid-type-form, invalid-return-type]
|
||||
|
||||
def __ror__(self, other: object) -> _SpecialForm:
|
||||
from typing import Union
|
||||
|
||||
return Union[other, self] # NoQA: UP007 # ty: ignore[invalid-type-form, invalid-return-type]
|
||||
return Union[other, self] # ruff: ignore[non-pep604-annotation-union] # ty: ignore[invalid-type-form, invalid-return-type]
|
||||
|
||||
def __getstate__(self) -> NoReturn:
|
||||
msg = f'Cannot pickle {self._name}'
|
||||
|
||||
@@ -14,7 +14,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.config import Config
|
||||
from sphinx.util.typing import _RestifyMode
|
||||
|
||||
class _AttrGetter(Protocol): # NoQA: PYI046
|
||||
class _AttrGetter(Protocol): # ruff: ignore[unused-private-protocol]
|
||||
def __call__(self, obj: Any, name: str, default: Any = ..., /) -> Any: ...
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ AUTODOC_EXTENDABLE_OPTIONS = frozenset({
|
||||
|
||||
|
||||
# Retained: legacy class-based
|
||||
class DummyOptionSpec(dict[str, Callable[[str], str]]): # NoQA: FURB189
|
||||
class DummyOptionSpec(dict[str, Callable[[str], str]]): # ruff: ignore[subclass-builtin]
|
||||
"""An option_spec allows any options."""
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
@@ -150,7 +150,7 @@ class AutodocDirective(SphinxDirective):
|
||||
)
|
||||
except (KeyError, ValueError, TypeError) as exc:
|
||||
# an option is either unknown or has a wrong type
|
||||
LOGGER.error( # NoQA: TRY400
|
||||
LOGGER.error( # ruff: ignore[error-instead-of-exception]
|
||||
'An option to %s is either unknown or has an invalid value: %s',
|
||||
self.name,
|
||||
exc,
|
||||
|
||||
@@ -8,9 +8,9 @@ from typing import TYPE_CHECKING, NamedTuple
|
||||
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.ext.autodoc._dynamic._importer import (
|
||||
_find_type_stub_spec, # NoQA: F401
|
||||
_reload_module, # NoQA: F401
|
||||
_StubFileLoader, # NoQA: F401
|
||||
_find_type_stub_spec, # ruff: ignore[unused-import]
|
||||
_reload_module, # ruff: ignore[unused-import]
|
||||
_StubFileLoader, # ruff: ignore[unused-import]
|
||||
)
|
||||
from sphinx.ext.autodoc._dynamic._importer import (
|
||||
_import_module as import_module,
|
||||
@@ -18,7 +18,7 @@ from sphinx.ext.autodoc._dynamic._importer import (
|
||||
from sphinx.ext.autodoc._dynamic._importer import _mangle_name as mangle
|
||||
from sphinx.ext.autodoc._dynamic._member_finder import (
|
||||
_filter_enum_dict,
|
||||
_is_native_enum_api, # NoQA: F401
|
||||
_is_native_enum_api, # ruff: ignore[unused-import]
|
||||
unmangle,
|
||||
)
|
||||
from sphinx.ext.autodoc._dynamic._mock import ismock, undecorate
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sphinx.ext.autodoc._dynamic._mock import (
|
||||
MockFinder, # NoQA: F401
|
||||
MockLoader, # NoQA: F401
|
||||
_make_subclass, # NoQA: F401
|
||||
_MockModule, # NoQA: F401
|
||||
_MockObject, # NoQA: F401
|
||||
ismock, # NoQA: F401
|
||||
ismockmodule, # NoQA: F401
|
||||
mock, # NoQA: F401
|
||||
undecorate, # NoQA: F401
|
||||
MockFinder, # ruff: ignore[unused-import]
|
||||
MockLoader, # ruff: ignore[unused-import]
|
||||
_make_subclass, # ruff: ignore[unused-import]
|
||||
_MockModule, # ruff: ignore[unused-import]
|
||||
_MockObject, # ruff: ignore[unused-import]
|
||||
ismock, # ruff: ignore[unused-import]
|
||||
ismockmodule, # ruff: ignore[unused-import]
|
||||
mock, # ruff: ignore[unused-import]
|
||||
undecorate, # ruff: ignore[unused-import]
|
||||
)
|
||||
@@ -9,11 +9,11 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sphinx.ext.autodoc._dynamic._preserve_defaults import (
|
||||
DefaultValue, # NoQA: F401
|
||||
_get_arguments, # NoQA: F401
|
||||
_get_arguments_inner, # NoQA: F401
|
||||
_is_lambda, # NoQA: F401
|
||||
get_default_value, # NoQA: F401
|
||||
DefaultValue, # ruff: ignore[unused-import]
|
||||
_get_arguments, # ruff: ignore[unused-import]
|
||||
_get_arguments_inner, # ruff: ignore[unused-import]
|
||||
_is_lambda, # ruff: ignore[unused-import]
|
||||
get_default_value, # ruff: ignore[unused-import]
|
||||
update_default_value,
|
||||
)
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from sphinx.ext.autodoc._dynamic._type_comments import (
|
||||
_update_annotations_using_type_comments,
|
||||
not_suppressed, # NoQA: F401
|
||||
signature_from_ast, # NoQA: F401
|
||||
not_suppressed, # ruff: ignore[unused-import]
|
||||
signature_from_ast, # ruff: ignore[unused-import]
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -726,7 +726,7 @@ def _import_by_name(name: str, grouped_exception: bool = True) -> tuple[Any, Any
|
||||
except (ValueError, ImportError, AttributeError, KeyError) as exc:
|
||||
errors.append(exc)
|
||||
if grouped_exception:
|
||||
raise ImportExceptionGroup('', errors) from None # NoQA: EM101
|
||||
raise ImportExceptionGroup('', errors) from None # ruff: ignore[raw-string-in-exception]
|
||||
else:
|
||||
raise ImportError(*exc.args) from exc
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ class ModuleScanner:
|
||||
try:
|
||||
if ('', name) in attr_docs:
|
||||
imported = False
|
||||
elif inspect.ismodule(value): # NoQA: SIM114
|
||||
elif inspect.ismodule(value): # ruff: ignore[if-with-same-arms]
|
||||
imported = True
|
||||
elif safe_getattr(value, '__module__') != self.object.__name__:
|
||||
imported = True
|
||||
@@ -767,7 +767,7 @@ def find_autosummary_in_docstring(
|
||||
pass
|
||||
except ImportExceptionGroup as exc:
|
||||
errors = '\n'.join({f'* {type(e).__name__}: {e}' for e in exc.exceptions})
|
||||
logger.warning(f'Failed to import {name}.\nPossible hints:\n{errors}') # NoQA: G004
|
||||
logger.warning(f'Failed to import {name}.\nPossible hints:\n{errors}') # ruff: ignore[logging-f-string]
|
||||
except SystemExit:
|
||||
logger.warning(
|
||||
"Failed to import '%s'; the module executes module level "
|
||||
|
||||
@@ -177,7 +177,7 @@ class CoverageBuilder(Builder):
|
||||
self.c_sourcefiles: list[str] = []
|
||||
for pattern in self.config.coverage_c_path:
|
||||
pattern = self.srcdir / pattern
|
||||
self.c_sourcefiles.extend(glob.glob(str(pattern))) # NoQA: PTH207
|
||||
self.c_sourcefiles.extend(glob.glob(str(pattern))) # ruff: ignore[glob]
|
||||
|
||||
self.c_regexes: list[tuple[str, re.Pattern[str]]] = []
|
||||
for name, exp in self.config.coverage_c_regexes.items():
|
||||
@@ -264,7 +264,7 @@ class CoverageBuilder(Builder):
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
red('undocumented ') # NoQA: G003
|
||||
red('undocumented ') # ruff: ignore[logging-string-concat]
|
||||
+ f'c api {f"{name} [{typ:>9}]":<30}'
|
||||
+ red(' - in file ')
|
||||
+ filename
|
||||
@@ -456,7 +456,7 @@ class CoverageBuilder(Builder):
|
||||
else:
|
||||
for func in undoc['funcs']:
|
||||
logger.info(
|
||||
red('undocumented ') # NoQA: G003
|
||||
red('undocumented ') # ruff: ignore[logging-string-concat]
|
||||
+ f'py function {func:<30}'
|
||||
+ red(' - in module ')
|
||||
+ name
|
||||
@@ -476,7 +476,7 @@ class CoverageBuilder(Builder):
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
red('undocumented ') # NoQA: G003
|
||||
red('undocumented ') # ruff: ignore[logging-string-concat]
|
||||
+ f'py class {class_name:<30}'
|
||||
+ red(' - in module ')
|
||||
+ name
|
||||
@@ -499,7 +499,7 @@ class CoverageBuilder(Builder):
|
||||
else:
|
||||
for meth in methods:
|
||||
logger.info(
|
||||
red('undocumented ') # NoQA: G003
|
||||
red('undocumented ') # ruff: ignore[logging-string-concat]
|
||||
+ f'py method {f"{class_name}.{meth}":<30}'
|
||||
+ red(' - in module ')
|
||||
+ name
|
||||
|
||||
@@ -420,10 +420,10 @@ class DocTestBuilder(Builder):
|
||||
condition = node['skipif']
|
||||
context: dict[str, Any] = {}
|
||||
if self.config.doctest_global_setup:
|
||||
exec(self.config.doctest_global_setup, context) # NoQA: S102
|
||||
should_skip = eval(condition, context) # NoQA: S307
|
||||
exec(self.config.doctest_global_setup, context) # ruff: ignore[exec-builtin]
|
||||
should_skip = eval(condition, context) # ruff: ignore[suspicious-eval-usage]
|
||||
if self.config.doctest_global_cleanup:
|
||||
exec(self.config.doctest_global_cleanup, context) # NoQA: S102
|
||||
exec(self.config.doctest_global_cleanup, context) # ruff: ignore[exec-builtin]
|
||||
return should_skip
|
||||
|
||||
def test_doc(self, docname: str, doctree: Node) -> bool:
|
||||
|
||||
@@ -239,7 +239,7 @@ def fix_svg_relative_paths(
|
||||
) -> None:
|
||||
"""Change relative links in generated svg files to be relative to imgpath."""
|
||||
env = self.builder.env
|
||||
tree = ET.parse(filepath) # NoQA: S314
|
||||
tree = ET.parse(filepath) # ruff: ignore[suspicious-xml-element-tree-usage]
|
||||
root = tree.getroot()
|
||||
ns = {'svg': 'http://www.w3.org/2000/svg', 'xlink': 'http://www.w3.org/1999/xlink'}
|
||||
href_name = '{http://www.w3.org/1999/xlink}href'
|
||||
|
||||
@@ -58,7 +58,7 @@ def process_ifconfig_nodes(app: Sphinx, doctree: nodes.document, docname: str) -
|
||||
ns['builder'] = app.builder.name
|
||||
for node in list(doctree.findall(ifconfig)):
|
||||
try:
|
||||
res = eval(node['expr'], ns) # NoQA: S307
|
||||
res = eval(node['expr'], ns) # ruff: ignore[suspicious-eval-usage]
|
||||
except Exception as err:
|
||||
# handle exceptions in a clean fashion
|
||||
from traceback import format_exception_only
|
||||
|
||||
@@ -69,7 +69,7 @@ depthsvgcomment_re = re.compile(r'<!-- DEPTH=(-?\d+) -->')
|
||||
def read_svg_depth(filename: str | os.PathLike[str]) -> int | None:
|
||||
"""Read the depth from comment at last line of SVG file"""
|
||||
with open(filename, encoding='utf-8') as f:
|
||||
for line in f: # NoQA: B007
|
||||
for line in f: # ruff: ignore[unused-loop-control-variable]
|
||||
pass
|
||||
# Only last line is checked
|
||||
matched = depthsvgcomment_re.match(line)
|
||||
|
||||
@@ -83,7 +83,7 @@ def validate_intersphinx_mapping(app: Sphinx, config: Config) -> None:
|
||||
'Invalid value `%r` in intersphinx_mapping[%r]. '
|
||||
'Values must be a (target URI, inventory locations) pair.'
|
||||
)
|
||||
LOGGER.error(msg, value, name) # NoQA: TRY400
|
||||
LOGGER.error(msg, value, name) # ruff: ignore[error-instead-of-exception]
|
||||
del config.intersphinx_mapping[name]
|
||||
continue
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ def _slice_index(
|
||||
count = 0
|
||||
start = offset
|
||||
if slices == slice_number + 1: # last column
|
||||
offset = len(seq) # NoQA: SIM113
|
||||
offset = len(seq)
|
||||
else:
|
||||
for value in values[offset:]:
|
||||
count += 1 + len(value[1][1])
|
||||
|
||||
@@ -210,7 +210,7 @@ class AfterCommentParser(TokenProcessor):
|
||||
tokens += self.fetch_until([OP, ']'])
|
||||
elif current == INDENT:
|
||||
tokens += self.fetch_until(DEDENT)
|
||||
elif current == [OP, ';']: # NoQA: SIM114
|
||||
elif current == [OP, ';']: # ruff: ignore[if-with-same-arms]
|
||||
break
|
||||
elif current and current.kind not in {OP, NAME, NUMBER, STRING}:
|
||||
break
|
||||
|
||||
@@ -118,7 +118,9 @@ var Stemmer = function () {
|
||||
|
||||
|
||||
# SearchEnglish imported after SearchLanguage is defined due to circular import
|
||||
from sphinx.search.en import SearchEnglish # NoQA: E402
|
||||
from sphinx.search.en import ( # ruff: ignore[module-import-not-at-top-of-file]
|
||||
SearchEnglish,
|
||||
)
|
||||
|
||||
|
||||
def parse_stop_word(source: str) -> set[str]:
|
||||
|
||||
@@ -121,7 +121,7 @@ def app_params(
|
||||
return _app_params(args, kwargs)
|
||||
|
||||
|
||||
_app_params = namedtuple('_app_params', 'args,kwargs') # NoQA: PYI024
|
||||
_app_params = namedtuple('_app_params', 'args,kwargs') # ruff: ignore[collections-named-tuple]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
+5
-5
@@ -511,22 +511,22 @@ def _migrate_conf_to_toml(argv: list[str]) -> int:
|
||||
raise SystemExit(0)
|
||||
argv = argv[1:]
|
||||
if len(argv) != 1:
|
||||
print('Usage: python -m sphinx.theming conf_to_toml <theme path>') # NoQA: T201
|
||||
print('Usage: python -m sphinx.theming conf_to_toml <theme path>') # ruff: ignore[print]
|
||||
raise SystemExit(1)
|
||||
theme_dir = Path(argv[0]).resolve()
|
||||
conf_path = theme_dir / _THEME_CONF
|
||||
if not theme_dir.is_dir() or not conf_path.is_file():
|
||||
print( # NoQA: T201
|
||||
print( # ruff: ignore[print]
|
||||
f'{theme_dir!r} must be a path to a theme directory containing a "theme.conf" file'
|
||||
)
|
||||
return 1
|
||||
_cfg_parser = _load_theme_conf(conf_path)
|
||||
if not _cfg_parser.has_section('theme'):
|
||||
print('The "theme" table is missing.') # NoQA: T201
|
||||
print('The "theme" table is missing.') # ruff: ignore[print]
|
||||
return 1
|
||||
inherit = _cfg_parser.get('theme', 'inherit', fallback=None)
|
||||
if not inherit:
|
||||
print('The "theme.inherit" setting is missing.') # NoQA: T201
|
||||
print('The "theme.inherit" setting is missing.') # ruff: ignore[print]
|
||||
return 1
|
||||
|
||||
toml_lines = [
|
||||
@@ -571,7 +571,7 @@ def _migrate_conf_to_toml(argv: list[str]) -> int:
|
||||
|
||||
toml_path = theme_dir / _THEME_TOML
|
||||
toml_path.write_text('\n'.join(toml_lines) + '\n', encoding='utf-8')
|
||||
print(f'Written converted settings to {toml_path!r}') # NoQA: T201
|
||||
print(f'Written converted settings to {toml_path!r}') # ruff: ignore[print]
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
|
||||
class FilenameUniqDict(dict[str, tuple[set[str], str]]): # NoQA: FURB189
|
||||
class FilenameUniqDict(dict[str, tuple[set[str], str]]): # ruff: ignore[subclass-builtin]
|
||||
"""A dictionary that automatically generates unique names for its keys,
|
||||
interpreted as filenames, and keeps track of a set of docnames they
|
||||
appear in. Used for images and downloadable files in the environment.
|
||||
@@ -61,7 +61,7 @@ class FilenameUniqDict(dict[str, tuple[set[str], str]]): # NoQA: FURB189
|
||||
self._existing = state
|
||||
|
||||
|
||||
class DownloadFiles(dict[Path, tuple[set[str], _StrPath]]): # NoQA: FURB189
|
||||
class DownloadFiles(dict[Path, tuple[set[str], _StrPath]]): # ruff: ignore[subclass-builtin]
|
||||
"""A special dictionary for download files.
|
||||
|
||||
.. important:: This class would be refactored in nearly future.
|
||||
|
||||
@@ -11,17 +11,17 @@ def parse_line_num_spec(spec: str, total: int) -> list[int]:
|
||||
try:
|
||||
begend = part.strip().split('-')
|
||||
if begend == ['', '']:
|
||||
raise ValueError # NoQA: TRY301
|
||||
raise ValueError # ruff: ignore[raise-within-try]
|
||||
if len(begend) == 1:
|
||||
items.append(int(begend[0]) - 1)
|
||||
elif len(begend) == 2:
|
||||
start = int(begend[0] or 1) # left half open (cf. -10)
|
||||
end = int(begend[1] or max(start, total)) # right half open (cf. 10-)
|
||||
if start > end: # invalid range (cf. 10-1)
|
||||
raise ValueError # NoQA: TRY301
|
||||
raise ValueError # ruff: ignore[raise-within-try]
|
||||
items.extend(range(start - 1, end))
|
||||
else:
|
||||
raise ValueError # NoQA: TRY301
|
||||
raise ValueError # ruff: ignore[raise-within-try]
|
||||
except ValueError as exc:
|
||||
msg = f'invalid line number spec: {spec!r}'
|
||||
raise ValueError(msg) from exc
|
||||
|
||||
@@ -44,7 +44,7 @@ if sys.platform == 'win32':
|
||||
# replace exists in both Path and str;
|
||||
# in Path it makes filesystem changes, so we use the safer str version
|
||||
warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
|
||||
return self.__str__().replace(old, new, count) # NoQA: PLC2801
|
||||
return self.__str__().replace(old, new, count) # ruff: ignore[unnecessary-dunder-call]
|
||||
|
||||
def __getattr__(self, item: str) -> Any:
|
||||
if item in _STR_METHODS:
|
||||
@@ -99,7 +99,7 @@ else:
|
||||
# replace exists in both Path and str;
|
||||
# in Path it makes filesystem changes, so we use the safer str version
|
||||
warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
|
||||
return self.__str__().replace(old, new, count) # NoQA: PLC2801
|
||||
return self.__str__().replace(old, new, count) # ruff: ignore[unnecessary-dunder-call]
|
||||
|
||||
def __getattr__(self, item: str) -> Any:
|
||||
if item in _STR_METHODS:
|
||||
|
||||
@@ -339,7 +339,7 @@ class BaseParser:
|
||||
def status(self, msg: str) -> None:
|
||||
# for debugging
|
||||
indicator = '-' * self.pos + '^'
|
||||
logger.debug(f'{msg}\n{self.definition}\n{indicator}') # NoQA: G004
|
||||
logger.debug(f'{msg}\n{self.definition}\n{indicator}') # ruff: ignore[logging-f-string]
|
||||
|
||||
def fail(self, msg: str) -> NoReturn:
|
||||
errors = []
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import shutil
|
||||
|
||||
import sphinx._cli.util.colour
|
||||
from sphinx._cli.util.colour import ( # NoQA: F401
|
||||
from sphinx._cli.util.colour import ( # ruff: ignore[unused-import]
|
||||
_create_input_mode_colour_func,
|
||||
black,
|
||||
blink,
|
||||
|
||||
@@ -44,7 +44,7 @@ def status_iterator[T](
|
||||
if single_line:
|
||||
# clear the entire line ('Erase in Line')
|
||||
logger.info('\x1b[2K', nonl=True)
|
||||
logger.info(f'{bold_summary}[{i / length: >4.0%}] ', nonl=True) # NoQA: G004
|
||||
logger.info(f'{bold_summary}[{i / length: >4.0%}] ', nonl=True) # ruff: ignore[logging-f-string]
|
||||
# Emit the string representation of ``item``
|
||||
logger.info(stringify_func(item), nonl=True, color=color)
|
||||
# If in single-line mode, emit a carriage return to move the cursor
|
||||
@@ -75,14 +75,14 @@ class progress_message:
|
||||
) -> bool:
|
||||
prefix = '' if self.nonl else bold(self.message + ': ')
|
||||
if isinstance(val, SkipProgressMessage):
|
||||
logger.info(prefix + __('skipped')) # NoQA: G003
|
||||
logger.info(prefix + __('skipped')) # ruff: ignore[logging-string-concat]
|
||||
if val.args:
|
||||
logger.info(*val.args)
|
||||
return True
|
||||
elif val:
|
||||
logger.info(prefix + __('failed')) # NoQA: G003
|
||||
logger.info(prefix + __('failed')) # ruff: ignore[logging-string-concat]
|
||||
else:
|
||||
logger.info(prefix + __('done')) # NoQA: G003
|
||||
logger.info(prefix + __('done')) # ruff: ignore[logging-string-concat]
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@@ -840,7 +840,7 @@ def new_document(source_path: str, settings: Any = None) -> nodes.document:
|
||||
caches the result of docutils' and use it on second call for instantiation.
|
||||
This makes an instantiation of document nodes much faster.
|
||||
"""
|
||||
global __document_cache__ # NoQA: PLW0603
|
||||
global __document_cache__ # ruff: ignore[global-statement]
|
||||
try:
|
||||
cached_settings, reporter = __document_cache__
|
||||
except NameError:
|
||||
@@ -960,5 +960,5 @@ if docutils.__version_info__[:2] < (0, 22):
|
||||
|
||||
else:
|
||||
from docutils.parsers.rst.roles import (
|
||||
normalize_options as _normalize_options, # NoQA: F401 # ty: ignore[unresolved-import]
|
||||
normalize_options as _normalize_options, # ruff: ignore[unused-import] # ty: ignore[unresolved-import]
|
||||
)
|
||||
@@ -619,10 +619,10 @@ class TypeAliasForwardRef:
|
||||
def __or__(self, other: Any) -> Any:
|
||||
# When evaluating type hints, our forward ref can appear in type expressions,
|
||||
# i.e. `Alias | None`. This means it needs to support ``__or__`` and ``__ror__``.
|
||||
return typing.Union[self, other] # NoQA: UP007
|
||||
return typing.Union[self, other] # ruff: ignore[non-pep604-annotation-union]
|
||||
|
||||
def __ror__(self, other: Any) -> Any:
|
||||
return typing.Union[other, self] # NoQA: UP007
|
||||
return typing.Union[other, self] # ruff: ignore[non-pep604-annotation-union]
|
||||
|
||||
|
||||
class TypeAliasModule:
|
||||
|
||||
@@ -514,7 +514,7 @@ def inline_all_toctrees(
|
||||
if includefile not in traversed:
|
||||
try:
|
||||
traversed.append(includefile)
|
||||
logger.info(indent + colorfunc(includefile)) # NoQA: G003
|
||||
logger.info(indent + colorfunc(includefile)) # ruff: ignore[logging-string-concat]
|
||||
subtree = inline_all_toctrees(
|
||||
builder,
|
||||
docnameset,
|
||||
|
||||
@@ -29,8 +29,8 @@ tex_replacements = [
|
||||
# map some special Unicode characters to similar ASCII ones
|
||||
# (even for Unicode LaTeX as may not be supported by OpenType font)
|
||||
('⎽', r'\_'),
|
||||
('ℯ', r'e'), # U+212F # NoQA: RUF001
|
||||
('ⅈ', r'i'), # U+2148 # NoQA: RUF001
|
||||
('ℯ', r'e'), # U+212F # ruff: ignore[ambiguous-unicode-character-string]
|
||||
('ⅈ', r'i'), # U+2148 # ruff: ignore[ambiguous-unicode-character-string]
|
||||
# Greek alphabet not escaped: pdflatex handles it via textalpha and inputenc
|
||||
# OHM SIGN U+2126 is handled by LaTeX textcomp package
|
||||
]
|
||||
|
||||
@@ -183,7 +183,7 @@ class ExtensionMetadata(typing.TypedDict, total=False):
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
type _ExtensionSetupFunc = Callable[[Sphinx], ExtensionMetadata] # NoQA: PYI047 (false positive)
|
||||
type _ExtensionSetupFunc = Callable[[Sphinx], ExtensionMetadata] # ruff: ignore[unused-private-type-alias] (false positive)
|
||||
|
||||
|
||||
def get_type_hints(
|
||||
@@ -586,12 +586,12 @@ def stringify_annotation(
|
||||
elif dataclasses.is_dataclass(m):
|
||||
# use stringify_annotation for the repr of field values rather than repr
|
||||
d_fields = ', '.join([
|
||||
f'{f.name}={stringify_annotation(getattr(m, f.name), mode=mode, short_literals=short_literals)}' # NoQA: E501
|
||||
f'{f.name}={stringify_annotation(getattr(m, f.name), mode=mode, short_literals=short_literals)}' # ruff: ignore[line-too-long]
|
||||
for f in dataclasses.fields(m)
|
||||
if f.repr
|
||||
])
|
||||
meta_args.append(
|
||||
f'{stringify_annotation(type(m), mode=mode, short_literals=short_literals)}({d_fields})' # NoQA: E501
|
||||
f'{stringify_annotation(type(m), mode=mode, short_literals=short_literals)}({d_fields})' # ruff: ignore[line-too-long]
|
||||
)
|
||||
else:
|
||||
meta_args.append(repr(m))
|
||||
|
||||
@@ -342,7 +342,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
)
|
||||
atts['href'] = '#' + node['refid']
|
||||
if not isinstance(node.parent, nodes.TextElement):
|
||||
assert len(node) == 1 and isinstance(node[0], nodes.image) # NoQA: PT018
|
||||
assert len(node) == 1 and isinstance(node[0], nodes.image) # ruff: ignore[pytest-composite-assertion]
|
||||
atts['class'] += ' image-reference'
|
||||
if 'reftitle' in node:
|
||||
atts['title'] = node['reftitle']
|
||||
|
||||
@@ -2575,7 +2575,7 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
|
||||
# FIXME: Workaround to avoid circular import
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/5433
|
||||
from sphinx.builders.latex.nodes import ( # NoQA: E402 # isort:skip
|
||||
from sphinx.builders.latex.nodes import ( # ruff: ignore[module-import-not-at-top-of-file] # isort:skip
|
||||
HYPERLINK_SUPPORT_NODES,
|
||||
captioned_literal_block,
|
||||
footnotetext,
|
||||
|
||||
@@ -242,7 +242,7 @@ class Table:
|
||||
for colno, cell in enumerate(line):
|
||||
if cell.col != colno:
|
||||
continue
|
||||
if lineno != cell.row: # NoQA: SIM114
|
||||
if lineno != cell.row: # ruff: ignore[if-with-same-arms]
|
||||
physical_text = ''
|
||||
elif physical_line >= len(cell.wrapped):
|
||||
physical_text = ''
|
||||
|
||||
@@ -37,7 +37,7 @@ def visit_numbered_text(self, node):
|
||||
raise nodes.SkipNode
|
||||
|
||||
|
||||
def get_title(node): # NoQA: FURB118
|
||||
def get_title(node): # ruff: ignore[reimplemented-operator]
|
||||
return node['title']
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from dummy import * # NoQA: F403
|
||||
from dummy import * # ruff: ignore[undefined-local-with-import-star]
|
||||
|
||||
|
||||
def test():
|
||||
"""Dummy function using dummy.*"""
|
||||
dummy_function() # NoQA: F405
|
||||
dummy_function() # ruff: ignore[undefined-local-with-import-star-usage]
|
||||
@@ -1,7 +1,9 @@
|
||||
# NoQA: N999
|
||||
# ruff: ignore[invalid-module-name]
|
||||
from __future__ import annotations
|
||||
|
||||
from gettext import NullTranslations # NoQA: TC003
|
||||
from gettext import (
|
||||
NullTranslations, # ruff: ignore[typing-only-standard-library-import]
|
||||
)
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -88,15 +88,15 @@ class Class:
|
||||
"""a documented instance attribute"""
|
||||
self._private_inst_attr = None #: a private instance attribute
|
||||
|
||||
def __special1__(self): # NoQA: PLW3201
|
||||
def __special1__(self): # ruff: ignore[bad-dunder-method-name]
|
||||
"""documented special method"""
|
||||
|
||||
def __special2__(self): # NoQA: PLW3201
|
||||
def __special2__(self): # ruff: ignore[bad-dunder-method-name]
|
||||
# undocumented special method
|
||||
pass
|
||||
|
||||
|
||||
class CustomDict(dict): # NoQA: FURB189
|
||||
class CustomDict(dict): # ruff: ignore[subclass-builtin]
|
||||
"""Docstring."""
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class DocstringSig:
|
||||
return 456
|
||||
|
||||
|
||||
class StrRepr(str): # NoQA: FURB189,SLOT000
|
||||
class StrRepr(str): # ruff: ignore[subclass-builtin, no-slots-in-str-subclass]
|
||||
"""docstring"""
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import io # NoQA: TC003
|
||||
import io # ruff: ignore[typing-only-standard-library-import]
|
||||
from typing import TYPE_CHECKING, overload
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -15,7 +15,7 @@ variable: myint
|
||||
variable2 = None # type: myint
|
||||
|
||||
#: docstring
|
||||
variable3: Optional[myint] # NoQA: UP045
|
||||
variable3: Optional[myint] # ruff: ignore[non-pep604-annotation-optional]
|
||||
|
||||
|
||||
def read(r: io.BytesIO) -> io.StringIO:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from inspect import Parameter, Signature
|
||||
from typing import List, Union # NoQA: UP035
|
||||
from typing import List, Union # ruff: ignore[deprecated-import]
|
||||
|
||||
|
||||
class Foo:
|
||||
@@ -30,7 +30,7 @@ class Qux:
|
||||
pass
|
||||
|
||||
|
||||
class Quux(List[Union[int, float]]): # NoQA: UP006,UP007
|
||||
class Quux(List[Union[int, float]]): # ruff: ignore[non-pep585-annotation, non-pep604-annotation-union]
|
||||
"""A subclass of List[Union[int, float]]"""
|
||||
|
||||
pass
|
||||
|
||||
@@ -22,7 +22,7 @@ class AsyncClass:
|
||||
yield
|
||||
|
||||
|
||||
async def _other_coro_func(): # NoQA: RUF029
|
||||
async def _other_coro_func(): # ruff: ignore[unused-async]
|
||||
return 'run'
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ class E:
|
||||
def __init__(self):
|
||||
r"""E(foo: int, bar: int, baz: int) -> None \
|
||||
E(foo: str, bar: str, baz: str) -> None \
|
||||
E(foo: float, bar: float, baz: float)""" # NoQA: D209
|
||||
E(foo: float, bar: float, baz: float)""" # ruff: ignore[new-line-after-last-paragraph]
|
||||
|
||||
|
||||
class F:
|
||||
def __init__(self):
|
||||
"""F(foo: int, bar: int, baz: int) -> None
|
||||
F(foo: str, bar: str, baz: str) -> None
|
||||
F(foo: float, bar: float, baz: float)""" # NoQA: D209
|
||||
F(foo: float, bar: float, baz: float)""" # ruff: ignore[new-line-after-last-paragraph]
|
||||
@@ -1,4 +1,4 @@
|
||||
# ruff: noqa: PIE796
|
||||
# ruff: file-ignore[non-unique-enums]
|
||||
import enum
|
||||
from typing import final
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import typing
|
||||
from typing import final
|
||||
|
||||
import typing_extensions
|
||||
from typing_extensions import final as final_ext # noqa: UP035
|
||||
from typing_extensions import final as final_ext # ruff: ignore[deprecated-import]
|
||||
|
||||
|
||||
@typing.final
|
||||
|
||||
@@ -9,7 +9,7 @@ async def coroutinefunc():
|
||||
pass
|
||||
|
||||
|
||||
async def asyncgenerator(): # NoQA: RUF029
|
||||
async def asyncgenerator(): # ruff: ignore[unused-async]
|
||||
yield
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@ builtin_func = print
|
||||
partial_builtin_func = partial(print)
|
||||
|
||||
|
||||
def slice_arg_func(arg: 'float64[:, :]'): # NoQA: F821
|
||||
def slice_arg_func(arg: 'float64[:, :]'): # ruff: ignore[undefined-name]
|
||||
pass
|
||||
@@ -7,7 +7,7 @@ T = TypeVar('T')
|
||||
|
||||
# Test that typing.Generic's __new__ method does not mask our class'
|
||||
# __init__ signature.
|
||||
class A(Generic[T]): # NoQA: UP046
|
||||
class A(Generic[T]): # ruff: ignore[non-pep695-generic-class]
|
||||
"""docstring for A"""
|
||||
|
||||
def __init__(self, a, b=None):
|
||||
|
||||
@@ -10,7 +10,7 @@ class Base:
|
||||
"""Inherited class method."""
|
||||
|
||||
@staticmethod
|
||||
def inheritedstaticmeth(cls): # NoQA: PLW0211
|
||||
def inheritedstaticmeth(cls): # ruff: ignore[bad-staticmethod-argument]
|
||||
"""Inherited static method."""
|
||||
|
||||
|
||||
@@ -26,6 +26,6 @@ class Derived(Base, AnotherBase):
|
||||
pass
|
||||
|
||||
|
||||
class MyList(list): # NoQA: FURB189
|
||||
class MyList(list): # ruff: ignore[subclass-builtin]
|
||||
def meth(self):
|
||||
"""docstring"""
|
||||
@@ -3,14 +3,16 @@ import missing_package1.missing_module1
|
||||
import sphinx.missing_module4
|
||||
from missing_module import missing_name
|
||||
from missing_package2 import missing_module2
|
||||
from missing_package3.missing_module3 import missing_name # NoQA: F811
|
||||
from missing_package3.missing_module3 import (
|
||||
missing_name, # ruff: ignore[redefined-while-unused]
|
||||
)
|
||||
from sphinx.missing_module4 import missing_name2
|
||||
|
||||
|
||||
@missing_name(int)
|
||||
def decorated_function():
|
||||
"""decorated_function docstring"""
|
||||
return None # NoQA: RET501
|
||||
return None # ruff: ignore[unnecessary-return-none]
|
||||
|
||||
|
||||
def func(arg: missing_module.Class):
|
||||
@@ -27,7 +29,7 @@ class TestAutodoc:
|
||||
@missing_name
|
||||
def decorated_method(self):
|
||||
"""TestAutodoc::decorated_method docstring"""
|
||||
return None # NoQA: RET501
|
||||
return None # ruff: ignore[unnecessary-return-none]
|
||||
|
||||
|
||||
class Inherited(missing_module.Class):
|
||||
|
||||
@@ -2,7 +2,7 @@ import typing
|
||||
from typing import TYPE_CHECKING, overload
|
||||
|
||||
import typing_extensions
|
||||
from typing_extensions import overload as over_ext # noqa: UP035
|
||||
from typing_extensions import overload as over_ext # ruff: ignore[deprecated-import]
|
||||
|
||||
|
||||
@overload
|
||||
|
||||
@@ -24,13 +24,13 @@ type Pep695Alias = Foo
|
||||
|
||||
type Pep695AliasUndocumented = Foo
|
||||
|
||||
TypeAliasTypeExplicit = TypeAliasType('TypeAliasTypeExplicit', Foo) # NoQA: UP040
|
||||
TypeAliasTypeExplicit = TypeAliasType('TypeAliasTypeExplicit', Foo) # ruff: ignore[non-pep695-type-alias]
|
||||
"""This is an explicitly constructed typing.TypeAlias."""
|
||||
|
||||
HandlerTypeAliasType = TypeAliasType('HandlerTypeAliasType', type[Exception]) # NoQA: UP040
|
||||
HandlerTypeAliasType = TypeAliasType('HandlerTypeAliasType', type[Exception]) # ruff: ignore[non-pep695-type-alias]
|
||||
"""This is an explicitly constructed generic alias typing.TypeAlias."""
|
||||
|
||||
TypeAliasTypeExtension = typing_extensions.TypeAliasType('TypeAliasTypeExtension', Foo) # NoQA: UP040
|
||||
TypeAliasTypeExtension = typing_extensions.TypeAliasType('TypeAliasTypeExtension', Foo) # ruff: ignore[non-pep695-type-alias]
|
||||
"""This is an explicitly constructed typing_extensions.TypeAlias."""
|
||||
|
||||
#: This is PEP695 complex type alias with doc comment.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any # NoQA: TC003
|
||||
from typing import Any # ruff: ignore[typing-only-standard-library-import]
|
||||
|
||||
CONSTANT = 'foo'
|
||||
SENTINEL = object()
|
||||
@@ -10,7 +10,7 @@ SENTINEL = object()
|
||||
def foo(
|
||||
name: str = CONSTANT,
|
||||
sentinel: Any = SENTINEL,
|
||||
now: datetime = datetime.now(), # NoQA: B008,DTZ005
|
||||
now: datetime = datetime.now(), # ruff: ignore[function-call-in-default-argument, call-datetime-now-without-tzinfo]
|
||||
color: int = 0xFFFFFF,
|
||||
*,
|
||||
kwarg1,
|
||||
@@ -26,7 +26,7 @@ class Class:
|
||||
self,
|
||||
name: str = CONSTANT,
|
||||
sentinel: Any = SENTINEL,
|
||||
now: datetime = datetime.now(), # NoQA: B008,DTZ005
|
||||
now: datetime = datetime.now(), # ruff: ignore[function-call-in-default-argument, call-datetime-now-without-tzinfo]
|
||||
color: int = 0xFFFFFF,
|
||||
*,
|
||||
kwarg1,
|
||||
@@ -39,7 +39,7 @@ class Class:
|
||||
cls,
|
||||
name: str = CONSTANT,
|
||||
sentinel: Any = SENTINEL,
|
||||
now: datetime = datetime.now(), # NoQA: B008,DTZ005
|
||||
now: datetime = datetime.now(), # ruff: ignore[function-call-in-default-argument, call-datetime-now-without-tzinfo]
|
||||
color: int = 0xFFFFFF,
|
||||
*,
|
||||
kwarg1,
|
||||
@@ -48,7 +48,7 @@ class Class:
|
||||
"""docstring"""
|
||||
|
||||
|
||||
get_sentinel = lambda custom=SENTINEL: custom # NoQA: E731
|
||||
get_sentinel = lambda custom=SENTINEL: custom # ruff: ignore[lambda-assignment]
|
||||
"""docstring"""
|
||||
|
||||
|
||||
@@ -74,5 +74,5 @@ class MultiLine:
|
||||
(lambda self: 4, doc='docstring'))
|
||||
|
||||
prop5 = property\
|
||||
(lambda self: 5, doc='docstring') # NoQA: E211
|
||||
(lambda self: 5, doc='docstring') # ruff: ignore[whitespace-before-parameters]
|
||||
# fmt: on
|
||||
@@ -9,7 +9,7 @@ SENTINEL = object()
|
||||
|
||||
|
||||
#: docstring
|
||||
ze_lambda = lambda z=SENTINEL: None # NoQA: E731
|
||||
ze_lambda = lambda z=SENTINEL: None # ruff: ignore[lambda-assignment]
|
||||
|
||||
|
||||
def foo(x, y, z=SENTINEL):
|
||||
@@ -50,5 +50,5 @@ class MyNamedTuple1(NamedTuple):
|
||||
c: list[int] = [1, 2, 3]
|
||||
|
||||
|
||||
class MyNamedTuple2(namedtuple('Base', ('a', 'b'), defaults=(0, SENTINEL))): # NoQA: PYI024,SLOT002
|
||||
class MyNamedTuple2(namedtuple('Base', ('a', 'b'), defaults=(0, SENTINEL))): # ruff: ignore[collections-named-tuple, no-slots-in-namedtuple-subclass]
|
||||
"""docstring"""
|
||||
@@ -21,4 +21,4 @@ class Bar:
|
||||
class Baz:
|
||||
"""docstring"""
|
||||
|
||||
__slots__ = 'attr' # NoQA: PLC0205
|
||||
__slots__ = 'attr' # ruff: ignore[single-string-slots]
|
||||
@@ -10,7 +10,7 @@ class _Descriptor:
|
||||
def __init__(self, name):
|
||||
self.__doc__ = f'This is {name}'
|
||||
|
||||
def __get__(self): # NoQA: PLE0302
|
||||
def __get__(self): # ruff: ignore[unexpected-special-method-signature]
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
from typing import TYPE_CHECKING, Tuple, TypeVar, Union # NoQA: UP035
|
||||
from typing import ( # ruff: ignore[deprecated-import]
|
||||
TYPE_CHECKING,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
@@ -65,7 +70,7 @@ def tuple_args(x: tuple[int, int | str]) -> tuple[int, int]:
|
||||
|
||||
|
||||
class NewAnnotation:
|
||||
def __new__(cls, i: int) -> NewAnnotation: # NoQA: PYI034
|
||||
def __new__(cls, i: int) -> NewAnnotation: # ruff: ignore[non-self-return-type]
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ T2 = TypeVar('T2') # A TypeVar not having doc comment
|
||||
T3 = TypeVar('T3', int, str)
|
||||
|
||||
#: T4
|
||||
T4 = TypeVar('T4', covariant=True) # NoQA: PLC0105
|
||||
T4 = TypeVar('T4', covariant=True) # ruff: ignore[type-name-incorrect-variance]
|
||||
|
||||
#: T5
|
||||
T5 = TypeVar('T5', contravariant=True) # NoQA: PLC0105
|
||||
T5 = TypeVar('T5', contravariant=True) # ruff: ignore[type-name-incorrect-variance]
|
||||
|
||||
#: T6
|
||||
T6 = NewType('T6', date)
|
||||
|
||||
@@ -2,10 +2,12 @@ from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager
|
||||
from functools import lru_cache
|
||||
from typing import Generator # NoQA: TC003,UP035
|
||||
from typing import ( # ruff: ignore[typing-only-standard-library-import, deprecated-import]
|
||||
Generator,
|
||||
)
|
||||
|
||||
|
||||
@lru_cache(maxsize=None) # NoQA: UP033
|
||||
@lru_cache(maxsize=None) # ruff: ignore[lru-cache-with-maxsize-none]
|
||||
def slow_function(message, timeout):
|
||||
"""This function is slow."""
|
||||
print(message)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
C.prop_attr1
|
||||
C.prop_attr2
|
||||
C.C2
|
||||
""" # NoQA: D212
|
||||
""" # ruff: ignore[multi-line-summary-first-line]
|
||||
|
||||
|
||||
def with_sentence():
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class class_:
|
||||
"""Class"""
|
||||
|
||||
def method_(_arg): # NoQA: N805
|
||||
def method_(_arg): # ruff: ignore[invalid-first-argument-name-for-method]
|
||||
"""Method"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import Union
|
||||
|
||||
|
||||
class Foo:
|
||||
class Bar: # NoQA: D106
|
||||
class Bar: # ruff: ignore[undocumented-public-nested-class]
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ def public_baz():
|
||||
"""Public Baz function"""
|
||||
|
||||
|
||||
__all__ = ['PublicBar', 'public_foo', 'public_baz', 'extra_dummy_module'] # NoQA: F822
|
||||
__all__ = ['PublicBar', 'public_foo', 'public_baz', 'extra_dummy_module'] # ruff: ignore[undefined-export]
|
||||
@@ -1,4 +1,4 @@
|
||||
from os import * # NoQA: F403
|
||||
from os import * # ruff: ignore[undefined-local-with-import-star]
|
||||
|
||||
|
||||
class Foo:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from os import * # NoQA: F403
|
||||
from os import * # ruff: ignore[undefined-local-with-import-star]
|
||||
|
||||
|
||||
class Foo:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from os import * # NoQA: F403
|
||||
from os import * # ruff: ignore[undefined-local-with-import-star]
|
||||
|
||||
|
||||
class Foo:
|
||||
|
||||
@@ -23,7 +23,7 @@ class Foo:
|
||||
CONSTANT3 = None
|
||||
CONSTANT4 = None
|
||||
|
||||
class Bar: # NoQA: D106
|
||||
class Bar: # ruff: ignore[undocumented-public-nested-class]
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
@@ -42,7 +42,7 @@ class _Baz:
|
||||
pass
|
||||
|
||||
|
||||
def bar(x: Union[int, str], y: int = 1) -> None: # NoQA: UP007
|
||||
def bar(x: Union[int, str], y: int = 1) -> None: # ruff: ignore[non-pep604-annotation-union]
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@ class DocMainLevel(Foo):
|
||||
pass
|
||||
|
||||
|
||||
class Alice(object): # NoQA: UP004
|
||||
class Alice(object): # ruff: ignore[useless-object-inheritance]
|
||||
pass
|
||||
@@ -4,7 +4,7 @@ from docutils.parsers.rst import Directive
|
||||
extensions = ['sphinx.ext.mathjax']
|
||||
|
||||
|
||||
def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): # NoQA: B006
|
||||
def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): # ruff: ignore[mutable-argument-default]
|
||||
text = 'E = mc^2'
|
||||
return [nodes.math(text, text)], []
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
|
||||
if 'test_linkcode' in tags: # NoQA: F821 (tags is injected into conf.py)
|
||||
if 'test_linkcode' in tags: # ruff: ignore[undefined-name] (tags is injected into conf.py)
|
||||
extensions.remove('sphinx.ext.viewcode')
|
||||
extensions.append('sphinx.ext.linkcode')
|
||||
|
||||
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user