-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Add ability to set __slots__ in dataclasses #86435
Comments
I resisted adding the ability to set __slots__ in the first version of dataclasses, since it requires that instead of modifying an existing class, an entirely new class is returned. But I think this feature would be useful enough that I'm now willing to add it. I have the code ready, I just need to work on tests and documentation. |
Is the plan to allow an argument to auto-generate __slots__, or would this require repeating the names once in __slots__, and once for annotations and the like? |
It would figure it out automatically. See https://github.com/ericvsmith/dataclasses/blob/master/dataclass_tools.py for a decorator that already does this. I'll have a PR ready soon, I hope. |
As a moderately-heavy dataclass user I support this. :) |
Hi Eric, I tried to help you with this feature and have opened a PR. I thought that you are too busy to implement this feature, so that's why I decided to help you (It almost two months since your last message in this thread). |
Thanks for all of your work, Yurii. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: