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
Enums: false-positive "No base classes allowed after ReprEnum" error #12787
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:
classReprEnum(Enum):
""" Only changes the repr(), leaving str() and format() to the mixed-in type. """# Much further down...classIntFlag(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).
changed the title [-]Enums: false-positive "No base classes allowed" error[/-][+]Enums: false-positive "No base classes allowed after `Enum`" error[/+]on May 14, 2022
changed the title [-]Enums: false-positive "No base classes allowed after `Enum`" error[/-][+]Enums: false-positive "No base classes allowed after `ReprEnum`" error[/+]on May 14, 2022
Activity
[-]Enums: false-positive "No base classes allowed" error[/-][+]Enums: false-positive "No base classes allowed after `Enum`" error[/+][-]Enums: false-positive "No base classes allowed after `Enum`" error[/-][+]Enums: false-positive "No base classes allowed after `ReprEnum`" error[/+]AlexWaygood commentedon May 14, 2022
An even simpler repro that doesn't involve
enum.Flag:This works fine at runtime, but mypy says:
Fix false-positive error on multiple enum base classes (#12963)
Fix false-positive error on multiple enum base classes (python#12963)