Mypy и django: ошибка: Заглушки библиотеки не установлены для "six" (или несовместимы с Python 3.9)

Я установил mypy для проекта django

[mypy]
# The mypy configurations: https://mypy.readthedocs.io/en/latest/config_file.html
python_version = 3.9

check_untyped_defs = True
# disallow_any_explicit = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
ignore_errors = False
ignore_missing_imports = True
implicit_reexport = False
strict_optional = True
strict_equality = True
no_implicit_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
warn_no_return = True
mypy_path = /home/user/app/backend_django/src

plugins =
  mypy_django_plugin.main,
  mypy_drf_plugin.main

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

Теперь я получаю

settings.py:21: error: Library stubs not installed for "six" (or incompatible with Python 3.9)

В settings.py я импортирую six

Как устранить эту ошибку.

У меня установлено django-stubs

попробуйте запустить mypy после добавления types-six в ваше окружение:

pip install types-six

смотрите примечание в mypy docs. поведение заглушек изменилось начиная с mypy>=0.9.

Вернуться на верх