我可以禁用 MyPy 的“找不到名为...的模块的实现或库存根”错误吗?

Ama*_*shy 1 python mypy

有很多关于Cannot find implementation or library stub for module named...错误的线程,但没有关联的错误代码。我想完全禁用此功能。我该怎么做呢?

小智 7

要禁用警告:

--ignore-missing-imports在 CLI 上传递标志。

或者如果使用配置文件:

对于mypy.inisetup.cfg

[mypy]
ignore_missing_imports = true
Run Code Online (Sandbox Code Playgroud)

为了pyproject.toml

[tool.mypy]
ignore_missing_imports = true
Run Code Online (Sandbox Code Playgroud)

这将禁用所有模块的警告。您可以在每个模块的基础上进行设置,但是您必须查看文档以获取有关如何执行此操作的示例。