[code-quality] flake8 config file usage

Jason Killen jsnklln at gmail.com
Fri Jan 2 16:41:32 CET 2015


Thanks for you help.  Couple of things:
1) The --help for flake8 says config files should go in flake8:
    --config=path       user config file location (default:
                                /Users/jkillen/.config/flake8)
My reading of your first reply is that they should go in ~/.config/pep8.  I
don't care where they go it's just confusing.
Also, I find the help text a little confusing, I'm not sure if I'm defining
the directory to search for setup.cfg or tox.ini or an actual file itself.
It looks like you're defining the actual file so I'll go with that.  That's
good because that's what I wanted in the first place.

2) Here are some more details, and weirdness, for the code I'm testing
with, I've removed flake8-debugger:
$ flake8 --version
2.2.5 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.7.1 on Darwin

The actual code:
$ cat ex.py
print("hello world")
#comment
if x == y:
  print("x")

if j == None:
    print("It's None")

My config file:
$ cat config.cfg
[flake8]
ignore = E265,E111

Running with a specified config file, doesn't seem to ignore E265,E111:
$ flake8 --config config.cfg ex.py
ex.py:2:1: E265 block comment should start with '# '
ex.py:3:4: F821 undefined name 'x'
ex.py:3:9: F821 undefined name 'y'
ex.py:4:3: E111 indentation is not a multiple of four
ex.py:6:4: F821 undefined name 'j'

Running with --ignore, ignores E111,E265 but includes errors not seen
before:
$ flake8 --ignore=E111,E265 ex.py
ex.py:1:21: W291 trailing whitespace
ex.py:3:4: F821 undefined name 'x'
ex.py:3:9: F821 undefined name 'y'
ex.py:6:4: F821 undefined name 'j'
ex.py:6:6: E711 comparison to None should be 'if cond is None:'

I did step through flake8 looking for where it opened the config file and
got completely lost a few lines in.  I'm pretty new to python.  Since you
mention that's handled by pep8 I'll take another stab at it concentrating
on the pep8 code.

Thanks for your help.

On Mon, Dec 29, 2014 at 4:27 PM, Ian Cordasco <graffatcolmingov at gmail.com>
wrote:

> On Mon, Dec 29, 2014 at 3:08 PM, Ian Cordasco
> <graffatcolmingov at gmail.com> wrote:
> > On Mon, Dec 29, 2014 at 1:57 PM, Jason Killen <jsnklln at gmail.com> wrote:
> >> I've just started using flake8.  I'm using 2.2.5 (pep8: 1.5.7, pyflakes:
> >> 0.8.1, mccabe: 0.3, flake8-debugger: 1.3.2) CPython 2.7.1 on Darwin
> >>
> >> Config files don't seem to be being read in.  I've tried defining it
> >> (config.cfg) using --config, putting it in ., putting it in everything
> up
> >> from ., and putting it in ~/.config/flake8.  No matter what I try flake8
> >> doesn't seem to be picking them up.  Using --ignore works fine.
> >>
> >> Here's my config file:
> >> [flake8]
> >> max-line-length = 200
> >> # E251 unexpected spaces around keyword / parameter equals
> >> # E711 comparison to None should be if cond is not None
> >> # E501 line too long (203 > 200 characters)
> >> # E303 too many blank lines (2)
> >> # E712 comparison to True should be 'if cond is not True:' or 'if not
> cond:'
> >> # E302 expected 2 blank lines, found 1
> >> # E226 missing whitespace around arithmetic operator
> >> # W291 trailing whitespace
> >> # W293 blank line contains whitespace
> >> # W391 blank line at end of file
> >> # E111 indentation is not a multiple of four
> >> # E702 multiple statements on one line (semicolon)
> >> ignore =
> E251,E711,E501,E303,E712,E302,E226,W291,W293,W391,E111,E702,E265
> >>
> >> Help please?
> >
> > Hey Jason,
> >
> > pep8 handles discovery and parsing of config files for flake8. Looking
> > at what pep8 tries to find, your options are ~/.config/pep8,
> > ./tox.ini, and ./setup.cfg. As for why using --config doesn't work, I
> > haven't tried that but that would also be a bug found in pep8. I'll
> > see if I can reproduce that though.
> >
> > Cheers,
> > Ian
> > flake8 maintainer
>
> So I just did the following:
>
> $ mktmpenv
> $ pip install flake8 flake8-docstrings
> $ flake8 --version
> 2.2.5 (pep8: 1.5.7, pyflakes: 0.8.1, pep257: 0.2.1, mccabe: 0.3)
> CPython 2.7.9 on Darwin
> $ cd ~/sandbox/github3.py
>
> I know my project has a lot of docstring (pep257) violations and that
> one of the common ones is D100 so I wrote
>
> [flake8]
> ignore = D100
>
> In test.cfg and did
>
> $ flake8 | wc -l
>      881
> $ flake8 --config test.cfg | wc -l
>      868
>
> So I think that --config is working just fine.
>
> If I update test.cfg to
>
> [flake8]
> ignore = D100,D101,D102
>
> $ flake8 --config test.cfg | wc -l
>      422
>
>
> My final iteration of test.cfg is
>
> [flake8]
> max-line-length = 100
> # Comment
> ignore = D100,D101,D102
>
> And that also works just fine.
>
> Can you share the exact commands you're running? Perhaps this is some
> weird side-effect of flake8-debugger.
>



-- 
Jason Killen   jsnklln at gmail.com
Pain is inevitable, misery is optional.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20150102/1fdc53d4/attachment.html>


More information about the code-quality mailing list