Skip to content

exceptiongroup python version import check not compatible with poetry/virtualenv #10956

@sergioisidoro

Description

@sergioisidoro

I'm hitting a problem where using poetry (together with Tox testing matrix) will fail system checks introduced in #10209

Indeed the python version installed system wide is 3.11, but when testing with multiple python versions with Tox and virtual envs, this fails, because the system installed python and environment python is not the same. So

if sys.version_info[:2] < (3, 11):
    from exceptiongroup import BaseExceptionGroup

Will try to import BaseExceptionGroup even though it's being ran in Python <= 3.10

Is it possible to use env markers instead?
https://peps.python.org/pep-0508/#environment-markers

pytest = "^7.3.1"

Related:
python-poetry/poetry#758

Trace:

Traceback (most recent call last):
  File "/home/runner/.cache/pypoetry/virtualenvs/my-package-koh7-DBw-py3.10/bin/py.test", line 5, in <module>
    from pytest import console_main
  File "/home/runner/.cache/pypoetry/virtualenvs/my-package-koh7-DBw-py3.10/lib/python3.10/site-packages/pytest/__init__.py", line 5, in <module>
    from _pytest._code import ExceptionInfo
  File "/home/runner/.cache/pypoetry/virtualenvs/my-package-koh7-DBw-py3.10/lib/python3.10/site-packages/_pytest/_code/__init__.py", line 2, in <module>
    from .code import Code
  File "/home/runner/.cache/pypoetry/virtualenvs/my-package-koh7-DBw-py3.10/lib/python3.10/site-packages/_pytest/_code/code.py", line 60, in <module>
    from exceptiongroup import BaseExceptionGroup
ModuleNotFoundError: No module named 'exceptiongroup'
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions