diff --git a/sphinx_autodoc_typehints.py b/sphinx_autodoc_typehints.py index e9e6ce5c..c4c00d3e 100644 --- a/sphinx_autodoc_typehints.py +++ b/sphinx_autodoc_typehints.py @@ -204,7 +204,7 @@ def get_all_type_hints(obj, name): try: rv = get_type_hints(obj) - except (AttributeError, TypeError, RecursionError): + except (AttributeError, TypeError, RecursionError, KeyError): # Introspecting a slot wrapper will raise TypeError, and and some recursive type # definitions will cause a RecursionError (https://github.com/python/typing/issues/574). pass @@ -225,7 +225,7 @@ def get_all_type_hints(obj, name): try: rv = get_type_hints(obj) - except (AttributeError, TypeError): + except (AttributeError, TypeError, KeyError): pass except NameError as exc: logger.warning('Cannot resolve forward reference in type annotations of "%s": %s',