You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incompatible definition of methods reported when using multiple inheritance #9319
mypy-error.py:6: error: Definition of "__xor__" in base class "int" is incompatible with definition in base class "Flag"
mypy-error.py:6: error: Definition of "__or__" in base class "int" is incompatible with definition in base class "Flag"
mypy-error.py:6: error: Definition of "__and__" in base class "int" is incompatible with definition in base class "Flag"
Found 3 errors in 1 file (checked 1 source file)
Comments
The error messages go away when
Not using multiple inheritance, i.e. class D(enum.IntFlag) instead of class D(C, enum.IntFlag).
Alternatively to adding # type: ignore, another workaround is to redefine the problematic methods in the subclass with a simple call to super. That's not pretty either but that prevents ignoring the whole inheritance.
Activity
JukkaL commentedon Sep 11, 2020
This looks like a bug in type checking classes with multiple inheritance. You can use
# type: ignoreon line 6 as a workaround for now.mypy bug workaround (python/mypy#9319)
Add-response-model (#64)
add ignore for mypy multiple inheritence bug: python/mypy#9319
adambirds commentedon Jan 30, 2023
Is this related to this issue here? Is there any idea when a proper fix will be available?
benbovy commentedon Sep 7, 2023
Is there any update on this?
Alternatively to adding
# type: ignore, another workaround is to redefine the problematic methods in the subclass with a simple call tosuper. That's not pretty either but that prevents ignoring the whole inheritance.Fix attribute type resolution with multiple inheritance (python#18415)
Add-response-model (#64)
Revert "dirty workaround for mypy 1.5 error"