mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7178: autodoc: TypeError is raised on fetching type annotations
This commit is contained in:
parent
011bdeb774
commit
5b84938cd2
1
CHANGES
1
CHANGES
@ -21,6 +21,7 @@ Bugs fixed
|
|||||||
* #7156: autodoc: separator for keyword only arguments is not shown
|
* #7156: autodoc: separator for keyword only arguments is not shown
|
||||||
* #7146: autodoc: IndexError is raised on suppressed type_comment found
|
* #7146: autodoc: IndexError is raised on suppressed type_comment found
|
||||||
* #7161: autodoc: typehints extension does not support parallel build
|
* #7161: autodoc: typehints extension does not support parallel build
|
||||||
|
* #7178: autodoc: TypeError is raised on fetching type annotations
|
||||||
* #7151: crashed when extension assigns a value to ``env.indexentries``
|
* #7151: crashed when extension assigns a value to ``env.indexentries``
|
||||||
* #7170: text: Remove debug print
|
* #7170: text: Remove debug print
|
||||||
* #7137: viewcode: Avoid to crash when non-python code given
|
* #7137: viewcode: Avoid to crash when non-python code given
|
||||||
|
@ -1236,7 +1236,7 @@ class DataDocumenter(ModuleLevelDocumenter):
|
|||||||
if not self.options.annotation:
|
if not self.options.annotation:
|
||||||
# obtain annotation for this data
|
# obtain annotation for this data
|
||||||
annotations = getattr(self.parent, '__annotations__', {})
|
annotations = getattr(self.parent, '__annotations__', {})
|
||||||
if self.objpath[-1] in annotations:
|
if annotations and self.objpath[-1] in annotations:
|
||||||
objrepr = stringify_typehint(annotations.get(self.objpath[-1]))
|
objrepr = stringify_typehint(annotations.get(self.objpath[-1]))
|
||||||
self.add_line(' :type: ' + objrepr, sourcename)
|
self.add_line(' :type: ' + objrepr, sourcename)
|
||||||
else:
|
else:
|
||||||
@ -1424,7 +1424,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter):
|
|||||||
if not self._datadescriptor:
|
if not self._datadescriptor:
|
||||||
# obtain annotation for this attribute
|
# obtain annotation for this attribute
|
||||||
annotations = getattr(self.parent, '__annotations__', {})
|
annotations = getattr(self.parent, '__annotations__', {})
|
||||||
if self.objpath[-1] in annotations:
|
if annotations and self.objpath[-1] in annotations:
|
||||||
objrepr = stringify_typehint(annotations.get(self.objpath[-1]))
|
objrepr = stringify_typehint(annotations.get(self.objpath[-1]))
|
||||||
self.add_line(' :type: ' + objrepr, sourcename)
|
self.add_line(' :type: ' + objrepr, sourcename)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user