-
-
Notifications
You must be signed in to change notification settings - Fork 513
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
Support dataclass transform #2049
base: master
Are you sure you want to change the base?
Conversation
For now, the proposal is a PoC before continuing I would like to know:
Also, I am not very familiar with |
Interesting, the method |
filter_ = cls.as_context().get_global_filter() | ||
# .values ordering is not guaranteed, at least not in | ||
# Python < 3.6, when dicts where not ordered, which is an | ||
# implementation detail anyway. |
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.
Python < 3.6 is not supported anymore.
Thanks a lot for taking this on!
100%. In general my acceptance of changes mostly depends on quality and test coverage. This looks very good so far. Feel free to "finish" it as far as you can and then I'll review it. I think there might be a few minor changes or discussions, but they shouldn't cost you a lot of time. Also don't waste too much time in making Mypy happy. You can also skip some things with
The complexity is unfortunately expected, with pretty much all typing changes. This change is on the very light side with only minor changes. My Mypy in Rust rewrite had to do way more to implement dataclass_transform (for doing proper type checking). Also note that this is a very low impact change, because it doesn't affect type inference and therefore won't affect performance. Happy to review it thoroughly once you think this is ready. I would be happy to see at least some of the CI green. But I'm happy to help out if there are issues. |
Goal
Support dataclass transform as specified: https://typing.readthedocs.io/en/latest/spec/dataclasses.html#dataclass-transform
Motivation
To have signature completions when using libraries like
Pydantic
orSQLalchemy
.Technical details
The decorator usage is very similar to the
dataclasses.dataclass
With a difference though: