Skip to content

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
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.

2 participants