Mypy linting in VSCode Errors out with "Error constructing plugin instance of NewSemanalDRFPlugin"

859 views Asked by At

Trying to run Mypy linter in VSCode, always getting the same error in the output...

The root of the Django project and the workspace directory are different.

##########Linting Output - mypy##########
Error constructing plugin instance of NewSemanalDRFPlugin
  • mypy==0.770
  • mypy-extensions==0.4.3
  • django-stubs==1.5.0
  • djangorestframework-stubs==1.2.0

python3.8.5

Django with DRF

2

There are 2 answers

0
vi_me On

PYTHONPATH has to contain the root of your django project, or Mypy has to be called from the root of the django project.

0
Petr DlouhĂ˝ On

I have got this error when using django-stubs and djangorestframework-stubs together. It is probably bug in one of these libraries: https://github.com/typeddjango/django-stubs/issues/672

There is workaround to this (careful, because it can hide other errors). Run mypy with (the -O parameter disables assert checks):

python -O -m mypy application/