summaryrefslogtreecommitdiff
path: root/sphinx/ext/autodoc.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2016-09-29 11:39:26 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2016-09-29 14:15:18 +0900
commit9118fa38a1492d6444829be07e5ec4aee0c91e35 (patch)
tree275fb8e191e2279a45dbf74d3c8f42306e94bfbc /sphinx/ext/autodoc.py
parent83d6ec11ce5debaf05364810fec21beb887f9761 (diff)
downloadsphinx-git-9118fa38a1492d6444829be07e5ec4aee0c91e35.tar.gz
Fix autodoc misdetect typing with py3.6
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r--sphinx/ext/autodoc.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index 08bc99cdf..967beada0 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -261,6 +261,8 @@ def format_annotation(annotation):
Displaying complex types from ``typing`` relies on its private API.
"""
+ if typing and isinstance(annotation, typing.TypeVar):
+ return annotation.__name__
if not isinstance(annotation, type):
return repr(annotation)
@@ -270,9 +272,7 @@ def format_annotation(annotation):
if annotation.__module__ == 'builtins':
return annotation.__qualname__
elif typing:
- if isinstance(annotation, typing.TypeVar):
- return annotation.__name__
- elif hasattr(typing, 'GenericMeta') and \
+ if hasattr(typing, 'GenericMeta') and \
isinstance(annotation, typing.GenericMeta):
# In Python 3.5.2+, all arguments are stored in __args__,
# whereas __parameters__ only contains generic parameters.