首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >mypy和django:错误:没有为"six“安装库存根(或与Python 3.9不兼容)

mypy和django:错误:没有为"six“安装库存根(或与Python 3.9不兼容)
EN

Stack Overflow用户
提问于 2021-08-16 03:13:23
回答 1查看 644关注 0票数 2

我已经为django项目设置了mypy

代码语言:javascript
运行
复制
[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

现在我得到了

代码语言:javascript
运行
复制
settings.py:21: error: Library stubs not installed for "six" (or incompatible with Python 3.9)

settings.py中,我正在导入six

那么如何解决这个错误呢?

我安装了django-stubs

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-19 02:03:33

在将types-six添加到您的环境后,尝试运行mypy:

pip install types-six

参见the note in the mypy docs。从mypy>=0.9开始,存根的行为发生了变化。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68797011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档