@@ -67,17 +67,19 @@ def _init_vars(app: Sphinx, config: Config):
67
67
config .html_static_path .append (str (HERE / "static" ))
68
68
69
69
70
+ def _fixup (fmt : str ) -> str :
71
+ # work around https://github.com/agronholm/sphinx-autodoc-typehints/issues/94
72
+ fmt = fmt .replace (":py:class:`typing.Tuple`" , ":py:data:`typing.Tuple`" )
73
+ fmt = fmt .replace (":py:class:`~typing.Tuple`" , ":py:data:`~typing.Tuple`" )
74
+ return fmt
75
+
76
+
70
77
def _format_full (annotation : Type [Any ], fully_qualified : bool = False ):
71
78
if inspect .isclass (annotation ) and annotation .__module__ == "builtins" :
72
79
return _format_orig (annotation , fully_qualified )
73
80
annotation_cls = annotation if inspect .isclass (annotation ) else type (annotation )
74
81
if annotation_cls .__module__ == "typing" :
75
- formatted = _format_orig (annotation , fully_qualified )
76
- # work around https://github.com/agronholm/sphinx-autodoc-typehints/issues/94
77
- formatted = formatted .replace (
78
- ":py:class:`typing.Tuple`" , ":py:data:`typing.Tuple`"
79
- )
80
- return formatted
82
+ return _fixup (_format_orig (annotation , fully_qualified ))
81
83
82
84
# Only if this is a real class we override sphinx_autodoc_typehints
83
85
if inspect .isclass (annotation ) or inspect .isclass (
@@ -88,7 +90,7 @@ def _format_full(annotation: Type[Any], fully_qualified: bool = False):
88
90
if override is not None :
89
91
return f":py:class:`{ '' if fully_qualified else '~' } { override } `"
90
92
91
- return _format_orig (annotation , fully_qualified )
93
+ return _fixup ( _format_orig (annotation , fully_qualified ) )
92
94
93
95
94
96
def _format_terse (annotation : Type [Any ], fully_qualified : bool = False ) -> str :
0 commit comments