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

pan*_*esh 6 python types type-hinting mypy

variable=[]

错误:

 error: Need type annotation for 'variable' (hint: "variable: List[<type>] = ...")
Run Code Online (Sandbox Code Playgroud)

在配置文件中:mypy.ini

disallow_any_expr=False

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

Lau*_*ent 9

你可以试试这个:

  • run mypy --show-error-code your_module.py,它将输出方括号内的错误代码
  • mypy.ini,添加disable_error_code = code