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

Add typing_extensions to py3.7 deps for Literal #46

Merged
merged 2 commits into from
Sep 12, 2023
Merged

Add typing_extensions to py3.7 deps for Literal #46

merged 2 commits into from
Sep 12, 2023

Conversation

khaeru
Copy link
Contributor

@khaeru khaeru commented Sep 12, 2023

#44 added use of Literal, which is only available in Python ≥3.8. This raises ImportError, for instance here:

__________ ERROR collecting ixmp/tests/reporting/test_computations.py __________
ImportError while importing test module '/home/runner/work/ixmp/ixmp/ixmp/tests/reporting/test_computations.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ixmp/tests/reporting/test_computations.py:6: in <module>
    import pyam
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyam/__init__.py:12: in <module>
    from pyam.core import *
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyam/core.py:59: in <module>
    from pyam._ops import _op_data
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pyam/_ops.py:5: in <module>
    from iam_units import registry
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/iam_units/__init__.py:9: in <module>
    from .currency import configure_currency
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/iam_units/currency.py:6: in <module>
    from typing import Literal, Union
E   ImportError: cannot import name 'Literal' from 'typing' (/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/typing.py)

This commit imports the same from typing_extensions for Python 3.7.

Note that Python 3.7 reached EOL as of 2023-06-06, and we should probably drop support for it soon. This preserves support in the interim.

@khaeru khaeru self-assigned this Sep 12, 2023
@khaeru
Copy link
Contributor Author

khaeru commented Sep 12, 2023

Here is a successful CI run with Python 3.7, from a temporary commit that I'll now remove.

Suppress warnings from GitHub Actions.
@danielhuppmann
Copy link
Member

FYI, pyam 2.0 to be released thisxweek will drop support for all versions <3.10 - so I suggest to also remove all versions rather than adding clutter for legacy-support.

@khaeru
Copy link
Contributor Author

khaeru commented Sep 12, 2023

I suggest to also remove all versions rather than adding clutter for legacy-support.

iam-units is needed by message_data and the stack underneath it which support all actively maintained versions of Python (so that will include 3.8 until about 2024-10; 3.9 until 2025-10, etc.). But good to know that 3.7 isn't needed for use via pyam—that means I can come back and drop this 3.7 compat item once we finish removing CI against Python 3.7 in those packages.

@khaeru khaeru merged commit e22eab6 into main Sep 12, 2023
6 checks passed
@khaeru khaeru deleted the fix/py37 branch September 12, 2023 11:02
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.

2 participants