Skip to content
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

Implement PEP 681 (@dataclass_transform) #91860

Closed
JelleZijlstra opened this issue Apr 23, 2022 · 5 comments
Closed

Implement PEP 681 (@dataclass_transform) #91860

JelleZijlstra opened this issue Apr 23, 2022 · 5 comments
Labels
topic-typing type-feature A feature request or enhancement

Comments

@JelleZijlstra
Copy link
Member

The SC has given the green light to implement PEP 681 in Python 3.11: https://mail.python.org/archives/list/typing-sig@python.org/thread/JWMSWJ6JZJNNG3JKPBYDMQUUHZFD2FZL/

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.

cc @debonte @erictraut

@JelleZijlstra JelleZijlstra added type-feature A feature request or enhancement topic-typing labels Apr 23, 2022
JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this issue Apr 23, 2022
Copied from typing-extensions (python/typing#1054, python/typing#1120).

Documentation is intentionally omitted, so we can focus on getting the
runtime part in before the feature freeze.
@bluetech
Copy link

Is there an intention to apply @dataclass_transform to dataclasses.dataclass itself?

@JelleZijlstra
Copy link
Member Author

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.

@bluetech
Copy link

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
Copy link
Contributor

I don't see any benefit to using @dataclass_transform with dataclass.dataclass. All existing type checkers already know about dataclass.

JelleZijlstra added a commit that referenced this issue Apr 26, 2022
Copied from typing-extensions (python/typing#1054, python/typing#1120).

Documentation is intentionally omitted, so we can focus on getting the
runtime part in before the feature freeze.
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 13, 2022
JelleZijlstra pushed a commit that referenced this issue May 20, 2022
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 20, 2022
…H-92768)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit f20a6a5)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
miss-islington added a commit that referenced this issue May 20, 2022
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit f20a6a5)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
ambv pushed a commit that referenced this issue Jun 28, 2022
…ams (GH-94354) (GH-94372)

(cherry picked from commit 81ac9ac)

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
@hauntsaninja
Copy link
Contributor

hauntsaninja commented Oct 10, 2022

I think all work here has been done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-typing type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants