1

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

sobolevn
  • 16,714
  • 6
  • 62
  • 60
vi_me
  • 373
  • 4
  • 17

2 Answers2

0

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

vi_me
  • 373
  • 4
  • 17
0

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/
Petr DlouhĂ˝
  • 857
  • 9
  • 11