Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-89529: disallowdefault_factory
for fields in dataclasses without__init__
#123070
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
gh-89529: disallowdefault_factory
for fields in dataclasses without__init__
#123070
Conversation
Uh oh!
There was an error while loading.Please reload this page.
picnixz commentedAug 17, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Should we consider this a bugfix or a feature actually? (to determine whether it requires backports or not, and update the issue's labels, which I tagged as 3.12, 3.13 and 3.14 + bug). |
Friendly ping@ericvsmith |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Technically, this is a breaking change. For example, it can break abstract dataclasses, which do not have__init__
on purpose. And their subclasses have__init__
s.
But, I also see that this bug can indeed happen.
So, I am not sure what is best.
Uh oh!
There was an error while loading.Please reload this page.
That's something I entirely missed. Maybe we can work out by checking if the class is abstract (namely, declared using Anyway, this solves one of my question about whether this is a bug fix or a feature. Since itcould break something, whether we want it or not, I'd prefer tagging it as a feature rather than a bug fix. |
@ericvsmith friendly ping |
I don't think I'll land this one because of this:
To be clear, it makes sense to indeed have an error but it's hard to know whether the error should be pre-caught as there are cases where it can be said that it would be unreachable (namely, we expect concrete classes to have their own So I'll mark this one as stale and a draft as I need to add tests for abstract classes as well.. |
Uh oh!
There was an error while loading.Please reload this page.
This is a proposal for rejecting
default_factory
on fields if the dataclass does not have an__init__
method.