summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authoryanyongyu <yanyongyu_1@126.com>2021-07-29 12:03:03 +0800
committeryanyongyu <yanyongyu_1@126.com>2021-07-29 12:03:03 +0800
commit67fb3d1157438d4fad25d3e2bf103df65f2ee4f6 (patch)
tree4ecf94e6db3bd657e95403a147034a82e3b03648 /sphinx/util
parentf59026865a8c658acbc6d5690c146f4be0851854 (diff)
downloadsphinx-git-67fb3d1157438d4fad25d3e2bf103df65f2ee4f6.tar.gz
Fix uncatched exception in get type hints
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/typing.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index 4b809e835..0fb03fad7 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -86,6 +86,9 @@ def get_type_hints(obj: Any, globalns: Dict = None, localns: Dict = None) -> Dic
except NameError:
# Failed to evaluate ForwardRef (maybe TYPE_CHECKING)
return safe_getattr(obj, '__annotations__', {})
+ except AttributeError:
+ # Failed to evaluate ForwardRef (maybe not runtime checkable)
+ return safe_getattr(obj, '__annotations__', {})
except TypeError:
# Invalid object is given. But try to get __annotations__ as a fallback for
# the code using type union operator (PEP 604) in python 3.9 or below.