diff options
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r-- | sphinx/ext/autodoc.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 6ae0966fb..08bc99cdf 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -261,12 +261,13 @@ def format_annotation(annotation): Displaying complex types from ``typing`` relies on its private API. """ + if not isinstance(annotation, type): + return repr(annotation) + qualified_name = (annotation.__module__ + '.' + annotation.__qualname__ if annotation else repr(annotation)) - if not isinstance(annotation, type): - return repr(annotation) - elif annotation.__module__ == 'builtins': + if annotation.__module__ == 'builtins': return annotation.__qualname__ elif typing: if isinstance(annotation, typing.TypeVar): |