biqqles / dataclassy

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

add another multiple inheritance test for member functions #38

Closed hroskes closed 3 years ago

hroskes commented 3 years ago

This test is for when a member is defined in the second base class but not directly in the first, when both inherit from the same grandparent class. It still fails post #30.

I can take a stab at a solution if you like.

biqqles commented 3 years ago

Drat, I knew I shouldn't have released so soon! I think I see why this is happening. Not sure how to fix yet.

biqqles commented 3 years ago

Turns out inheritance is really complicated!

biqqles commented 3 years ago

The only way to exactly match Python's behaviour, presumably, is to use MRO, but I really don't want to have to hackily create classes twice to get this.

biqqles commented 3 years ago

OK, it's fixable for user methods quite trivially. The trick is to keep the dict passed to type as bare-bones as possible so that Python does the heavy lifting. Magic methods will require a little more work, I think the obvious way to do this is keep two dictionaries, one recording the attributes in the chain so as not to mess with dict any more than is necessary. That is ugly, however.

biqqles commented 3 years ago

btw, got this test to pass a while ago but stuck at another failing test!

biqqles commented 3 years ago

Should be all fixed! The class dict is now not touched at all except to add generated methods.

hroskes commented 3 years ago

Thank you so much, this looks great and works for all my tests!

Is there any chance we can get a release on pypi?

biqqles commented 3 years ago

Yes, I can do that.

hroskes commented 3 years ago

Thank you!