Fix #9752: autodoc: Failed to detect type annotation for slots attribute

This commit is contained in:
Takeshi KOMIYA
2021-10-23 14:59:36 +09:00
parent e6f9603494
commit b778ee806e
7 changed files with 22 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ class Bar:
__slots__ = {'attr1': 'docstring of attr1',
'attr2': 'docstring of attr2',
'attr3': None}
__annotations__ = {'attr1': int}
def __init__(self):
self.attr2 = None #: docstring of instance attr2

View File

@@ -1359,6 +1359,7 @@ def test_slots(app):
'',
' .. py:attribute:: Bar.attr1',
' :module: target.slots',
' :type: int',
'',
' docstring of attr1',
'',

View File

@@ -129,6 +129,7 @@ def test_autoattribute_slots_variable_dict(app):
'',
'.. py:attribute:: Bar.attr1',
' :module: target.slots',
' :type: int',
'',
' docstring of attr1',
'',

View File

@@ -243,6 +243,7 @@ def test_slots_attribute(app):
'',
' .. py:attribute:: Bar.attr1',
' :module: target.slots',
' :type: int',
'',
' docstring of attr1',
'',