Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flake8 not picking up config file

I have my flake8 config file in ~/.config/flake8

[flake8]
max-line-length = 100

However when I run flake8 the config file is not picked up. I know that because i still get warnings over lines longer than 79 char.

I'm on redhat, but the same happens on mac.

I use pyenv. Global is 2.7.6 (not even sure this is relevant)

like image 266
evolution Avatar asked Feb 10 '15 16:02

evolution


People also ask

Where do I put flake8 config file?

Flake8 allows a user to use “global” configuration file to store preferences. The user configuration file is expected to be stored somewhere in the user's “home” directory. On Windows the “home” directory will be something like C:\\Users\sigmavirus24 , a.k.a, ~\ .

Does flake8 check PEP8?

Flake8 is a Python library that wraps PyFlakes, pycodestyle and Ned Batchelder's McCabe script. It is a great toolkit for checking your code base against coding style (PEP8), programming errors (like “library imported but unused” and “Undefined name”) and to check cyclomatic complexity.


2 Answers

I had a silly mistake, leaving out the [flake8] tag at the beginning of my configuration file I just spent 2 hours debugging this problem.

Here was my original .flake8 file:

ignore=
    # line too long
    E501,
    #line break after binary operator
    W504

This was the fix:

[flake8]
ignore=
    # line too long
    E501,
    #line break after binary operator
    W504

Obviously this wasn't OP's problem: they have the tag in there. But if I can save one person from my stupidity, I will be happy. Frankly I was almost too embarrassed to post this because it is an "Is your computer plugged in?" level error, but oh well.

like image 170
eric Avatar answered Sep 21 '22 12:09

eric


Sharing my mistake in case this can help someone:

I had a similar issue which was simply due to a bad file name: .flake8.txt instead of .flake8.

Correcting resolves the issue.

like image 36
CharlesG Avatar answered Sep 19 '22 12:09

CharlesG