You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐛 fix(resolver): survive PEP 649 lazy annotation evaluation errors (#713)
Documenting a function annotated with a non-subscriptable generic such
as `DiGraph[int]` from `networkx` crashes the whole Sphinx build on
Python 3.14. PEP 649 makes annotations lazy, so the module imports fine,
but the first `__annotations__` access runs `__annotate__` and the
`TypeError` from the annotation expression escapes through
`process_signature`. The existing guards only caught the `NameError`
raised by `TYPE_CHECKING`-only names.
The guards in `process_signature` and `collect_documented_type_aliases`
now cover the errors annotation expressions raise at runtime:
`NameError`, `TypeError` and `AttributeError`. 🛟 When
`typing.get_type_hints` raises `TypeError`, the resolver retries with
`annotationlib`'s `FORWARDREF` format, which wraps unevaluatable
expressions in `ForwardRef` proxies, so the parameter still renders as
its source text (`g (DiGraph[int])`) instead of being dropped.
`RecursionError` keeps returning no hints because re-evaluating after a
recursion blowup is unsafe.
Behavior on Python 3.13 and earlier is unchanged; eager annotation
evaluation raises at import time there, before this code runs.
Fixes#712.
0 commit comments