From 18f107b0bccd8fd01d2f17ec1f47cbf09b80ed6f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 25 Aug 2018 10:20:53 +0900 Subject: [PATCH] autodoc: Fix typing.get_type_hints() raises AttributeError for partial objects --- sphinx/util/inspect.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index f4c3461ea..1d038747b 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -360,8 +360,13 @@ 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) - 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