I'll send a PR shortly to add the runtime implementation. As with PEP 655, I'll hold off on documentation to make sure we get the runtime code in before the feature freeze in a few weeks.
Is there an intention to apply @dataclass_transform to dataclasses.dataclass itself?
I haven't considered it. For performance reasons dataclasses.py avoids importing typing, which presents a problem for doing it at runtime. We could apply the decorator in typeshed, probably based on feedback from type checker authors.
If it is decided to apply it in typeshed, the effect of the decorator (the __dataclass_transform__ attribute) can be added manually to dataclass, perhaps with some test to ensure consistency.
Activity
pythongh-91860: Add typing.dataclass_transform (PEP 681)
bluetech commented on Apr 23, 2022
Is there an intention to apply @dataclass_transform to dataclasses.dataclass itself?
JelleZijlstra commented on Apr 23, 2022
I haven't considered it. For performance reasons dataclasses.py avoids importing typing, which presents a problem for doing it at runtime. We could apply the decorator in typeshed, probably based on feedback from type checker authors.
bluetech commented on Apr 23, 2022
If it is decided to apply it in typeshed, the effect of the decorator (the __dataclass_transform__ attribute) can be added manually to dataclass, perhaps with some test to ensure consistency.
erictraut commented on Apr 23, 2022
I don't see any benefit to using @dataclass_transform with dataclass.dataclass. All existing type checkers already know about dataclass.
gh-91860: Add typing.dataclass_transform (PEP 681) (#91861)
pythongh-91860: documentation for typing.dataclass_transform
gh-91860: documentation for typing.dataclass_transform (#92768)
pythongh-91860: documentation for typing.dataclass_transform (pythonG…
gh-91860: documentation for typing.dataclass_transform (GH-92768)
gh-91860: Add docs for typing.dataclass_transform field specifier par…
hauntsaninja commented on Oct 10, 2022
I think all work here has been done