New submission from Ethan Furman:
Consider:
--------
class AllEnum(Enum):
@classattr
def ALL(cls):
members = list(cls)
all_value = None
if members:
all_value = members[0]
for member in members[1:]:
all_value |= member
cls.ALL = all_value
return all_value
class Color(AllEnum, Flag):
RED = auto()
BLUE = auto()
GREEN = auto()
class IntColor(AllEnum, IntFlag):
RED = auto()
BLUE = auto()
GREEN = auto()
--------
The Color class works fine, but the IntColor fails. This is due to the way the
base data type and __new__ method is discovered. If we switch the order of the
bases
class IntColor(IntFlag, AllEnum)
it works, but having to put the mixin class last is both bizarre and unworkable
when the mixin should be overriding behavior.
----------
assignee: ethan.furman
components: Library (Lib)
messages: 287910
nosy: barry, eli.bendersky, ethan.furman
priority: normal
severity: normal
status: open
title: Enum: mixin classes don't mix well with already mixed Enums
versions: Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29577>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com