When using the Flag enum class, entries that are composite with other entries omits them from the list of all enum entries, even if all entries are unique.
from aenum import Flag, auto
class SBInterfaceType(Flag):
ALL = 0
UNKNOWN = auto()
URL = auto()
PROD = auto()
DEV = auto()
S3 = auto()
T3 = auto() | PROD | S3
[i for i in SBInterfaceTypes]
Result:
[<SBInterfaceTypes.UNKNOWN: 1>, <SBInterfaceTypes.URL: 2>, <SBInterfaceTypes.PROD: 4>, <SBInterfaceTypes.DEV: 8>, <SBInterfaceTypes.S3: 16>]
T3 is missing
T3 does appear in SBInterfaceType's _member_map_ but not in its _member_names_. Because it's not in the member_names, the Flag class's __iter__ method will skip it (it loops through all member_names to use as a key look up for member_map).
A fix that worked for me was to remove the is_single_bit check in the elif check in the following line of code:
Though I'm not sure what the ramifications outside my use-case are for this change, or why that check was done in the first place.
When using the Flag enum class, entries that are composite with other entries omits them from the list of all enum entries, even if all entries are unique.
Result:
[<SBInterfaceTypes.UNKNOWN: 1>, <SBInterfaceTypes.URL: 2>, <SBInterfaceTypes.PROD: 4>, <SBInterfaceTypes.DEV: 8>, <SBInterfaceTypes.S3: 16>]T3 is missing
T3 does appear in SBInterfaceType's
_member_map_but not in its_member_names_. Because it's not in the member_names, the Flag class's__iter__method will skip it (it loops through all member_names to use as a key look up for member_map).A fix that worked for me was to remove the is_single_bit check in the elif check in the following line of code:
aenum/aenum/_enum.py
Line 909 in 523f7d4
Though I'm not sure what the ramifications outside my use-case are for this change, or why that check was done in the first place.