-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Combine multiple classes #1392
Comments
@dkrikun Given that Hynek doesn't reaaallly like On the other hand, you can relatively easily write your own function that combines the fields of two attrs classes and passes them to I did something similar for Typed Settings, maybe you can just copy and adjust this code (which was handcrafted by a real human): https://gitlab.com/sscherfke/typed-settings/-/blob/24.6.0/src/typed_settings/cls_attrs.py?ref_type=tags#L387-487 ;-) |
Gotta enjoy the human part while it still exists, thanks ;) |
Another problem here is that there's currently no way to make this in any way work with type checkers. So merging a feature like this to attrs proper would only add another cause for a flurry of issues about PyCharm/Pyright/Mypy complaining and us not being able to do anything about it at all. |
Is it possible to combine two (or more) class declarations into one?
This should be similar to multiple inheritance I guess, but should work with slots.
For example:
One could argue, that composition should be used instead, but I think it could be nicer to be able to access attributes without nesting.
Is there something like this in attrs, or how it could be done using existing api?
The text was updated successfully, but these errors were encountered: