flake8 不报告太长的行

flake8 not reporting on lines that are too long

如果我创建一个文件 test.py,其中包含以下格式不正确的内容:

import re
long_string = "foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
class Foo():
    pass

和 运行 flake8 在命令行中的文件上,如下所示:

$ flake8 --max-line-length=79 test.py

只报了两个错误:

test.py:1:1: F401 're' imported but unused
test.py:3:1: E302 expected 2 blank lines, found 0

未报告第二行的 max-line-length 违规。

完全是偶然的(我正在测试命令选项的 any 是否会被尊重),我发现如果我添加这样的忽略选项:

$ flake8 --max-line-length=79 --ignore=E302 test.py

那么行长度违规报告:

test.py:1:1: F401 're' imported but unused
test.py:2:80: E501 line too long (97 > 79 characters)

我使用的是 Ubuntu 16.04,我的 flake8 版本信息是:

2.5.4 (pep8: 1.7.0, mccabe: 0.2.1, pyflakes: 1.1.0) CPython 3.5.1+ on Linux

当我发帖时a related question on the Emacs Stack Exchange site (I thought the issue was with an Emacs package initially), one of the users there pointed out that flake8 2.5.4 requires a lower version of pyflakes。但是,通过 aptpip 安装 flake8 会自动安装特定版本的 pyflakes 作为依赖项,而我无法获得旧版本的 pyflakes 看看是否解决了问题(也许这完全是另一个问题)。

我是不是做错了什么,或者这是一个错误?

E501 在某处被忽略了。它位于 ~/.config/flake8tox.inisetup.cfg.flake8 的本地目录中。在其中一个文件中的某处,您可能会发现类似于:

[flake8]
ignore = E501

(您也可能在其他错误代码中看到它。)

不是 Flake8 中的一个错误,几乎可以肯定是您的环境中的某些东西导致了这个问题。您看到 E501 的原因是因为您通过在命令行上提供 --ignore 来覆盖配置文件设置。