Fix #8541: autodoc_type_aliases doesn't work for the instance attrs

So far, autodoc obtains type annotations of instance attributes by
ModuleAnalyzer directly.  As a result, autodoc_type_aliases are ignored
for these variables.

This goes to merge type annotations from the class itself and
ModuleAnalyzer's, and get type annotations using `typing.get_type_hints()`
to apply autodoc_type_aliases.
This commit is contained in:
Takeshi KOMIYA
2020-12-17 00:46:49 +09:00
parent 36e684bf83
commit 55c110f609
5 changed files with 100 additions and 18 deletions

View File

@@ -7,6 +7,9 @@ myint = int
#: docstring
variable: myint
#: docstring
variable2 = None # type: myint
def sum(x: myint, y: myint) -> myint:
"""docstring"""
@@ -32,4 +35,7 @@ class Foo:
"""docstring"""
#: docstring
attr: myint
attr1: myint
def __init__(self):
self.attr2: myint = None #: docstring