-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[dataclass_transform] support default parameters #14580
[dataclass_transform] support default parameters #14580
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Could we add |
I noticed that Pyright had support for that, but I was holding off adding it here until I determined where it was made “official” (just for thoroughness’s sake). The CPython PR is pretty canonical so I’ll add support tomorrow :) |
Awesome! This pull request is huge for me. Really looking forward to it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Looks good! Comments are mostly nits about test cases.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/dataclasses.py:108: error: "field_specifiers" support is currently unimplemented [misc]
+ pydantic/dataclasses.py:124: error: "field_specifiers" support is currently unimplemented [misc]
+ pydantic/dataclasses.py:175: error: "field_specifiers" support is currently unimplemented [misc]
|
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.
Thanks for the updates!
Follow up on some of the recurring feedback from #14580 and #14657. There are many error messages similar to `X must be True or False.` in MyPy. This commit updates them all to: - remove the dangling period for consistency with other error messages - clarify that we need a `True` or `False` literal - use the `literal-required` error code for consistency with other literal errors This should have no impact outside of error message formatting.
PEP 681 defines several parameters for
typing.dataclass_transform
. This commit adds support for collecting these arguments and forwarding them to the dataclasses plugin. For this first iteration, only the*_default
parameters are supported;field_specifiers
will be implemented in a separate commit, since it is more complicated.