I'm trying to install the mypy linter in Visual Studio Code version 1.53 on MacOS. I've never used a linter before, so I'm not sure what to expect, though I know it should be highlighting type errors and the such. I'm trying to get mypy working in the context of a Django app.
I followed these steps and restarted VS Code a few times, but the instructions don't seem to be working. I've also gone through the settings to ensure mypy linting is enabled and even tried changing the Python > Linting: Mypy Path setting to be the full path returned when doing which mypy; this also did not work.
Lastly, I installed this package from the VS Code marketplace: Mypy . I installed it through the marketplace in VS Code and followed the virtual environment instructions in the description.
django-stubs and mypy are both installed and I configured the mypy.ini file as suggested in the PyPI docs above.
I get the following error:
Error running mypy: mypy.ini:2:1: error: Error importing plugin 'mypy_django_plugin.main': No module named 'mypy_django_plugin'
How do I fix this error?
In VS Code, "mypy" is one of the python code analysis tools, we usually install and use it as follows:
Install it. (pip install mypy)
Check the installation: (pip show mypy)

Select "mypy": (F1, Python: Select Linter, mypy)

Run "mypy": (F1, Python: Run Linting)

Its effect:

Reference: Linting in VS Code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With