-
Notifications
You must be signed in to change notification settings - Fork 9
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
Bug when mixing metaclasses w/ dataclassy
(Python 3.6 only)
#52
Comments
As I see it there are three possibilities that explain this (ranked in order of my guesses at likelihood):
I will take some time later to try to prove or disprove these theories, then hopefully fix the problem if it's with dataclassy, or find a workaround. |
MRE: from typing import Generic, TypeVar
from dataclassy import dataclass
X = TypeVar('X')
@dataclass
class T(Generic[X]):
... |
Diff: python/cpython@v3.6.14...v3.7.10 Unfortunately I can't find a way to link to the single file |
These seems relevant (in So, seems like in Python <=3.6 only you'd need to integrate |
Or... I can just drop 3.6 support from my library 😓 (which I've been meaning to anyways) |
Great find. The 3.7 release notes are a little more blunt:
This kind of makes me want to say it's a Anyway, this made me curious what the same paragraph looked like in 3.6. There I read:
This made me try implementing Edit: trying your suggestion of basing |
@biqqles thanks for looking into it, I've decided to just deprecate support for Python 3.6 in my framework. IPython was also giving me grief, so it made sense to do. |
In general, I was under the impression that such situations could be handled on the caller side by merging the separate (conflicting) metaclasses into one via inheritance, similar to how the above |
I found a bug when I attempt to mix metaclasses w/
dataclassy
. Here is what I was doing:Generic
has nothing to do withdataclassy'
mechanics, but I could see how the metaclass might interfere.This is the error it raises in Python 3.6 (from my CI):
For reference, here is the code that defines the
abstractdataclass
decorator:It works perfectly fine with Python 3.7+, I think related to this:
https://stackoverflow.com/questions/11276037/resolving-metaclass-conflicts
The text was updated successfully, but these errors were encountered: