biqqles / dataclassy

A fast and flexible reimplementation of data classes
https://pypi.org/project/dataclassy
Mozilla Public License 2.0
82 stars 9 forks source link

make subclasses of DataClassMeta compatible with __init__ #13

Closed hroskes closed 3 years ago

hroskes commented 3 years ago

If there's not __init__ function defined, __new__ of DataClassMeta uses the actual mcs, which works well with subclasses because mcs is the actual subclass. However, if __init__ is defined, __new__ is hardcoded to use DataClassInit. This PR fixes that and instead creates a subclass of DataClassInit for each subclass of DataClassMeta, as needed.

biqqles commented 3 years ago

Thanks for this nice PR! Unfortunately, DataClassInit will shortly be removed when the changes discussed in #12 are merged, which will render this fix redundant. However the added tests might be useful in their own right. I will get back to you then.

hroskes commented 3 years ago

Thank you! I'll go ahead and close this.