mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user