Skip to content

Commit

Permalink
autodoc: Fix typing.get_type_hints() raises AttributeError for partia…
Browse files Browse the repository at this point in the history
…l objects
  • Loading branch information
tk0miya committed Aug 25, 2018
1 parent ea3d0b3 commit a3ae0ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sphinx/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,13 @@ def __init__(self, subject, bound_method=False, has_retval=True):
try:
self.annotations = typing.get_type_hints(subject) # type: ignore
except Exception as exc:
logger.warning('Invalid type annotation found on %r. Ingored: %r', subject, exc)
self.annotations = {}
if (3, 5, 0) <= sys.version_info < (3, 5, 3) and isinstance(exc, AttributeError):
# python 3.5.2 raises ValueError for partial objects.
self.annotations = {}
else:
logger.warning('Invalid type annotation found on %r. Ingored: %r',
subject, exc)
self.annotations = {}

if bound_method:
# client gives a hint that the subject is a bound method
Expand Down

0 comments on commit a3ae0ef

Please sign in to comment.