Real-time mypy linting disabled when using a plugin
See original GitHub issueEnvironment data
VSCode Version: 1.36.1
OS Version: macOS 10.14.5
Python version : 3.7.2
Type of virtual environment used : pyenv
viapipenv
Relevant/affected Python packages and their versions: N/A
Jedi or Language Server? (i.e. what is “python.jediEnabled”): Language Server ("python.jediEnabled": false
)
Expected behaviour
When mypy linting is enabled, VSCode should use the mypy.ini
and accordingly adopt any plugins that are used and installed, and display real-time warnings/errors in the editor.
Actual behaviour
When a plugin is used, all real-time checking is disabled.
Steps to reproduce:
- Enable Python and
mypy
linting in settings. - You will see errors (red squiggly line) if you define a function like this one:
def some_func() -> int:
return "some string"
- Install a mypy specific plugin. In my case it was
django-stubs
:
"python.linting.mypyEnabled": true,
"python.linting.mypyArgs": [
"--config-file=${workspaceFolder}/mypy.ini"
],
and the mypy.ini
file contents:
[mypy]
plugins = mypy_django_plugin.main
warn_unused_ignores = True
strict_optional = True
check_untyped_defs = True
follow_imports = silent
ignore_missing_imports = True
show_column_numbers = True
[mypy.plugins.django-stubs]
django_settings_module = my_app.settings.dev
When I run mypy
like so:
PYTHONPATH=${PYTHONPATH}:${PWD} mypy core/selectors.py
I get the correct errors, for example:
error: Incompatible return value type (got “int”, expected “Iterable[SomeModel]”)
But this is not highlighted in my editor in real-time/after save.
However, if I remove the plugin section from the mypy.ini
file, I do get an error in the editor:
Incompatible return value type (got “int”, expected “Iterable[SomeModel]”) mypy(error)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9
Top GitHub Comments
Thanks for cooperating. As I am not able to reproduce this, I would’ve to ask you to try few things.
~/.virtualenvs/myvirtualenv/bin/python -m mypy --config-file=/Users/myusername/Projects/project_root/mypy.ini ~/Projects/project_root/accounts/models.py
Try running this command in the terminal. I expect to see error
Error constructing plugin instance of NewSemanalDjangoPlugin
.PYTHONPATH
variable followed by the commandIf the second one works, it means extension is not initializing the
PYTHONPATH
environment variable like it should.Also, could you try a different interpreter and see if it reproduces the issue?
Try to choose a different Python version interpreter, with mypy installed. Maybe one without virtualenv.
python.pythonPath
setting gets set when you choose a python interpreter.