summaryrefslogtreecommitdiff
path: root/tests/roots/test-ext-autodoc/target/annotations.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-12-17 00:46:49 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-12-17 01:07:54 +0900
commit55c110f60965ea6f0ea32d129b62413f1f84b3f4 (patch)
treee3065e10b0db4b3749096b6e59433ad8e1565559 /tests/roots/test-ext-autodoc/target/annotations.py
parent36e684bf83d14e587f0bf48eb0980f41ab66733e (diff)
downloadsphinx-git-55c110f60965ea6f0ea32d129b62413f1f84b3f4.tar.gz
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.
Diffstat (limited to 'tests/roots/test-ext-autodoc/target/annotations.py')
-rw-r--r--tests/roots/test-ext-autodoc/target/annotations.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/roots/test-ext-autodoc/target/annotations.py b/tests/roots/test-ext-autodoc/target/annotations.py
index e9ff2f604..ef600e2af 100644
--- a/tests/roots/test-ext-autodoc/target/annotations.py
+++ b/tests/roots/test-ext-autodoc/target/annotations.py
@@ -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