mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable more Ruff checks
This commit is contained in:
parent
80ac07907d
commit
2361db5748
32
.ruff.toml
32
.ruff.toml
@ -114,9 +114,7 @@ select = [
|
|||||||
# pycodestyle ('E')
|
# pycodestyle ('E')
|
||||||
"E",
|
"E",
|
||||||
# flake8-errmsg ('EM')
|
# flake8-errmsg ('EM')
|
||||||
"EM101", # Exception must not use a string literal, assign to variable first
|
"EM",
|
||||||
"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')
|
# eradicate ('ERA')
|
||||||
# NOT YET USED
|
# NOT YET USED
|
||||||
# flake8-executable ('EXE')
|
# flake8-executable ('EXE')
|
||||||
@ -130,7 +128,7 @@ select = [
|
|||||||
# flake8-fixme ('FIX')
|
# flake8-fixme ('FIX')
|
||||||
# NOT YET USED
|
# NOT YET USED
|
||||||
# flynt ('FLY')
|
# flynt ('FLY')
|
||||||
# NOT YET USED
|
"FLY",
|
||||||
# refurb ('FURB')
|
# refurb ('FURB')
|
||||||
"FURB",
|
"FURB",
|
||||||
# flake8-logging-format ('G')
|
# flake8-logging-format ('G')
|
||||||
@ -149,16 +147,11 @@ select = [
|
|||||||
# flake8-no-pep420 ('INP')
|
# flake8-no-pep420 ('INP')
|
||||||
"INP",
|
"INP",
|
||||||
# flake8-gettext ('INT')
|
# flake8-gettext ('INT')
|
||||||
"INT001", # f-string is resolved before function call; consider `_("string %s") % arg`
|
"INT",
|
||||||
"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')
|
# flake8-implicit-str-concat ('ISC')
|
||||||
# NOT YET USED
|
# NOT YET USED
|
||||||
# flake8-logging ('LOG')
|
# flake8-logging ('LOG')
|
||||||
"LOG001", # Use `logging.getLogger()` to instantiate loggers
|
"LOG",
|
||||||
"LOG002", # Use `__name__` with `logging.getLogger()`
|
|
||||||
"LOG007", # Use of `logging.exception` with falsy `exc_info`
|
|
||||||
"LOG009", # Use of undocumented `logging.WARN` constant
|
|
||||||
# pep8-naming ('N')
|
# pep8-naming ('N')
|
||||||
# NOT YET USED
|
# NOT YET USED
|
||||||
# numpy-specific rules ('NPY')
|
# numpy-specific rules ('NPY')
|
||||||
@ -186,9 +179,15 @@ select = [
|
|||||||
"PLC0105", # `{kind}` name "{param_name}" does not reflect its {variance}; consider renaming it to "{replacement_name}"
|
"PLC0105", # `{kind}` name "{param_name}" does not reflect its {variance}; consider renaming it to "{replacement_name}"
|
||||||
"PLC0131", # `{kind}` cannot be both covariant and contravariant
|
"PLC0131", # `{kind}` cannot be both covariant and contravariant
|
||||||
"PLC0132", # `{kind}` name `{param_name}` does not match assigned variable name `{var_name}`
|
"PLC0132", # `{kind}` name `{param_name}` does not match assigned variable name `{var_name}`
|
||||||
# "PLC0205", # Class `__slots__` should be a non-string iterable
|
"PLC0205", # Class `__slots__` should be a non-string iterable
|
||||||
# "PLC0208", # Use a sequence type instead of a `set` when iterating over values
|
"PLC0208", # Use a sequence type instead of a `set` when iterating over values
|
||||||
"PLC0414", # Import alias does not rename original package
|
"PLC0414", # Import alias does not rename original package
|
||||||
|
# "PLC0415", # `import` should be at the top-level of a file
|
||||||
|
"PLC1901", # `{existing}` can be simplified to `{replacement}` as an empty string is falsey
|
||||||
|
"PLC2401", # {kind} name `{name}` contains a non-ASCII character, consider renaming it
|
||||||
|
"PLC2403", # Module alias `{name}` contains a non-ASCII character, use an ASCII-only alias
|
||||||
|
# "PLC2701", # Private name import `{name}` from external module `{module}`
|
||||||
|
"PLC2801", # Unnecessary dunder call to `{method}`. {replacement}.
|
||||||
"PLC3002", # Lambda expression called directly. Execute the expression inline instead.
|
"PLC3002", # Lambda expression called directly. Execute the expression inline instead.
|
||||||
# pylint ('PLE')
|
# pylint ('PLE')
|
||||||
"PLE0100", # `__init__` method is a generator
|
"PLE0100", # `__init__` method is a generator
|
||||||
@ -367,12 +366,7 @@ select = [
|
|||||||
# pyupgrade ('UP')
|
# pyupgrade ('UP')
|
||||||
"UP",
|
"UP",
|
||||||
# pycodestyle ('W')
|
# pycodestyle ('W')
|
||||||
"W191", # Indentation contains tabs
|
"W",
|
||||||
# "W291", # Trailing whitespace
|
|
||||||
"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')
|
# flake8-2020 ('YTT')
|
||||||
"YTT",
|
"YTT",
|
||||||
]
|
]
|
||||||
|
@ -921,7 +921,7 @@ class StandardDomain(Domain):
|
|||||||
# * :option:`-foo=bar`
|
# * :option:`-foo=bar`
|
||||||
# * :option:`-foo[=bar]`
|
# * :option:`-foo[=bar]`
|
||||||
# * :option:`-foo bar`
|
# * :option:`-foo bar`
|
||||||
for needle in {'=', '[=', ' '}:
|
for needle in ('=', '[=', ' '):
|
||||||
if needle in target:
|
if needle in target:
|
||||||
stem, _, _ = target.partition(needle)
|
stem, _, _ = target.partition(needle)
|
||||||
docname, labelid = self.progoptions.get((progname, stem), ('', ''))
|
docname, labelid = self.progoptions.get((progname, stem), ('', ''))
|
||||||
|
@ -170,7 +170,7 @@ def merge_members_option(options: dict) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
members = options.setdefault('members', [])
|
members = options.setdefault('members', [])
|
||||||
for key in {'private-members', 'special-members'}:
|
for key in ('private-members', 'special-members'):
|
||||||
if key in options and options[key] not in (ALL, None):
|
if key in options and options[key] not in (ALL, None):
|
||||||
for member in options[key]:
|
for member in options[key]:
|
||||||
if member not in members:
|
if member not in members:
|
||||||
|
@ -28,7 +28,7 @@ if sys.platform == 'win32':
|
|||||||
# replace exists in both Path and str;
|
# replace exists in both Path and str;
|
||||||
# in Path it makes filesystem changes, so we use the safer str version
|
# in Path it makes filesystem changes, so we use the safer str version
|
||||||
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
|
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
|
||||||
return self.__str__().replace(old, new, count)
|
return self.__str__().replace(old, new, count) # NoQA: PLC2801
|
||||||
|
|
||||||
def __getattr__(self, item: str) -> Any:
|
def __getattr__(self, item: str) -> Any:
|
||||||
if item in _STR_METHODS:
|
if item in _STR_METHODS:
|
||||||
@ -77,7 +77,7 @@ else:
|
|||||||
# replace exists in both Path and str;
|
# replace exists in both Path and str;
|
||||||
# in Path it makes filesystem changes, so we use the safer str version
|
# in Path it makes filesystem changes, so we use the safer str version
|
||||||
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
|
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
|
||||||
return self.__str__().replace(old, new, count)
|
return self.__str__().replace(old, new, count) # NoQA: PLC2801
|
||||||
|
|
||||||
def __getattr__(self, item: str) -> Any:
|
def __getattr__(self, item: str) -> Any:
|
||||||
if item in _STR_METHODS:
|
if item in _STR_METHODS:
|
||||||
|
@ -429,7 +429,7 @@ def _assert_getter_works(app, directive, objtype, name, attrs=(), **kw):
|
|||||||
hooked_members = {s[1] for s in getattr_spy}
|
hooked_members = {s[1] for s in getattr_spy}
|
||||||
documented_members = {s[1] for s in processed_signatures}
|
documented_members = {s[1] for s in processed_signatures}
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
fullname = '.'.join((name, attr))
|
fullname = f'{name}.{attr}'
|
||||||
assert attr in hooked_members
|
assert attr in hooked_members
|
||||||
assert fullname not in documented_members, f'{fullname!r} not intercepted'
|
assert fullname not in documented_members, f'{fullname!r} not intercepted'
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ def test_getslots():
|
|||||||
__slots__ = {'attr': 'docstring'}
|
__slots__ = {'attr': 'docstring'}
|
||||||
|
|
||||||
class Qux:
|
class Qux:
|
||||||
__slots__ = 'attr'
|
__slots__ = 'attr' # NoQA: PLC0205
|
||||||
|
|
||||||
assert inspect.getslots(Foo) is None
|
assert inspect.getslots(Foo) is None
|
||||||
assert inspect.getslots(Bar) == {'attr': None}
|
assert inspect.getslots(Bar) == {'attr': None}
|
||||||
|
Loading…
Reference in New Issue
Block a user