-
Notifications
You must be signed in to change notification settings - Fork 18
Description
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:
Line 909 in 523f7d4
| and is_single_bit(value) |
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.