-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3.11 compatibility #107
Conversation
…thon 3.11 Enum values do now have the type of mixin classes, which DataType is for BasicType. Consequently, instantiation fails and the class does not work in Python 3.11 and later. Some of that behaviour is also buggy, see the discussion in https://discuss.python.org/t/inconsistent-behavior-with-python-3-11-enum-mixin-class-behavior/24613/4 Removing the init routine restores the desired behaviour, although we do now no longer ensure that the base class has not been instantiated directly.
Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/107/index.html |
b3f67be
to
62dd809
Compare
Codecov Report
@@ Coverage Diff @@
## main #107 +/- ##
=======================================
Coverage 92.14% 92.14%
=======================================
Files 89 89
Lines 16483 16482 -1
=======================================
Hits 15188 15188
+ Misses 1295 1294 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
62dd809
to
69b7053
Compare
This is due to PEP 663, which changed the string output to the basic integer value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, many thanks! If someone could convince the over-zealous codecov checker, it'd be GTG
A small change to achieve compatibility with Python 3.11. Reason is that since 3.11, Enum values do get the type of all mixin base classes and because of the composing nature how this is done, the assertion we had there triggered.
See also https://discuss.python.org/t/inconsistent-behavior-with-python-3-11-enum-mixin-class-behavior/24613/4
I had to also use a plain
Enum
withint
datatype instead ofIntEnum
to retain the originalstr
-behaviour. (Changed with PEP 663)Testing has been expanded to include Python 3.11