mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable some flake8-annotations (ANN) lint rules
This commit is contained in:
parent
2b47fd4b4b
commit
767e39df8c
13
.ruff.toml
13
.ruff.toml
@ -32,7 +32,17 @@ select = [
|
||||
# airflow ('AIR')
|
||||
# Airflow is not used in Sphinx
|
||||
# flake8-annotations ('ANN')
|
||||
# NOT YET USED
|
||||
# "ANN001", # Missing type annotation for function argument `{name}`
|
||||
"ANN002", # Missing type annotation for `*{name}`
|
||||
"ANN003", # Missing type annotation for `**{name}`
|
||||
# "ANN101", # Missing type annotation for `{name}` in method
|
||||
# "ANN102", # Missing type annotation for `{name}` in classmethod
|
||||
# "ANN201", # Missing return type annotation for public function `{name}`
|
||||
# "ANN202", # Missing return type annotation for private function `{name}`
|
||||
# "ANN204", # Missing return type annotation for special method `{name}`
|
||||
"ANN205", # Missing return type annotation for staticmethod `{name}`
|
||||
"ANN206", # Missing return type annotation for classmethod `{name}`
|
||||
# "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `{name}`
|
||||
# flake8-unused-arguments ('ARG')
|
||||
"ARG004", # Unused static method argument: `{name}`
|
||||
# flake8-async ('ASYNC')
|
||||
@ -487,6 +497,7 @@ select = [
|
||||
|
||||
"tests/*" = [
|
||||
"E501",
|
||||
"ANN", # tests don't need annotations
|
||||
"T201", # whitelist ``print`` for tests
|
||||
]
|
||||
|
||||
|
@ -322,7 +322,7 @@ class desc_sig_element(nodes.inline, _desc_classes_injector):
|
||||
super().__init__(rawsource, text, *children, **attributes)
|
||||
self['classes'].extend(self.classes)
|
||||
|
||||
def __init_subclass__(cls, *, _sig_element=False, **kwargs):
|
||||
def __init_subclass__(cls, *, _sig_element=False, **kwargs: Any):
|
||||
super().__init_subclass__(**kwargs)
|
||||
if _sig_element:
|
||||
# add the class to the SIG_ELEMENTS set if asked
|
||||
|
@ -175,7 +175,7 @@ def make_app(test_params: dict, monkeypatch: Any) -> Generator[Callable, None, N
|
||||
apps = []
|
||||
syspath = sys.path.copy()
|
||||
|
||||
def make(*args, **kwargs):
|
||||
def make(*args: Any, **kwargs: Any):
|
||||
status, warning = StringIO(), StringIO()
|
||||
kwargs.setdefault('status', status)
|
||||
kwargs.setdefault('warning', warning)
|
||||
|
@ -104,7 +104,7 @@ class FilenameUniqDict(dict):
|
||||
self._existing = state
|
||||
|
||||
|
||||
def _md5(data=b'', **_kw):
|
||||
def _md5(data=b'', **_kw: Any):
|
||||
"""Deprecated wrapper around hashlib.md5
|
||||
|
||||
To be removed in Sphinx 9.0
|
||||
@ -112,7 +112,7 @@ def _md5(data=b'', **_kw):
|
||||
return hashlib.md5(data, usedforsecurity=False)
|
||||
|
||||
|
||||
def _sha1(data=b'', **_kw):
|
||||
def _sha1(data=b'', **_kw: Any):
|
||||
"""Deprecated wrapper around hashlib.sha1
|
||||
|
||||
To be removed in Sphinx 9.0
|
||||
|
@ -34,7 +34,7 @@ for file in DOCKERFILE_BASE, DOCKERFILE_LATEXPDF:
|
||||
file.write_text(content, encoding='utf-8')
|
||||
|
||||
|
||||
def git(*args):
|
||||
def git(*args: str):
|
||||
ret = subprocess.run(('git', *args),
|
||||
capture_output=True,
|
||||
cwd=DOCKER_ROOT,
|
||||
|
Loading…
Reference in New Issue
Block a user