skip to Main Content

I have a Python project which uses mypy for type checking. The root of my project contains a setup.py and the package folder rise, along with a virtual environment folder venv. Both my shells and VSCode are set to use this virtual environment.

Most of the time, this setup works great: VSCode runs mypy every time I save and marks the errors with squiggles and in the Problems window. But for some reason, if I install the rise package in editable mode using pip install -e ., type checking in VSCode never finds any type errors. This does not happen if I install it in non-editable mode with pip install ., and if I uninstall the editable-mode package and reload the VSCode window, it immediately starts working normally again.


If I go into the Python output in the Output window, I see:

> ./venv/bin/python ~/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/linter.py -m mypy --show-column-numbers --strict ./rise/action.py

[...output from pylint, which is also configured and is working normally, clipped]

##########Linting Output - mypy##########

Success: no issues found in 1 source file

Yet if I copy and paste the command it’s echoing into the terminal, there is in fact an error:

$ ./venv/bin/python ~/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/linter.py -m mypy --show-column-numbers --strict ./rise/action.py
rise/action.py:140:12: error: Incompatible return value type (got "None", expected "bool")  [return-value]

I’m stumped as to how to troubleshoot this further, and I haven’t been able to find any reference to this issue anywhere on the web.

2

Answers


  1. Chosen as BEST ANSWER

    I ended up installing the Mypy extension for Visual Studio Code and removing mypy from my linters configuration. The extension doesn't suffer from this bug (or misconfiguration, or whatever it is), and it runs faster to boot.


  2. I’ve run into a similar issue. Perhaps an explicit setting of severity in the settings.json file should help:

    "python.linting.mypyCategorySeverity.error":"Warning"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search