From jsnklln at gmail.com Fri Jan 2 16:41:32 2015 From: jsnklln at gmail.com (Jason Killen) Date: Fri, 2 Jan 2015 10:41:32 -0500 Subject: [code-quality] flake8 config file usage In-Reply-To: References: Message-ID: 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 wrote: > On Mon, Dec 29, 2014 at 3:08 PM, Ian Cordasco > wrote: > > On Mon, Dec 29, 2014 at 1:57 PM, Jason Killen 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: From graffatcolmingov at gmail.com Fri Jan 2 16:55:24 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Fri, 2 Jan 2015 09:55:24 -0600 Subject: [code-quality] flake8 config file usage In-Reply-To: References: Message-ID: I'm beginning to think this is a problem with the ConfigParser module on Python 2.7.1. Can you upgrade your system installation of Python? ~ mktmpenv New python executable in tmp-e6c7d5624589670b/bin/python2.7 Also creating executable in tmp-e6c7d5624589670b/bin/python Installing setuptools, pip...done. This is a temporary environment. It will be deleted when you run 'deactivate'. (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b vl ex.py (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b pip install flake8 Collecting flake8 Using cached flake8-2.2.5.tar.gz Collecting pyflakes>=0.8.1 (from flake8) Using cached pyflakes-0.8.1-py2.py3-none-any.whl Collecting pep8>=1.5.7 (from flake8) Using cached pep8-1.5.7-py2.py3-none-any.whl Collecting mccabe>=0.2.1 (from flake8) Using cached mccabe-0.3-py2.py3-none-any.whl Installing collected packages: mccabe, pep8, pyflakes, flake8 Running setup.py install for flake8 Installing flake8 script to ~/virtualenv/tmp-e6c7d5624589670b/bin Successfully installed flake8-2.2.5 mccabe-0.3 pep8-1.5.7 pyflakes-0.8.1 (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b vl config.cfg (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b flake8 --config config.cfg 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:' (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b flake8 --version 2.2.5 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.7.9 on Darwin (output https://gist.github.com/sigmavirus24/bb5ff3b11de0d40bc7c2 in the event it's easier to read for some people) On Fri, Jan 2, 2015 at 9:41 AM, Jason Killen wrote: > 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 > wrote: >> >> On Mon, Dec 29, 2014 at 3:08 PM, Ian Cordasco >> wrote: >> > On Mon, Dec 29, 2014 at 1:57 PM, Jason Killen 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. From sylvain.thenault at logilab.fr Mon Jan 5 10:33:56 2015 From: sylvain.thenault at logilab.fr (Sylvain =?utf-8?B?VGjDqW5hdWx0?=) Date: Mon, 5 Jan 2015 10:33:56 +0100 Subject: [code-quality] Pylint custom transformer: suppress some error messages In-Reply-To: References: Message-ID: <20150105093356.GB11041@logilab.fr> On 28 d?cembre 22:42, Alexandr Presniakov wrote: > Hello! Hi, > I'm implementing pylint plugin for web2py: it executes user code in a > special environment populated with predefined objects. > My transformer adds imports for pylint not to complain about undefined > objects. > But after that pylint complains about unused-wildcard-import. > Is there any way to suppress some messages or at least to add some > '#pylint: disable=...' line to module from the transformer? could you post some code snippet to explain your problem? I'm not sure what's going on here... -- Sylvain Th?nault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, M?th. Agiles: http://www.logilab.fr/formations D?veloppement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework: http://www.cubicweb.org From graffatcolmingov at gmail.com Tue Jan 6 15:25:20 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Tue, 6 Jan 2015 08:25:20 -0600 Subject: [code-quality] [Announcement] [mccabe] New way to run mccabe as a standalone script Message-ID: Hey all, Ever since mccabe has become it's own package on PyPI, you've been able to run it independently by executing python -m mccabe {opts} Since most of mccabe's downloads are via Flake8, the project has resisted adding an entry point to make an easy-to-access console script. I'm a thoroughly curious person though, so I threw together a package on PyPI - mccabe-console-script - to provide that functionality. If the download count demonstrates that this is useful, I'll propose updating the mccabe package to include the extra lines that make this possible. The repository is on GitLab [1] and mirrored to GitHub [2] with the source code. Cheers, Ian [1]: https://gitlab.com/pycqa/mccabe-console-script [2]: https://github.com/PyCQA/mccabe-console-script From graffatcolmingov at gmail.com Tue Jan 6 15:40:08 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Tue, 6 Jan 2015 08:40:08 -0600 Subject: [code-quality] [Announcement] [mccabe] New way to run mccabe as a standalone script In-Reply-To: References: Message-ID: On Tue, Jan 6, 2015 at 8:25 AM, Ian Cordasco wrote: > Hey all, > > Ever since mccabe has become it's own package on PyPI, you've been > able to run it independently by executing > > python -m mccabe {opts} > > Since most of mccabe's downloads are via Flake8, the project has > resisted adding an entry point to make an easy-to-access console > script. I'm a thoroughly curious person though, so I threw together a > package on PyPI - mccabe-console-script - to provide that > functionality. > > If the download count demonstrates that this is useful, I'll propose > updating the mccabe package to include the extra lines that make this > possible. > > The repository is on GitLab [1] and mirrored to GitHub [2] with the source code. > > Cheers, > Ian > > [1]: https://gitlab.com/pycqa/mccabe-console-script > [2]: https://github.com/PyCQA/mccabe-console-script FWIW, I just noticed the mirror does not seem to be mirroring. I've contacted GitHub support about that to see if we can get it fixed it up. Cheers From jsnklln at gmail.com Thu Jan 8 21:55:39 2015 From: jsnklln at gmail.com (Jason Killen) Date: Thu, 8 Jan 2015 15:55:39 -0500 Subject: [code-quality] flake8 config file usage In-Reply-To: References: Message-ID: Thanks again Ian. I think I've tracked down the problem in the pep8 code. I realize you're not the pep8 developer but I could use a second set of eyes. If you don't mind can you verify that what I'm seeing is the same as what you have. In pep8.py in the fuction read_config near line 1852. I've got this: user_conf = options.config if user_conf and os.path.isfile(user_conf): if options.verbose: print('user configuration: %s' % user_conf) config.read(user_conf) local_dir = os.curdir parent = tail = args and os.path.abspath(os.path.commonprefix(args)) while tail: if config.read([os.path.join(parent, fn) for fn in PROJECT_CONFIG]): local_dir = parent if options.verbose: print('local configuration: in %s' % parent) break (parent, tail) = os.path.split(parent) What's happening here is it's reading my defined config file then over-reading it with files found further up the directory tree. I started playing with flake8 on a project level then took a left turn and started wanting to define config files on the command line, so I've got a setup.cfg a few directories up. I did some tests after adding an else after the if so pep8 only looks for files in the tree if the user defined file doesn't exist. That seems to be working much better. On Fri, Jan 2, 2015 at 10:55 AM, Ian Cordasco wrote: > I'm beginning to think this is a problem with the ConfigParser module > on Python 2.7.1. Can you upgrade your system installation of Python? > > ~ mktmpenv > New python executable in tmp-e6c7d5624589670b/bin/python2.7 > Also creating executable in tmp-e6c7d5624589670b/bin/python > Installing setuptools, pip...done. > This is a temporary environment. It will be deleted when you run > 'deactivate'. > (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b vl ex.py > (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b pip install > flake8 > Collecting flake8 > Using cached flake8-2.2.5.tar.gz > Collecting pyflakes>=0.8.1 (from flake8) > Using cached pyflakes-0.8.1-py2.py3-none-any.whl > Collecting pep8>=1.5.7 (from flake8) > Using cached pep8-1.5.7-py2.py3-none-any.whl > Collecting mccabe>=0.2.1 (from flake8) > Using cached mccabe-0.3-py2.py3-none-any.whl > Installing collected packages: mccabe, pep8, pyflakes, flake8 > > > > Running setup.py install for flake8 > Installing flake8 script to ~/virtualenv/tmp-e6c7d5624589670b/bin > Successfully installed flake8-2.2.5 mccabe-0.3 pep8-1.5.7 pyflakes-0.8.1 > (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b vl config.cfg > (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b flake8 > --config config.cfg 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:' > (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b flake8 --version > 2.2.5 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.7.9 on Darwin > > (output https://gist.github.com/sigmavirus24/bb5ff3b11de0d40bc7c2 in > the event it's easier to read for some people) > > On Fri, Jan 2, 2015 at 9:41 AM, Jason Killen wrote: > > 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 > >> wrote: > >> > On Mon, Dec 29, 2014 at 1:57 PM, Jason Killen > 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. > -- Jason Killen jsnklln at gmail.com Pain is inevitable, misery is optional. -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Thu Jan 8 22:12:31 2015 From: me at the-compiler.org (Florian Bruhin) Date: Thu, 8 Jan 2015 22:12:31 +0100 Subject: [code-quality] pylint: Writing checker to check method calls Message-ID: <20150108211231.GC29790@tonks> Hi! I'm trying to write a checker for pylint which checks if certain callables (anything passed to the .connect() method of a pyqtSignal, i.e. Qt slots) are decorated with @pyqtSlot. However I'm already stuck trying to implement a visit_callfunc which actually sees the call. My checker does this: def visit_callfunc(self, node): if hasattr(node, 'func'): if getattr(node.func, 'name', None) == 'connect': import pdb; pdb.set_trace() (full source: http://paste.the-compiler.org/view/32c1b8df) This is the code I'm testing with: from PyQt5.QtCore import QObject, pyqtSignal class Foo(QObject): sig = pyqtSignal() def __init__(self): self.sig.connect(func) def func(): pass (paste: http://paste.the-compiler.org/view/1970b9b8) However, the breakpoint never hits. Why is that? Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From graffatcolmingov at gmail.com Fri Jan 9 18:01:58 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Fri, 9 Jan 2015 11:01:58 -0600 Subject: [code-quality] flake8 config file usage In-Reply-To: References: Message-ID: On Thu, Jan 8, 2015 at 2:55 PM, Jason Killen wrote: > Thanks again Ian. I think I've tracked down the problem in the pep8 code. > I realize you're not the pep8 developer but I could use a second set of > eyes. If you don't mind can you verify that what I'm seeing is the same as > what you have. In pep8.py in the fuction read_config near line 1852. I've > got this: > user_conf = options.config > if user_conf and os.path.isfile(user_conf): > if options.verbose: > print('user configuration: %s' % user_conf) > config.read(user_conf) > > local_dir = os.curdir > parent = tail = args and os.path.abspath(os.path.commonprefix(args)) > while tail: > if config.read([os.path.join(parent, fn) for fn in PROJECT_CONFIG]): > local_dir = parent > if options.verbose: > print('local configuration: in %s' % parent) > break > (parent, tail) = os.path.split(parent) > > What's happening here is it's reading my defined config file then > over-reading it with files found further up the directory tree. I started > playing with flake8 on a project level then took a left turn and started > wanting to define config files on the command line, so I've got a setup.cfg > a few directories up. I did some tests after adding an else after the if so > pep8 only looks for files in the tree if the user defined file doesn't > exist. That seems to be working much better. I saw you filed an issue and pull request against pep8. I'll respond there when I have a chance to look at them. > On Fri, Jan 2, 2015 at 10:55 AM, Ian Cordasco > wrote: >> >> I'm beginning to think this is a problem with the ConfigParser module >> on Python 2.7.1. Can you upgrade your system installation of Python? >> >> ~ mktmpenv >> New python executable in tmp-e6c7d5624589670b/bin/python2.7 >> Also creating executable in tmp-e6c7d5624589670b/bin/python >> Installing setuptools, pip...done. >> This is a temporary environment. It will be deleted when you run >> 'deactivate'. >> (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b vl ex.py >> (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b pip install >> flake8 >> Collecting flake8 >> Using cached flake8-2.2.5.tar.gz >> Collecting pyflakes>=0.8.1 (from flake8) >> Using cached pyflakes-0.8.1-py2.py3-none-any.whl >> Collecting pep8>=1.5.7 (from flake8) >> Using cached pep8-1.5.7-py2.py3-none-any.whl >> Collecting mccabe>=0.2.1 (from flake8) >> Using cached mccabe-0.3-py2.py3-none-any.whl >> Installing collected packages: mccabe, pep8, pyflakes, flake8 >> >> >> >> Running setup.py install for flake8 >> Installing flake8 script to ~/virtualenv/tmp-e6c7d5624589670b/bin >> Successfully installed flake8-2.2.5 mccabe-0.3 pep8-1.5.7 pyflakes-0.8.1 >> (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b vl config.cfg >> (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b flake8 >> --config config.cfg 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:' >> (tmp-e6c7d5624589670b)~/virtualenv/tmp-e6c7d5624589670b flake8 --version >> 2.2.5 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.7.9 on Darwin >> >> (output https://gist.github.com/sigmavirus24/bb5ff3b11de0d40bc7c2 in >> the event it's easier to read for some people) >> >> On Fri, Jan 2, 2015 at 9:41 AM, Jason Killen wrote: >> > 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 >> > >> > wrote: >> >> >> >> On Mon, Dec 29, 2014 at 3:08 PM, Ian Cordasco >> >> wrote: >> >> > On Mon, Dec 29, 2014 at 1:57 PM, Jason Killen >> >> > 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. > > > > > -- > Jason Killen jsnklln at gmail.com > Pain is inevitable, misery is optional. From asmacdo at gmail.com Mon Jan 12 22:16:45 2015 From: asmacdo at gmail.com (Austin Macdonald) Date: Mon, 12 Jan 2015 16:16:45 -0500 Subject: [code-quality] [feature request] .gitignore option for flake8 Message-ID: I would like if flake8 could ignore all files that match the .gitignore. This would be helpful since it is not ideal to list things that are specific to a specific dev environment in automatic test runners. Thanks, Austin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Mon Jan 12 23:20:14 2015 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 13 Jan 2015 09:20:14 +1100 Subject: [code-quality] [feature request] .gitignore option for flake8 References: Message-ID: <857fwrvdy9.fsf@benfinney.id.au> Austin Macdonald writes: > I would like if flake8 could ignore all files that match the > .gitignore. Rather than making an option specific to one particular tool, I think the correct way to do this would be to break it in two: * Query $SOME_TOOL for a set of file names. In your case, this would be something like ?git clean --dry-run -dX?. * Use the output from the above command to specify which files Flake should ignore. The ?flake8? help shows we have a ?--exclude? option available. So it remains only to transform the output from ?determine-files-to-ignore? into the format expected by ?flake8 --exclude?. But please, not a special one-tool-only option. -- \ ?Don't fight forces, use them.? ?Richard Buckminster Fuller, | `\ _Shelter_, 1932 | _o__) | Ben Finney From laurent at bachelier.name Tue Jan 13 00:28:07 2015 From: laurent at bachelier.name (Laurent Bachelier) Date: Tue, 13 Jan 2015 00:28:07 +0100 Subject: [code-quality] [feature request] .gitignore option for flake8 In-Reply-To: <857fwrvdy9.fsf@benfinney.id.au> References: <857fwrvdy9.fsf@benfinney.id.au> Message-ID: <54B45887.7090008@bachelier.name> On 2015-01-12 23:20, Ben Finney wrote: > Austin Macdonald > writes: > >> I would like if flake8 could ignore all files that match the >> .gitignore. > > Rather than making an option specific to one particular tool, I think > the correct way to do this would be to break it in two: > > * Query $SOME_TOOL for a set of file names. In your case, this would be > something like ?git clean --dry-run -dX?. I use something like flake8 $(git ls-files|grep '^scripts\|\.py$'|grep ...) ls-files seems to have a lot of options, you might not even need grep. From graffatcolmingov at gmail.com Tue Jan 13 00:56:05 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Mon, 12 Jan 2015 17:56:05 -0600 Subject: [code-quality] [feature request] .gitignore option for flake8 In-Reply-To: <54B45887.7090008@bachelier.name> References: <857fwrvdy9.fsf@benfinney.id.au> <54B45887.7090008@bachelier.name> Message-ID: On Mon, Jan 12, 2015 at 5:28 PM, Laurent Bachelier wrote: > On 2015-01-12 23:20, Ben Finney wrote: >> Austin Macdonald >> writes: >> >>> I would like if flake8 could ignore all files that match the >>> .gitignore. >> >> Rather than making an option specific to one particular tool, I think >> the correct way to do this would be to break it in two: >> >> * Query $SOME_TOOL for a set of file names. In your case, this would be >> something like ?git clean --dry-run -dX?. > > I use something like > flake8 $(git ls-files|grep '^scripts\|\.py$'|grep ...) > > ls-files seems to have a lot of options, you might not even need grep. So I'm personally -1 on adding this feature to Flake8. There are a few reasons: 1. Already we support per-project and global configuration files for Flake8. In either (or both) of these we allow the user to specify things to ignore via --exclude. Ignoring things in git works similarly (i.e., per-repository and globally) and handling both cases (as would eventually be demanded) would be untenable, unmaintainable, and rather complex. 2. We can not (and will not) only support this feature for git. Supporting it for mercurial would be enough to satisfy me, but then we would sacrifice the ability to simply read a file for patterns (since mercurial allows for at least 2 ways (that I know of) to ignore files). 2. a. Shelling out to git and mercurial is extremely sub-optimal and subprocesses introduce yet another group of hacks to support on both Windows, OS X, and Linux (already complicated by using multiprocessing). 2. b. Git has no elegant API for this 2. c. Using Mercurial's API (according to Mercurial) would probably made Flake8 would have to be re-licensed as a GPL-family tool, which is unacceptable. 3. This can already quite easily be configured (globally or per-project) but would require maintaining a .gitignore and a second configuration file. 4. People may expect that some file which should not be checked in is still compliant. Automatically ignoring it because it is ignored by a *separate* tool will lead to confusion and likely bug reports. 5. Explicit is better than magic. If you want Flake8 to ignore something, there are already well documented ways of doing so. Flake8 doesn't automatically check commit diffs for you either, nor will it. It /will/ install a hook for you but it won't do it without your consent. Adding this would violate internal consistency. There may be value in a separate extension to /suggest/ patterns or files to pass to --exclude based on VCS ignore files though. I encourage others to continue offering solutions for their various tools. We can turn them into snippets over on https://gitlab.com/pycqa/flake8/snippets Cheers, Ian From kannan at cakoose.com Fri Jan 16 01:52:17 2015 From: kannan at cakoose.com (Kannan Goundan) Date: Fri, 16 Jan 2015 00:52:17 +0000 (UTC) Subject: [code-quality] Getting Flake8 to report syntax errors. Message-ID: Sample input file "test.py": def f(x) print x Pyflakes reports the syntax error: $ pyflakes test.py test.py:1:9: invalid syntax def f(x) ^ $ But Flake8 doesn't: $ flake8 test.py $ Is this intentional? Is there a way to get Flake8 to report syntax errors? $ flake8 --version 2.3.0 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.7.5 on Darwin $ pyflakes --version 0.8.1 From graffatcolmingov at gmail.com Fri Jan 16 04:31:23 2015 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Thu, 15 Jan 2015 21:31:23 -0600 Subject: [code-quality] Getting Flake8 to report syntax errors. In-Reply-To: References: Message-ID: On Jan 15, 2015 7:00 PM, "Kannan Goundan" wrote: > > Sample input file "test.py": > > def f(x) > print x > > Pyflakes reports the syntax error: > > $ pyflakes test.py > test.py:1:9: invalid syntax > def f(x) > ^ > $ > > But Flake8 doesn't: > > $ flake8 test.py > $ > > Is this intentional? Is there a way to get Flake8 to report syntax errors? > > $ flake8 --version > 2.3.0 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.3) CPython 2.7.5 on Darwin > $ pyflakes --version > 0.8.1 > > _______________________________________________ > code-quality mailing list > code-quality at python.org > https://mail.python.org/mailman/listinfo/code-quality Sounds like a bug to me. Please report this on the repo? -------------- next part -------------- An HTML attachment was scrubbed... URL: From pcmanticore at gmail.com Fri Jan 16 21:22:42 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Fri, 16 Jan 2015 22:22:42 +0200 Subject: [code-quality] [ANN] Pylint 1.4.1 / Astroid 1.3.3 released Message-ID: Hello, It's my pleasure to announce the release of both Pylint 1.4.1 and Astroid 1.3.3 respectively. The following bug fixes and features made their way into Astroid 1.3.3: * Restore file_stream to a property, but deprecate it in favour of the newly added method Module.stream. * Add inference tips for 'tuple', 'list', 'dict' and 'set' builtins. * Add brain definition for most string and unicode methods * Add a new method to Class nodes, 'mro', for obtaining the the method resolution order of the class. * Add brain tips for six.moves. Closes issue #63. * .slots() can contain unicode strings on Python 2. * Add inference tips for nose.tools. The complete list of changes can be seen here: https://bitbucket.org/logilab/astroid/src/15cff6016b793bb64c92d04acc4da001a2c98683/ChangeLog?at=default#cl-4 For Pylint, we have the following fixes and features: * Add a new JSON reporter, usable through -f flag. * Add a new warning, 'redundant-unittest-assert', emitted when using unittest's methods assertTrue and assertFalse with constant value as argument. * Check the return of properties when checking for not-callable. Closes issue #406. * Warn about using the input() or round() built-ins for Python 3. Closes issue #411. * Use a mro traversal for finding abstract methods. Closes issue #415. * Fix a false positive on Python 2 for raising-bad-type, when raising tuples in the form 'raise (ZeroDivisionError, None)'. * Fix a false positive with invalid-slots-objects, where the slot entry was an unicode string on Python 2. Closes issue #421. The complete list of changes can be found here: https://bitbucket.org/logilab/pylint/src/02eabae6b72569876e7104db7724ad26a7de0af3/ChangeLog?at=default#cl-4 If you find any bugs, don't hesitate to open a new issue on our issue tracker (https://bitbucket.org/logilab/pylint/) Enjoy!