Closed perey closed 3 years ago
extend_enum is broken for Flag and IntFlag under versions 3.0.0 and 3.1.0.
extend_enum
Flag
IntFlag
The following works in version 2.2.6:
>>> class FlagTest(Flag): # Or IntFlag ... NONE = 0 ... LOW = 1 ... MID = 2 ... >>> extend_enum(FlagTest, 'HIGH', 4) >>> FlagTest.LOW | FlagTest.HIGH <FlagTest.HIGH|LOW: 5> >>> FlagTest(5) <FlagTest.HIGH|LOW: 5>
It fails under later versions, both when OR'ing two values together and when constructing from a value:
ValueError: FlagTest: invalid value: 5\n given 0b0 101\n allowed 0b0 011
int
More detailed test cases attached, suitable for running with doctest:
doctest
$ python -m doctest testcases.txt
Thank you for the report, I'll look into it!
This is fixed in 3.1.1.
extend_enum
is broken forFlag
andIntFlag
under versions 3.0.0 and 3.1.0.The following works in version 2.2.6:
It fails under later versions, both when OR'ing two values together and when constructing from a value:
Flag
enums produce aValueError: FlagTest: invalid value: 5\n given 0b0 101\n allowed 0b0 011
IntFlag
enums produce no error but return anint
, not an enumMore detailed test cases attached, suitable for running with
doctest
: