Skip to content

Fix @auto_docstring crash with from __future__ import annotations in _process_kwargs_parameters#45105

Open
rpathade wants to merge 4 commits intohuggingface:mainfrom
rpathade:fix/auto-docstring-string-annotations
Open

Fix @auto_docstring crash with from __future__ import annotations in _process_kwargs_parameters#45105
rpathade wants to merge 4 commits intohuggingface:mainfrom
rpathade:fix/auto-docstring-string-annotations

Conversation

@rpathade
Copy link
Copy Markdown

What does this PR do?

Fixes _process_kwargs_parameters crashing with AttributeError when @auto_docstring is applied in a module that uses from __future__ import annotations.

Fixes #45103

Root cause

from __future__ import annotations defers all annotations to strings at runtime. _process_kwargs_parameters accessed kwarg_param.annotation.__args__ directly, which fails when the annotation is a string instead of a type object:

# annotation is "Optional[IsaacKwargs]" (str), not the actual type — crashes here
if kwarg_param.annotation.__args__[0].__name__ not in BASIC_KWARGS_TYPES:

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.

[auto_docstring] _process_kwargs_parameters crashes with AttributeError when module uses from __future__ import annotations

1 participant