Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle attrs forward refs #345

Merged
merged 5 commits into from Apr 13, 2023
Merged

Conversation

znicholls
Copy link
Contributor

These seems to be an issue in the interaction between sphinx-autodoc-typehints and attrs. The current implementation evaluates guarded imports into obj.__globals__. However, something happens with attrs where obj.__globals__ is not the same for all objects within the same module, so the current implementation doesn't work.

As far as I can tell, the current implementation uses _TYPE_GUARD_IMPORTS_RESOLVED to avoid doing the imports more than is necessary. Simply removing this fixes the issue (see commit d611358). Alternately, an extra guard can be added to handle this attrs problem (see commit b68ea03).

As a final note, I don't know whether there is a problem with attrs which should be fixed (e.g. this issue seems related python-attrs/attrs#1021) or whether sphinx-autodoc-typehints needs to change to support attrs way of doing things.

@gaborbernat gaborbernat merged commit 09197b8 into tox-dev:main Apr 13, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants