Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-15 07:58:12 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-28 09:58:06 +0300
commit7d3cc382fa2ab875ea168ee40ce34562a387bb40 (patch)
tree4aacb2a5d06b37893fd1bbf3fa2235401528423f /sphinx/util
parent6ca7c1c579c6857985a5e8faae64a77b32dc6098 (diff)
autodoc: an imported TypeVar is not resolved (refs: #8415)
So far, a TypeVar is rendered without module name. As a result, it could not be resolved if it is imported from other modules. This prepends its module name and make it resolvable. This is available only in Python 3.7 or above. As a side effect, all of TypeVars are displayed with module name. It should be fixed in latter step (refs: #7119)
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/typing.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index d2bd03efd..afd2f805a 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -263,7 +263,10 @@ def stringify(annotation: Any) -> str:
else:
return annotation
elif isinstance(annotation, TypeVar):
- return annotation.__name__
+ if annotation.__module__ == 'typing':
+ return annotation.__name__
+ else:
+ return '.'.join([annotation.__module__, annotation.__name__])
elif inspect.isNewType(annotation):
# Could not get the module where it defiend
return annotation.__name__