Skip to content

Commit e858479

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent aba77c9 commit e858479

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/sphinx_autodoc_typehints/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
from sphinx.ext.autodoc.mock import mock
1818
from sphinx.parsers import RSTParser
1919
from sphinx.util import logging, rst
20+
from sphinx.util.inspect import TypeAliasForwardRef, TypeAliasNamespace, stringify_signature
2021
from sphinx.util.inspect import signature as sphinx_signature
21-
from sphinx.util.inspect import stringify_signature
22-
23-
from typing import get_type_hints
24-
from sphinx.util.inspect import TypeAliasNamespace, TypeAliasForwardRef
2522

2623
from .parser import parse
2724
from .patches import install_patches
@@ -413,7 +410,6 @@ def _future_annotations_imported(obj: Any) -> bool:
413410
def get_all_type_hints(
414411
autodoc_mock_imports: list[str], obj: Any, name: str, localns: TypeAliasNamespace
415412
) -> dict[str, Any]:
416-
417413
result = _get_type_hint(autodoc_mock_imports, name, obj, localns)
418414
if not result:
419415
result = backfill_type_hints(obj, name)
@@ -728,8 +724,7 @@ def _inject_signature( # noqa: C901
728724
app: Sphinx,
729725
lines: list[str],
730726
) -> None:
731-
732-
for arg_name, arg_type in signature.parameters.items():
727+
for arg_name in signature.parameters:
733728
annotation = type_hints.get(arg_name)
734729

735730
default = signature.parameters[arg_name].default

tests/test_integration.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,7 @@ def typehints_use_signature(a: AsyncGenerator) -> AsyncGenerator:
12701270

12711271
prolog = """
12721272
.. |test_node_start| replace:: {test_node_start}
1273-
""".format(
1274-
test_node_start="test_start"
1275-
)
1273+
""".format(test_node_start="test_start")
12761274

12771275

12781276
@expected(
@@ -1309,9 +1307,7 @@ def docstring_with_multiline_note_after_params_prolog_replace(param: int) -> Non
13091307

13101308
epilog = """
13111309
.. |test_node_end| replace:: {test_node_end}
1312-
""".format(
1313-
test_node_end="test_end"
1314-
)
1310+
""".format(test_node_end="test_end")
13151311

13161312

13171313
@expected(
@@ -1366,19 +1362,19 @@ def docstring_with_multiline_note_after_params_epilog_replace(param: int) -> Non
13661362
mod.function1(x)
13671363
13681364
Function docstring.
1369-
1365+
13701366
Parameters:
13711367
**x** (Input) -- foo
1372-
1368+
13731369
Return type:
13741370
Output
1375-
1371+
13761372
Returns:
13771373
something
13781374
13791375
""",
13801376
)
1381-
def function1(x: "Input") -> "Output":
1377+
def function1(x: Input) -> Output:
13821378
"""
13831379
Function docstring.
13841380

tests/test_integration_autodoc_type_aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def dec(val: T) -> T:
3838

3939

4040
class _SchemaMeta(type):
41-
def __eq__(cls, other: Any) -> bool:
41+
def __eq__(cls, other: object) -> bool:
4242
return True
4343

4444

0 commit comments

Comments
 (0)