autodoc: Fix typing.get_type_hints() raises AttributeError for partial objects

This commit is contained in:
Takeshi KOMIYA 2018-08-25 10:20:53 +09:00
parent ea3d0b3768
commit 18f107b0bc

View File

@ -360,7 +360,12 @@ class Signature(object):
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)
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: