diff --git a/CHANGES b/CHANGES index 1a9383ff6..f12a1cb1b 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,9 @@ Features added Bugs fixed ---------- +* #7138: autodoc: ``autodoc.typehints`` crashed when variable has unbound object + as a value + Testing -------- diff --git a/sphinx/ext/autodoc/typehints.py b/sphinx/ext/autodoc/typehints.py index d7b4ee96b..77934dae5 100644 --- a/sphinx/ext/autodoc/typehints.py +++ b/sphinx/ext/autodoc/typehints.py @@ -46,7 +46,7 @@ def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any, annotation[param.name] = typing.stringify(param.annotation) if sig.return_annotation is not sig.empty: annotation['return'] = typing.stringify(sig.return_annotation) - except TypeError: + except (TypeError, ValueError): pass