-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Dataclass __init__
annotation eagerly evaluated
#128184
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
Labels
3.14
bugs and security fixes
stdlib
Python modules in the Lib dir
topic-dataclasses
topic-typing
type-bug
An unexpected behavior, bug, or error
Comments
I will take a look, thanks for the report! |
Looks like this is the root cause: Lines 1162 to 1169 in f420bdd
I guess we can just ignore |
Ignoring NameError would be unfortunate, as it leaves the docstring empty. It would be more appropriate to evaluate the annotations in the SOURCE format, which |
sobolevn
added a commit
to sobolevn/cpython
that referenced
this issue
Dec 23, 2024
JelleZijlstra
added a commit
that referenced
this issue
Mar 4, 2025
Co-authored-by: sobolevn <[email protected]>
seehwan
pushed a commit
to seehwan/cpython
that referenced
this issue
Apr 16, 2025
…30815) Co-authored-by: sobolevn <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.14
bugs and security fixes
stdlib
Python modules in the Lib dir
topic-dataclasses
topic-typing
type-bug
An unexpected behavior, bug, or error
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
In 3.14, evaluation of annotations is deferred. Except, annotations for the
__init__
method of adataclass
are eagerly evaluated.Running this blows up with a scary stack trace:
AFAICT, this behavior is specific to
__init__
withdataclass
. I don't know what's intended, but as a user it feels like a bug.Adding
from __future__ import annotations
causes the problem to go away. But that shouldn't be required in 3.14.CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: