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

grafanalib 0.7.1 trips with ImportError: cannot import name 'Literal' from 'typing' #650

Closed
amotl opened this issue Feb 14, 2024 · 4 comments

Comments

@amotl
Copy link
Contributor

amotl commented Feb 14, 2024

Hi there,

first things first: Thanks a stack for conceiving and maintaining grafanalib.

Looking at our CI run #7525555866, it trips like this:

ImportError while loading conftest '/home/runner/work/grafana-wtf/grafana-wtf/tests/conftest.py'.
tests/conftest.py:9: in <module>
    import grafanalib.core
.venv/lib/python3.7/site-packages/grafanalib/core.py:15: in <module>
    from typing import Literal
E   ImportError: cannot import name 'Literal' from 'typing' (/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/typing.py)
make: *** [Makefile:33: test] Error 4

We did not investigate about the root cause yet, just wanted to report here for a start.

With kind regards,
Andreas.

@amotl
Copy link
Contributor Author

amotl commented Feb 14, 2024

Most probably, Python 3.7 became unsupported without bumping to 0.8.0. That would be the easiest and most straight-forward explanation. We can't find anything in the changelog about it, though, and setup.py still lists Python 3.7. Is it true?

@davaffy
Copy link
Contributor

davaffy commented Feb 23, 2024

The reason is because of commit #622 which added the Literal import from typing.
That is not available in 3.7 thus given error.

The changelog says:

  • Correct type annotations for py37, py38

However, it breaks py37 functionality. Is it not possible to upgrade to 3.8, which has it (since 3.7 is EOL) ?

It's my opinion that either the Literal has to be changed in order to make it back compliant with 3.7 ( by using typing_extensions) or 3.7 should be removed as supported version and you will need to upgrade.

Ideally it should be the second one in my opinion

@amotl
Copy link
Contributor Author

amotl commented Feb 23, 2024

Dear @davaffy,

thanks for your quick reply.

[...] or 3.7 should be removed as supported version and you will need to upgrade.

Yeah, I think it will be fine to remove the compatibility definition in project metadata.

'Programming Language :: Python :: 3.7',

With kind regards,
Andreas.

@amotl
Copy link
Contributor Author

amotl commented Mar 16, 2024

Hi again,

on our downstream project grafana-wtf, we removed support for Python 3.7, and upgraded to grafanalib 0.7.1. Thanks!

On matters of grafanalib itself, we submitted a corresponding patch to fix the project metadata.

With kind regards,
Andreas.

@amotl amotl closed this as completed Apr 27, 2024
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

No branches or pull requests

2 participants