diff --git a/.ruff.toml b/.ruff.toml index 8d237f239..08576e175 100644 --- a/.ruff.toml +++ b/.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 ] diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py index d51d6000b..ad2651514 100644 --- a/sphinx/addnodes.py +++ b/sphinx/addnodes.py @@ -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 diff --git a/sphinx/testing/fixtures.py b/sphinx/testing/fixtures.py index ae2509428..1e66d8fc0 100644 --- a/sphinx/testing/fixtures.py +++ b/sphinx/testing/fixtures.py @@ -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) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 7cad48a24..ffd051c7f 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -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 diff --git a/utils/bump_docker.py b/utils/bump_docker.py index ec4a1c7e0..9052a2ea8 100755 --- a/utils/bump_docker.py +++ b/utils/bump_docker.py @@ -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,