gpt4 book ai didi

django - mypy 和 django : error: Library stubs not installed for "six" (or incompatible with Python 3. 9)

转载 作者:行者123 更新时间:2023-12-05 05:57:27 27 4
gpt4 key购买 nike

我已经为 django 项目设置了 mypy

[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

最佳答案

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

pip install types-six

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

关于django - mypy 和 django : error: Library stubs not installed for "six" (or incompatible with Python 3. 9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68797011/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com