Closed
Description
Current problem
The following behaviour seemed confusing:
>>> from enum import IntFlag
>>> class TestFlag(IntFlag):
... A = 1
... B = 2
... C = 3
...
>>> print([i for i in TestFlag])
[<TestFlag.A: 1>, <TestFlag.B: 2>]
(note that this is an IntFlag
, not an IntEnum
)
Desired solution
The reason this happens is that Flag
types are designed for setwise operations (bitwise operations, in the case of IntFlag
), and, because C
can be composed of A
and B
...
>>> int(TestFlag.A | TestFlag.B)
3
>>> int(TestFlag.C)
3
...internally, IntFlag
considers C
to be an alias -- and doesn't include it when iterating over the members of the flag.
A pylint
message something along the lines of implicit-flag-overlap
could be emitted by a relevant checker when scanning the class declaration.
Additional context
No response