-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
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.
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.
Do you want me to remove the sort or just the comment ?
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. |
About attrs. It uses But users with an older attrs would lose completions if they would use a newer version of jedi. Sticking to an old jedi version would avoid that. Should I drop attrs hooks or keep it ? |
This comment was marked as resolved.
This comment was marked as resolved.
Good question. I think that the tests should probably still work. I don't care if an older attr version doesn't work anymore, as long as the most recent versions work. |
Not sure what to do. |
If you pull in the changes from |
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
.Features
init=False
then the parameters are ignored.Technical details
The decorator usage is very similar to the
dataclasses.dataclass
With a difference though: