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

Can not fallback to bundled mypy with fromEnvironment #184

Open
Morikko opened this issue Oct 23, 2023 · 5 comments
Open

Can not fallback to bundled mypy with fromEnvironment #184

Morikko opened this issue Oct 23, 2023 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug needs PR

Comments

@Morikko
Copy link

Morikko commented Oct 23, 2023

  • Extension: 2023.4
  • Import strategy: fromEnvironment

When a python file is saved in an environment where mypy is not installed, there is this in the output:

2023-10-23 20:32:45.177 [info] Error while checking mypy executable:
Traceback (most recent call last):
  File "/home/eric/.vscode-oss/extensions/ms-python.mypy-type-checker-2023.4.0-universal/bundled/tool/lsp_server.py", line 102, in get_mypy_info
    first_line = result.stdout.splitlines(keepends=False)[0]
IndexError: list index out of range

2023-10-23 20:32:45.177 [info] [Trace - 8:32:45 PM] Received notification 'window/logMessage'.
2023-10-23 20:32:45.177 [info] [Error - 8:32:45 PM] Linting failed with error:
Traceback (most recent call last):
  File "/home/eric/.vscode-oss/extensions/ms-python.mypy-type-checker-2023.4.0-universal/bundled/tool/lsp_server.py", line 187, in _linting_helper
    version = get_mypy_info(settings).version
AttributeError: 'NoneType' object has no attribute 'version'

It works again if either mypy is installed in the environment or if import strategy is changed to useBundled.

@karthiknadig
Copy link
Member

@Morikko The initial part of the logs should have a sys.path. can you share that?

@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Oct 23, 2023
@karthiknadig karthiknadig self-assigned this Oct 23, 2023
@karthiknadig
Copy link
Member

We need to add a check if we can load mypy from environment. Currently we don't add the fallback, since we have to use PYTHONPATH to include the fallback path. If we add it before checking then python will always load the bundled mypy, even when using fromEnvironment.

@Morikko
Copy link
Author

Morikko commented Oct 24, 2023

2023-10-23 20:33:02.025 [info] sys.path used to run Server:
   /home/eric/OneDrive/Projects
   /home/eric/.vscode-oss/extensions/ms-python.mypy-type-checker-2023.4.0-universal/bundled/libs
   /home/eric/.vscode-oss/extensions/ms-python.mypy-type-checker-2023.4.0-universal/bundled/tool
   /home/eric/.pyenv/versions/3.10.12/lib/python310.zip
   /home/eric/.pyenv/versions/3.10.12/lib/python3.10
   /home/eric/.pyenv/versions/3.10.12/lib/python3.10/lib-dynload
   /home/eric/.local/lib/python3.10/site-packages
   /home/eric/.pyenv/versions/3.10.12/lib/python3.10/site-packages

@adehad
Copy link

adehad commented Nov 21, 2023

If any advice can be provided on the implementation I can give an attempt.

I think my perspective of Done would at least include:

  1. Message pop-up to user if mypy was not found with reason.

@martinpakosch
Copy link

Hey guys,

just wanna add my report here.

VSCode: 1.86.2
Extension: 2023.6.0
Import Strategy: fromEnvironment
Windows 11, Python 3.11

  1. When using fromEnvironment with a Py3.11 Environment without Mypy installed, the extension throws lots of tracebacks/errors. Fallback to bundled Mypy fails, there is no reporting/checking.
  2. When using useBundled, the extension seems to work fine.

See both full logs of a restart. Hope this gets fixed soon... :)

vscode-mypy-from-environment.log
vscode-mypy-use-bundled.log

Kind Regards,
Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug needs PR
Projects
None yet
Development

No branches or pull requests

4 participants