mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9509 from yanyongyu/bugfix/get-type-hints
[autodoc] Fix uncatched exception in get type hints
This commit is contained in:
commit
e344c3b718
@ -86,6 +86,9 @@ def get_type_hints(obj: Any, globalns: Dict = None, localns: Dict = None) -> Dic
|
|||||||
except NameError:
|
except NameError:
|
||||||
# Failed to evaluate ForwardRef (maybe TYPE_CHECKING)
|
# Failed to evaluate ForwardRef (maybe TYPE_CHECKING)
|
||||||
return safe_getattr(obj, '__annotations__', {})
|
return safe_getattr(obj, '__annotations__', {})
|
||||||
|
except AttributeError:
|
||||||
|
# Failed to evaluate ForwardRef (maybe not runtime checkable)
|
||||||
|
return safe_getattr(obj, '__annotations__', {})
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# Invalid object is given. But try to get __annotations__ as a fallback for
|
# 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.
|
# the code using type union operator (PEP 604) in python 3.9 or below.
|
||||||
|
Loading…
Reference in New Issue
Block a user