Skip to content

bpo-33188: Allow dynamic creation of generic dataclasses #6319

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

Merged

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Mar 31, 2018

As per PEP 560 the only way to dynamically create generic classes is by calling types.new_class. It turns out that some users are interested in dynamic creation of generic dataclasses. I propose to allow this, by using types.new_class() instead of type() in make_dataclass(). I propose to don't change the signature of the latter because of this rare use case (but it is not a strong opinion).

https://bugs.python.org/issue33188

Copy link
Member

@ericvsmith ericvsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

@ilevkivskyi ilevkivskyi merged commit 5a7092d into python:master Mar 31, 2018
@miss-islington
Copy link
Contributor

Thanks @ilevkivskyi for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@ilevkivskyi ilevkivskyi deleted the allow-dynamic-generic-dataclasses branch March 31, 2018 12:41
@bedevere-bot
Copy link

GH-6320 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 31, 2018
(cherry picked from commit 5a7092d)

Co-authored-by: Ivan Levkivskyi <[email protected]>
@Ricyteach
Copy link

Looks fantastic.

ilevkivskyi added a commit that referenced this pull request Apr 1, 2018
(cherry picked from commit 5a7092d)

Co-authored-by: Ivan Levkivskyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants