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

[v2024.4.0] Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' [Py3.7] #23179

Closed
matthuisman opened this issue Apr 4, 2024 · 5 comments
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@matthuisman
Copy link

matthuisman commented Apr 4, 2024

Behaviour

Cant load / run any pytests tests in v2024.4.0

Can see the breaking change coming in here:
v2024.2.1...v2024.4.0#diff-9a28b4b19fbb6331c15c76b4752852162785c0d521038cb637d8432901ebead2R13

should be importing from typing_extensions

Steps to reproduce:

  1. Try to run / load any pytest tests

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Traceback (most recent call last):
  File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\pytest\__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 192, in console_main
    code = main()
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 150, in main
    config = _prepareconfig(args, plugins)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 332, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\pluggy\_hooks.py", line 433, in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\pluggy\_manager.py", line 112, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\pluggy\_callers.py", line 133, in _multicall
    teardown[0].send(outcome)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\helpconfig.py", line 104, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\pluggy\_result.py", line 108, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\pluggy\_callers.py", line 80, in _multicall
    res = hook_impl.function(*args)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 1075, in pytest_cmdline_parse
    self.parse(args)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 1425, in parse
    self._preparse(args, addopts=addopts)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 1301, in _preparse
    self.pluginmanager.consider_preparse(args, exclude_only=False)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 709, in consider_preparse
    self.consider_pluginarg(parg)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 735, in consider_pluginarg
    self.import_plugin(arg, consider_entry_points=True)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 785, in import_plugin
    ).with_traceback(e.__traceback__) from e
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\config\__init__.py", line 781, in import_plugin
    __import__(importspec)
  File "C:\Users\mhuisman\envs\3.7\lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "c:\Users\mhuisman\.vscode\extensions\ms-python.python-2024.4.0\python_files\vscode_pytest\__init__.py", line 13, in <module>
    from typing import Any, Dict, List, Optional, Union, Literal, TypedDict  # noqa: E402
ImportError: Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' (c:\python37\lib\typing.py)

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 4, 2024
@matthuisman matthuisman changed the title ImportError: Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' (c:\python37\lib\typing.py) [v2024.4.0] ImportError: Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' (c:\python37\lib\typing.py) Apr 4, 2024
@matthuisman matthuisman changed the title [v2024.4.0] ImportError: Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' (c:\python37\lib\typing.py) [v2024.4.0 Py3.7] Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' Apr 4, 2024
@matthuisman matthuisman changed the title [v2024.4.0 Py3.7] Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' [v2024.4.0] Error importing plugin "vscode_pytest": cannot import name 'Literal' from 'typing' [Py3.7] Apr 4, 2024
@matthuisman
Copy link
Author

looks like PR: #22741 brought in these breaking changes

@matthuisman
Copy link
Author

@karthiknadig
Copy link
Member

Closing this.

Python 3.7 has been out of support for about 6 months. Underlying packages have moved out of 3.7 support. We will be migrating any remaining packages out of python 3.7 as well. You can pin the extension to 2024.2.1 or older for python 3.7 support.

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2024
@robert8138
Copy link

robert8138 commented Apr 14, 2024

@matthuisman, I am running into a similar issue on VScode. It seems like your PR was not accepted due to Python 3.7 reaching EOL. I think one solution is to pin the version of the extension to one that still supports Python 3.7, as suggested here, but I wonder if you have other workarounds?

@matthuisman
Copy link
Author

matthuisman commented Apr 14, 2024

revert / pin to old Python Extension version is the only solution it seems

Extensions -> Python -> Uninstall Down Arrow -> Install Another Version -> Select v2024.2.1

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants