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

Update the lowest python version to 3.11 to include StrEnum #3178

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samuell
Copy link
Contributor

@samuell samuell commented Apr 25, 2024

StrEnum is used in multiple places including tests and alembic scripts and was introduced in Python 3.11 (See https://docs.python.org/3/library/enum.html#enum.StrEnum ).

This currently breaks using the poetry environment if the user accdientally is using a python version lower than 3.11 in poetry, causing errors complaning that StrEnum is not found.

Reproducing the error:

  1. Set poetry to use python 3.10:
poetry env use 3.10
  1. Check out the cg repository and cd into it:
git clone [email protected]:Clinical-Genomics/cg.git
cd cg
  1. Install poetry dependencies:
poetry install
  1. Start the poetry shell:
poetry shell
  1. Run pytest
pytest

You will now see errors like below:

$ pytest
ImportError while loading conftest '/home/shl/proj/23/01-jasen/cg/tests/conftest.py'.
tests/conftest.py:18: in <module>
    from cg.apps.crunchy import CrunchyAPI
cg/apps/crunchy/__init__.py:3: in <module>
    from .crunchy import CrunchyAPI
cg/apps/crunchy/crunchy.py:12: in <module>
    from cg.apps.crunchy import files
cg/apps/crunchy/files.py:8: in <module>
    from cg.constants.constants import FileFormat
cg/constants/__init__.py:8: in <module>
    from cg.constants.constants import (
cg/constants/constants.py:3: in <module>
    from enum import IntEnum, StrEnum
E   ImportError: cannot import name 'StrEnum' from 'enum' (/home/shl/opt/mc3/lib/python3.10/enum.py)

This is fixed though when doing:

  1. Removing the old poetry env (warning, make sure you know what you are doing!):
rm -rf $(dirname $(dirname $(which python)))
  1. Setting poetry to use python 3.11
poetry env use 3.11
  1. Installing the poetry dependencies anew:
poetry install
  1. Starting the poetry shell again
poetry shell
  1. Running the pytest
pytest

(Then I get other errors, but at least different ones 🙂 ):

[...]
  File "/home/shl/.pyenv/versions/3.11.8/lib/python3.11/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

Description

Changed

  • Changed the lowest allowed python version from 3.9 to 3.11 in pyproject.toml

How to prepare for test

  • TBC

How to test

  • Do ...

Expected test outcome

  • Check that ...
  • Take a screenshot and attach or copy/paste the output.

Review

  • Tests executed by
  • "Merge and deploy" approved by
    Thanks for filling in who performed the code review and the test!

This version is a

  • MAJOR - when you make incompatible API changes
  • MINOR - when you add functionality in a backwards compatible manner
  • PATCH - when you make backwards compatible bug fixes or documentation/instructions

Implementation Plan

  • Document in ...
  • Deploy this branch on ...
  • Inform to ...

StrEnum is used in multiple places including tests and alembic scripts and was introduced in Python 3.11

See https://docs.python.org/3/library/enum.html#enum.StrEnum
Copy link

sonarcloud bot commented Apr 25, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

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.

1 participant