-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codetopic-enumtopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides
Description
Bug Report
Minimal repro on 3.11 (playground link):
from enum import ReprEnum, Flag
class MyFlag(ReprEnum, Flag): ...
Minimal repro on <=3.10 (playground link):
from enum import Enum, Flag
class ReprEnum(Enum): ...
class MyFlag(ReprEnum, Flag): ...
mypy output for both (with small line-number differences):
main.py:4: error: No base classes are allowed after "__main__.ReprEnum" [misc]
Expected Behavior
No error should be reported. This use of multiple inheritance works fine at runtime on 3.10 and 3.11. In fact, in 3.11, the source code for the enum
module in the stdlib uses exactly this inheritance structure:
class ReprEnum(Enum):
"""
Only changes the repr(), leaving str() and format() to the mixed-in type.
"""
# Much further down...
class IntFlag(int, ReprEnum, Flag, boundary=EJECT):
"""
Support for integer-based Flags
"""
Your Environment
I can reproduce this bug on mypy 0.940+ (0.940 was the first released version with @sobolevn's #12026, which introduced this error message).
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codetopic-enumtopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides