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

[dataclass_transform] support default parameters #14580

Merged

Conversation

wesleywright
Copy link
Collaborator

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.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@NeilGirdhar
Copy link
Contributor

NeilGirdhar commented Feb 6, 2023

Could we add frozen_default as well to this pull request? It was added to CPython and typing-extensions:

@wesleywright
Copy link
Collaborator Author

Could we add frozen_default as well to this pull request? It was added to CPython and typing-extensions:

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 :)

@NeilGirdhar
Copy link
Contributor

Awesome! This pull request is huge for me. Really looking forward to it.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL 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! Comments are mostly nits about test cases.

test-data/unit/check-dataclass-transform.test Show resolved Hide resolved
test-data/unit/check-dataclass-transform.test Outdated Show resolved Hide resolved
test-data/unit/check-dataclass-transform.test Outdated Show resolved Hide resolved
test-data/unit/check-dataclass-transform.test Outdated Show resolved Hide resolved
test-data/unit/check-dataclass-transform.test Outdated Show resolved Hide resolved
test-data/unit/check-dataclass-transform.test Show resolved Hide resolved
mypy/nodes.py Outdated Show resolved Hide resolved
mypy/nodes.py Show resolved Hide resolved
mypy/semanal.py Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

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]

Copy link
Collaborator

@JukkaL JukkaL left a 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!

@JukkaL JukkaL merged commit 9e85f9b into python:master Feb 8, 2023
@ilinum ilinum mentioned this pull request Feb 9, 2023
17 tasks
JukkaL pushed a commit that referenced this pull request Feb 14, 2023
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.
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.

4 participants