-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-36077: Update handling of defaulted fields #17322
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
Conversation
When a non-defaulted dataclass field follows a defaulted field, the behaviour has changed from raising a `TypeError` to making all arguments in `__init__` following the defaulted field keyword-only.
|
Looking forward to this! |
|
This is waiting on PEP 557 to be changed to allow this in the first place. I've submitted a feature-request in Discourse but there's been no discussion. |
|
We don't typically update PEPs when new features are added. |
|
Other way around: this pull-request is in direct contradiction with the PEP (it says that non-defaulted fields following defaulted fields cause a TypeError) |
|
It doesn't matter: PEPs are not meant to describe current behavior. |
|
For those wanting a patch: https://gist.github.com/EpicWink/195f43286e47c26eef7d5eb3263fee75 |
|
This is so useful! Thanks for the patch. |
|
Thank you for the patch. Any way to know if this will get into 3.10? |
|
There hasn't been much discussion in the mailing list entry I posted or the Discourse post, so it seems the core devs aren't interested. This suggestion from 2018 suggests allowing it in a backwards-compatible way by introducing a There is an existing solution in the mailing list: pass |
|
I've posted a different proposal in python-ideas at https://mail.python.org/archives/list/python-ideas@python.org/message/FI6KS4O67XDEIDYOFWCXMDLDOSCNSEYG/ I'd be interested in any opinions on it. Please comment on python-ideas for a wider audience. Thanks! |
|
This has been superseded by the more explicit solution to be included in Python 3.10 #24909 |
When a non-defaulted dataclass field follows a defaulted field, the behaviour has changed from raising a
TypeErrorto making all arguments in__init__following the defaulted field keyword-only.I'm not sold on the prettiness of the
versionchangedarea in the docs change: please comment.https://bugs.python.org/issue36077