From 67fb3d1157438d4fad25d3e2bf103df65f2ee4f6 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Thu, 29 Jul 2021 12:03:03 +0800 Subject: [PATCH] Fix uncatched exception in get type hints --- sphinx/util/typing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index 4b809e835a0..0fb03fad74f 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.