-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
When I define methods ('__or__', '__and__', '__xor__', '__ror__', '__rand__', '__rxor__', '__invert__')
directly in the class inheriting from enum.Flag, these methods are "added" (mro) to the members, however, if the method is defined in the mixin, the methods defined in enum.Flag are added (e.g. Flag.__or__). I would expect methods to be called from mixin.
from enum import Flag
class Mixin:
def __or__(self, value): ...
class MyFlag(Mixin, Flag):
pass
class MyFlag2(Flag):
def __or__(self, value): ...
print(MyFlag.__or__.__qualname__) # Flag.__or__, I would expect Mixin.__or__
print(MyFlag2.__or__.__qualname__) # MyFlag2.__or__ - GOODLines 610 to 619 in 0898354
| if Flag is not None and issubclass(enum_class, Flag): | |
| for name in ( | |
| '__or__', '__and__', '__xor__', | |
| '__ror__', '__rand__', '__rxor__', | |
| '__invert__' | |
| ): | |
| if name not in classdict: | |
| enum_method = getattr(Flag, name) | |
| setattr(enum_class, name, enum_method) | |
| classdict[name] = enum_method |
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error