如何在包级别禁用 mypy 错误代码?

How to disable mypy error code at package level?

variable=[]

错误:

 error: Need type annotation for 'variable' (hint: "variable: List[<type>] = ...")

在配置文件中:mypy.ini

disallow_any_expr=False

有没有办法通过配置文件中的标志来覆盖此错误?

你可以试试这个:

  • 运行mypy --show-error-code your_module.py,会输出方括号内的错误码
  • mypy.ini中添加disable_error_code = code