Skip to content
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

Merged
merged 6 commits into from
Jul 3, 2023
Merged

Python 3.11 compatibility #107

merged 6 commits into from
Jul 3, 2023

Conversation

reuterbal
Copy link
Collaborator

@reuterbal reuterbal commented Jun 30, 2023

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 with int datatype instead of IntEnum to retain the original str-behaviour. (Changed with PEP 663)

Testing has been expanded to include Python 3.11

…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.
@github-actions
Copy link

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/107/index.html

@reuterbal reuterbal force-pushed the 69-python-3.11-compatibility branch from b3f67be to 62dd809 Compare June 30, 2023 11:10
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #107 (faaddcc) into main (615fdc5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #107   +/-   ##
=======================================
  Coverage   92.14%   92.14%           
=======================================
  Files          89       89           
  Lines       16483    16482    -1     
=======================================
  Hits        15188    15188           
+ Misses       1295     1294    -1     
Flag Coverage Δ
lint_rules 97.36% <ø> (+<0.01%) ⬆️
loki 92.09% <100.00%> (-0.01%) ⬇️
transformations 91.85% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
loki/types.py 86.40% <100.00%> (-0.14%) ⬇️

... and 2 files with indirect coverage changes

@reuterbal reuterbal force-pushed the 69-python-3.11-compatibility branch from 62dd809 to 69b7053 Compare June 30, 2023 12:42
This is due to PEP 663, which changed the string output to the basic integer value
@reuterbal reuterbal changed the title Python 3.11/3.12 compatibility Python 3.11 Jun 30, 2023
@reuterbal reuterbal changed the title Python 3.11 Python 3.11 compatibility Jun 30, 2023
@reuterbal reuterbal marked this pull request as ready for review June 30, 2023 14:20
@reuterbal reuterbal requested a review from mlange05 June 30, 2023 14:20
Copy link
Collaborator

@mlange05 mlange05 left a 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

@mlange05 mlange05 merged commit b9b5cd3 into main Jul 3, 2023
12 checks passed
@mlange05 mlange05 deleted the 69-python-3.11-compatibility branch July 3, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some metaclass conflict using loki.types.DataType and IntEnum with Python 3.11
2 participants