diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6930adf..0a6eafc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,8 @@ Bug Fixes not turning off signature type hints. ``autodoc_typehints`` integration is consisidered experimental until the extension properly supports overload functions. +* `#261 ` + Fixed data annotations causing pickle or deepcopy errors. Trivial/Internal Changes ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/autoapi/mappers/python/astroid_utils.py b/autoapi/mappers/python/astroid_utils.py index d22170e..944cb12 100644 --- a/autoapi/mappers/python/astroid_utils.py +++ b/autoapi/mappers/python/astroid_utils.py @@ -176,21 +176,13 @@ def get_assign_annotation(node): :returns: The type annotation as a string, or None if one does not exist. :rtype: str or None """ - annotation = None - annotation_node = None try: annotation_node = node.annotation except AttributeError: annotation_node = node.type_annotation - if annotation_node: - if isinstance(annotation_node, astroid.nodes.Const): - annotation = node.value - else: - annotation = annotation_node.as_string() - - return annotation + return format_annotation(annotation_node, node) def is_decorated_with_property(node):