Author ethan.furman
Recipients barry, eli.bendersky, ethan.furman
Date 2017-02-16.02:09:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487210984.19.0.348647583319.issue29577@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-02-16 02:09:44ethan.furmansetrecipients: + ethan.furman, barry, eli.bendersky
2017-02-16 02:09:44ethan.furmansetmessageid: <1487210984.19.0.348647583319.issue29577@psf.upfronthosting.co.za>
2017-02-16 02:09:44ethan.furmanlinkissue29577 messages
2017-02-16 02:09:43ethan.furmancreate