【发布时间】:2020-11-02 16:51:25
【问题描述】:
之前在使用 pylint 时,我在 vscode 中编辑时使用了自定义注释设置来忽略未定义的变量,例如:
# Make pylint think that it knows about additional builtins
data = data # pylint:disable=invalid-name,used-before-assignment,undefined-variable
DEBUG = DEBUG # pylint:disable=invalid-name,used-before-assignment,undefined-variable
VERBOSE = VERBOSE # pylint:disable=invalid-name,used-before-assignment,undefined-variable
请注意,我的应用程序有它自己的基于 python 的精简脚本语言,因此还有其他内置函数。
我找不到 pylance 的等价物。 有人有什么建议吗?
回答:
我使用# type: ignore 来停止错误突出显示。
【问题讨论】:
-
您好 Jill,感谢您的建议,但我想有选择地选择要从检查中排除的变量。
-
我已经提交了这个提案,让我们期待一个好的解决方案。 Github链接:Is there a setting to turn off specific errors displayed by Pylance