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

astroid 2.13.0 uses typing_extensions on Python 3.10 but does not require it there #1942

Closed
andy-maier opened this issue Jan 8, 2023 · 6 comments · Fixed by #1941
Closed

Comments

@andy-maier
Copy link

andy-maier commented Jan 8, 2023

Steps to reproduce

In a virtual Python environment with Python 3.10 that does not have typing_extensions installed:

  1. pip install pylint
  2. pylint --version

This only happens on Python 3.10, not on <=3.9 or 3.11

Test runs with different OS and Python versions: https://github.com/pywbem/nocaselist/actions/runs/3864593150

Current behavior

Pylint fails with astroid trying to import from typing_extensions. However, typing_extensions is not installed because astroid 2.13.0 does not require it in its distribution on Python 3.10:

$ pylint --version
Traceback (most recent call last):
  File "/Users/maiera/virtualenvs/nocaselist310/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/__init__.py", line 32, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/lint/__init__.py", line 19, in <module>
    from pylint.config.exceptions import ArgumentPreprocessingError
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/config/__init__.py", line 25, in <module>
    from pylint.config.arguments_provider import UnsupportedAction
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/config/arguments_provider.py", line 15, in <module>
    from pylint.config.arguments_manager import _ArgumentsManager
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/config/arguments_manager.py", line 25, in <module>
    from pylint import utils
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/utils/__init__.py", line 9, in <module>
    from pylint.utils.ast_walker import ASTWalker
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 13, in <module>
    from astroid import nodes
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/astroid/__init__.py", line 46, in <module>
    from astroid import inference, raw_building
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/astroid/inference.py", line 18, in <module>
    from astroid import bases, constraint, decorators, helpers, nodes, protocols, util
  File "/Users/maiera/virtualenvs/nocaselist310/lib/python3.10/site-packages/astroid/constraint.py", line 19, in <module>
    from typing_extensions import Self
ModuleNotFoundError: No module named 'typing_extensions'

Expected behavior

should not fail

Looking at the requirement for typing_extensions in pyproject.toml and at the import in astroid/constraints.py, it seems that a mismatch of the Python version between those two for Python 3.10 is the reason for the issue.

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

This command does not work on Python 3.10 because of missing typing_extensions.
When installing typing_extensions manually, it shows:

2.13.0

pipdeptree -p pylint output

pylint==2.15.9
  - astroid [required: >=2.12.13,<=2.14.0-dev0, installed: 2.13.0]
    - lazy-object-proxy [required: >=1.4.0, installed: 1.9.0]
    - wrapt [required: >=1.11,<2, installed: 1.14.1]
  - dill [required: >=0.2, installed: 0.3.6]
  - isort [required: >=4.2.5,<6, installed: 5.11.4]
  - mccabe [required: >=0.6,<0.8, installed: 0.7.0]
  - platformdirs [required: >=2.2.0, installed: 2.6.2]
  - tomli [required: >=1.1.0, installed: 2.0.1]
  - tomlkit [required: >=0.10.1, installed: 0.11.6]
@andy-maier andy-maier changed the title astroid 2.13.0 uses typing_extensions but does not require it astroid 2.13.0 uses typing_extensions on Python 3.10 but does not require it there Jan 8, 2023
@DanielNoord
Copy link
Collaborator

@Pierre-Sassoulas Shall we release a hot fix and yank 2.13.0? This seems truly broken.

@Pierre-Sassoulas
Copy link
Member

Yeah definitely. I'm on mobile right now so I can't release. Also thé maintenance branche is not ready sorry. But we Can release directly from main in this case

@DanielNoord
Copy link
Collaborator

I'm on mobile as well. No rush as it is the weekend and we haven't release pylint yet 😄

@mathiascode
Copy link

mathiascode commented Jan 8, 2023

This doesn't seem to be fixed yet. typing-extensions isn't installed on Python 3.10 due to the Python version check here: https://github.com/PyCQA/astroid/blob/82b80d9c588e394afe9c61165b484a0944a4b352/pyproject.toml#L39

Sample job output:
https://github.com/nicotine-plus/nicotine-plus/actions/runs/3863997823/jobs/6591410278

@Pierre-Sassoulas
Copy link
Member

Thank you for the head up @mathiascode, it was due to typing-extensions also being present in our tests requirements with laxer constraints hiding the issue, see #1944

@mathiascode
Copy link

Thanks for the fix, much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants