2024-09-20 23:03:59 发布
网友
我为Salt编写了一个模块。通过documentation它将__salt__对象添加到builtins中。所以,pyflake警告我,当我运行prospector和mypy时,__salt__是未定义的!我可以忽略带有# noqa: F821的forpyflake或者在那一行中忽略# type: ignore的formypy。在
__salt__
builtins
# noqa: F821
# type: ignore
问题是!如何忽视他们两个?在
PEP 484在section on type comments末尾指定了以下内容:
In some cases, linting tools or other comments may be needed on the same line as a type comment. In these cases, the type comment should be before other comments and linting markers:# type: ignore # ~comment or other marker~
In some cases, linting tools or other comments may be needed on the same line as a type comment. In these cases, the type comment should be before other comments and linting markers:
# type: ignore # ~comment or other marker~
因此,正如Ryan Tam所建议的,# type: ignore # noqa是忽略两者的正确方法。在
# type: ignore # noqa
PEP 484在section on type comments末尾指定了以下内容:
因此,正如Ryan Tam所建议的,
# type: ignore # noqa
是忽略两者的正确方法。在相关问题 更多 >
编程相关推荐