ethanfurman / aenum

Advanced Enumerations for Python
183 stars 14 forks source link

Regression - extend_enum broken for Flag and IntFlag as of version 3.0.0 #13

Closed perey closed 3 years ago

perey commented 3 years ago

extend_enum is broken for Flag and IntFlag under versions 3.0.0 and 3.1.0.

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:

More detailed test cases attached, suitable for running with doctest:

$ python -m doctest testcases.txt
ethanfurman commented 3 years ago

Thank you for the report, I'll look into it!

ethanfurman commented 3 years ago

This is fixed in 3.1.1.