Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flake8 not reporting on lines that are too long

If I create a file test.py with the following poorly-formatted contents:

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

and run flake8 on the file from the command-line like this:

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

only two errors are reported:

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

The max-line-length violation on line two is not reported.

Completely by accident (I was testing if any of the command options would be respected), I found that if I add an ignore option like this:

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

Then the line length violation is reported:

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

I am on Ubuntu 16.04 and my flake8 version info is:

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

When I posted 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. However, installing flake8 through apt or pip automatically installs that particular version of pyflakes as a dependency, and I have been unable to get an older version of pyflakes to see if that solves the problem (maybe that is another question altogether).

Am I doing something wrong here, or is this a bug?

like image 253
elethan Avatar asked Jan 05 '23 23:01

elethan


1 Answers

E501 is being ignored somewhere. It's either in ~/.config/flake8 or in the local directory in tox.ini, setup.cfg, or .flake8. Somewhere in one of those files you will probably find something akin to:

[flake8]
ignore = E501

(You may see it among other error codes too.)

This is not a bug in Flake8, and is almost certainly something in your environment causing this. The reason you see E501 is because you override the config file setting by providing --ignore on the command line.

like image 186
Ian Stapleton Cordasco Avatar answered Jan 21 '23 03:01

Ian Stapleton Cordasco