有没有办法flake8只忽略整个文件的特定规则?具体来说,我只想忽略F401整个文件。
我有一个文件,比如__init__.py我在其中导入从未在该文件中使用过的符号。我宁愿不添加# noqa到每一行。我可以添加# flake8: noqa到文件的开头,但这会忽略所有规则。我想忽略只是该F401规则。
Ant*_*ile 34
there is not currently a way to do what you're asking with only source inside the file itself
the current suggested way is to use the per-file-ignores feature in your flake8 configuration:
[flake8]
per-file-ignores =
*/__init__.py: F401
Run Code Online (Sandbox Code Playgroud)
Note that F401 in particular can be solved in a better way, any names that are exposed in __all__ will be ignored by pyflakes:
[flake8]
per-file-ignores =
*/__init__.py: F401
Run Code Online (Sandbox Code Playgroud)
(disclaimer: I'm the current maintainer of flake8 and one of the maintainers of pyflakes)
根据文档,只需更改即可简单# noqa:
# noqa: F401
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5972 次 |
| 最近记录: |