相关疑难解决方法(0)

如何为文件中的特定变量禁用pylint"未定义变量"错误?

我在C#应用程序中托管IronPython并将主机的API注入全局范围.

我刚刚开始喜欢syntasticvim pylint来检查我的脚本.但是我[E0602, method_name] Undefined variable 'variable_name'对注入变量的所有错误消息感到恼火.

我知道使用# pylint: disable=E0602禁用此错误消息,但我不想仅为某些特定的变量名称削弱一个非常有用的功能.

你怎么处理这个?

目前,我在我的脚本顶部执行此操作:

try:
    host_object = getattr(__builtins__, 'host_object')
except AttributeError:
    pass # oops, run this script inside the host application!!
Run Code Online (Sandbox Code Playgroud)

我真正想做的是:

# pylint: declare=host_object, other_stuff
Run Code Online (Sandbox Code Playgroud)

python pylint

13
推荐指数
3
解决办法
2万
查看次数

标签 统计

pylint ×1

python ×1