Skip to content

Commit

Permalink
Merge pull request #9509 from yanyongyu/bugfix/get-type-hints
Browse files Browse the repository at this point in the history
[autodoc] Fix uncatched exception in get type hints
  • Loading branch information
tk0miya committed Jul 30, 2021
2 parents ee612ff + 4cceeae commit e344c3b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sphinx/util/typing.py
Expand Up @@ -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.
Expand Down

0 comments on commit e344c3b

Please sign in to comment.