Fixed data annotations causing pickle or deepcopy errors

Closes #261
This commit is contained in:
Ashley Whetter 2021-04-02 20:57:06 -07:00
parent bf8f50dc97
commit 7541f922ae
2 changed files with 3 additions and 9 deletions

View File

@ -22,6 +22,8 @@ Bug Fixes
not turning off signature type hints. not turning off signature type hints.
``autodoc_typehints`` integration is consisidered experimental until ``autodoc_typehints`` integration is consisidered experimental until
the extension properly supports overload functions. the extension properly supports overload functions.
* `#261 <https://github.com/readthedocs/sphinx-autoapi/issues/261>`
Fixed data annotations causing pickle or deepcopy errors.
Trivial/Internal Changes Trivial/Internal Changes
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -176,21 +176,13 @@ def get_assign_annotation(node):
:returns: The type annotation as a string, or None if one does not exist. :returns: The type annotation as a string, or None if one does not exist.
:rtype: str or None :rtype: str or None
""" """
annotation = None
annotation_node = None annotation_node = None
try: try:
annotation_node = node.annotation annotation_node = node.annotation
except AttributeError: except AttributeError:
annotation_node = node.type_annotation annotation_node = node.type_annotation
if annotation_node: return format_annotation(annotation_node, node)
if isinstance(annotation_node, astroid.nodes.Const):
annotation = node.value
else:
annotation = annotation_node.as_string()
return annotation
def is_decorated_with_property(node): def is_decorated_with_property(node):