设置 pyflake 和 mypy 忽略相同的行

2024-09-20 23:03:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我为Salt编写了一个模块。通过documentation它将__salt__对象添加到builtins中。所以,pyflake警告我,当我运行prospectormypy时,__salt__是未定义的!我可以忽略带有# noqa: F821的forpyflake或者在那一行中忽略# type: ignore的formypy。在

问题是!如何忽视他们两个?在


Tags: 模块对象警告documentationtypesalt未定义prospector
1条回答
网友
1楼 · 发布于 2024-09-20 23:03:59

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~

因此,正如Ryan Tam所建议的,# type: ignore # noqa是忽略两者的正确方法。在

相关问题 更多 >

    热门问题