matangover/mypy-vscode

Error importing plugin mypy_drf_plugin

sodiqit opened this issue · 1 comments

Hello!

My project has this structure:

- server
  - manage.py
  - app
     - settings.py
     - apps
     ...
- mypy.ini
...

Then extension was started, i got this error

Error importing plugin "mypy_drf_plugin.main": No module named 'mypy_drf_plugin'".

my mypy.ini:

[mypy]
warn_return_any = True
warn_unreachable = True
warn_unused_configs = True
check_untyped_defs = True
mypy_path = $MYPY_CONFIG_FILE_DIR/server
plugins = mypy_drf_plugin.main, ./server/custom_mypy_django_plugin.py

[mypy-configurations]
ignore_missing_imports = True

[mypy-app.apps.*.migrations.*]
ignore_errors = true

[mypy-app.apps.*.models]
disallow_any_explicit = false

[mypy.plugins.django-stubs]
django_settings_module = app.settings

I tried to change mypy_path in different ways, but still not working.

When I started mypy from terminal - work fine without error. Maybe you know the solution?

You need to make sure you run mypy with the Python interpreter in which mypy_drf_plugin is installed. You can do this in two ways:

  1. Set the mypy.dmypyExecutable setting to the full path to the mypy executable you want to use (which also must have the plugin installed in the same interpreter).
  2. Set mypy.runUsingActiveInterpreter if you want to run mypy using the active Python interpreter selected in VSCode. In that case make sure you select the interpreter which has mypy and the plugin installed.

You can adjust these settings globally (in your VSCode user settings) or for a single workspace (in the VSCode workspace settings).
For further info please see the Configuration section in the README.

Please let me know if you managed to solve it.