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): resolve forward refs in nested attrs classes (#646)
Nested attrs classes that reference sibling types via their parent (e.g.
`Outer.Foo` inside `Outer.Bar`) fail with `NameError: name 'Outer' is
not defined` during Sphinx doc generation. 🐛 This happens because
attrs-generated `__init__` methods have `__globals__` pointing to attrs
internals rather than the defining module's namespace, so the parent
class can't be found for forward reference resolution.
The fix walks the full `__qualname__` chain using `inspect.getmodule` to
obtain the correct module namespace, resolving each ancestor class and
adding it to `localns`. This falls back to `obj.__globals__` for dynamic
modules where `inspect.getmodule` returns `None`, preserving
compatibility with PEP 695 type parameter resolution.
Fixes#643
0 commit comments