Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 whereobj.__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.