From 7541f922ae862e7de052040ae69749006ac9692f Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Fri, 2 Apr 2021 20:57:06 -0700 Subject: [PATCH] Fixed data annotations causing pickle or deepcopy errors Closes #261 --- CHANGELOG.rst | 2 ++ autoapi/mappers/python/astroid_utils.py | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) 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):