FW-735: Pipeline failing - changes to Enum class in Python 3.12.10 #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It looks like 3.12.10 included some updates to the Enum class that is causing a new TypeError when setting up a new BitwiseFlag class.
See changelog: https://docs.python.org/release/3.12.10/whatsnew/changelog.html#python-3-12-10
Specifically: gh-108682: Enum: require names=() or type=... to create an empty enum using the functional syntax.
python/cpython#108682
Looks like stricter validation introduced in the enum module. Specifically, when instantiating an enumeration, Python now raises a TypeError if the class has no members defined. This change was implemented to prevent the creation of empty Flag enumerations without explicitly specifying that intention.
In our implementation, overriding the
__new__
class method, was interfering with how members are registered during enum class creation and leading to the above type error.Looks like fix is to just move validation done in
__new__
to a new place (__init_subclass__
).Note
This error was introduced in the Github pipeline, but was not showing up when running locally. Github was using the latest 3.12.10 Python release, whereas locally, was still using 3.12.3 (the latest version available in the apt deadsnakes ppa).
Had to install 3.12.10 locally by building the binaries manually.