|
17 | 17 | from sphinx.ext.autodoc.mock import mock
|
18 | 18 | from sphinx.parsers import RSTParser
|
19 | 19 | from sphinx.util import logging, rst
|
20 |
| -from sphinx.util.inspect import TypeAliasForwardRef, TypeAliasNamespace, stringify_signature |
| 20 | +from sphinx.util.inspect import stringify_signature |
21 | 21 | from sphinx.util.inspect import signature as sphinx_signature
|
22 | 22 |
|
23 | 23 | from ._parser import parse
|
@@ -222,9 +222,6 @@ def format_annotation(annotation: Any, config: Config, *, short_literals: bool =
|
222 | 222 | if isinstance(annotation, tuple):
|
223 | 223 | return format_internal_tuple(annotation, config)
|
224 | 224 |
|
225 |
| - if isinstance(annotation, TypeAliasForwardRef): |
226 |
| - return annotation.name |
227 |
| - |
228 | 225 | try:
|
229 | 226 | module = get_annotation_module(annotation)
|
230 | 227 | class_name = get_annotation_class_name(annotation, module)
|
@@ -446,7 +443,7 @@ def _future_annotations_imported(obj: Any) -> bool:
|
446 | 443 |
|
447 | 444 |
|
448 | 445 | def get_all_type_hints(
|
449 |
| - autodoc_mock_imports: list[str], obj: Any, name: str, localns: TypeAliasNamespace |
| 446 | + autodoc_mock_imports: list[str], obj: Any, name: str, localns: dict[str, ForwardRef] |
450 | 447 | ) -> dict[str, Any]:
|
451 | 448 | result = _get_type_hint(autodoc_mock_imports, name, obj, localns)
|
452 | 449 | if not result:
|
@@ -517,7 +514,7 @@ def _resolve_type_guarded_imports(autodoc_mock_imports: list[str], obj: Any) ->
|
517 | 514 | _execute_guarded_code(autodoc_mock_imports, obj, module_code)
|
518 | 515 |
|
519 | 516 |
|
520 |
| -def _get_type_hint(autodoc_mock_imports: list[str], name: str, obj: Any, localns: TypeAliasNamespace) -> dict[str, Any]: |
| 517 | +def _get_type_hint(autodoc_mock_imports: list[str], name: str, obj: Any, localns: dict[str, ForwardRef]) -> dict[str, Any]: |
521 | 518 | _resolve_type_guarded_imports(autodoc_mock_imports, obj)
|
522 | 519 | try:
|
523 | 520 | result = get_type_hints(obj, None, localns)
|
@@ -689,7 +686,7 @@ def process_docstring( # noqa: PLR0913, PLR0917
|
689 | 686 | except (ValueError, TypeError):
|
690 | 687 | signature = None
|
691 | 688 |
|
692 |
| - localns = TypeAliasNamespace(app.config["autodoc_type_aliases"]) |
| 689 | + localns = {key: ForwardRef(value) for key, value in app.config["autodoc_type_aliases"].items()} |
693 | 690 | type_hints = get_all_type_hints(app.config.autodoc_mock_imports, obj, name, localns)
|
694 | 691 | app.config._annotation_globals = getattr(obj, "__globals__", {}) # noqa: SLF001
|
695 | 692 | try:
|
|
0 commit comments