Dataclass __init__
annotation eagerly evaluated
#128184
Labels
3.14
new features, bugs and security fixes
stdlib
Python modules in the Lib dir
topic-dataclasses
topic-typing
type-bug
An unexpected behavior, bug, or error
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: