summaryrefslogtreecommitdiff
path: root/sphinx/util/inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/inspect.py')
-rw-r--r--sphinx/util/inspect.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index 541d5f5c5..82814e00d 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -322,19 +322,12 @@ class Signature:
raise
try:
- if ispartial(subject):
- # get_type_hints() does not support partial objects
- self.annotations = {} # type: Dict[str, Any]
- else:
- self.annotations = typing.get_type_hints(subject) # type: ignore
- except Exception as exc:
- if (3, 5, 0) <= sys.version_info < (3, 5, 3) and isinstance(exc, AttributeError):
- # python 3.5.2 raises ValueError for classmethod-ized partial objects.
- self.annotations = {}
- else:
- logger.warning('Invalid type annotation found on %r. Ignored: %r',
- subject, exc)
- self.annotations = {}
+ self.annotations = typing.get_type_hints(subject) # type: ignore
+ except Exception:
+ # get_type_hints() does not support some kind of objects like partial,
+ # ForwardRef and so on. For them, it raises an exception. In that case,
+ # we try to build annotations from argspec.
+ self.annotations = {}
if bound_method:
# client gives a hint that the subject is a bound method