From thomasharrisonnelson at gmail.com Tue May 2 10:49:50 2017 From: thomasharrisonnelson at gmail.com (Thomas Nelson) Date: Tue, 02 May 2017 14:49:50 +0000 Subject: [code-quality] pylint Unnecessary parens after 'print' keyword for python3 Message-ID: I am trying to use pylint to check python3 code. I get "Unnecessary parens after 'print' keyword" for every print. I installed it with "pip3 install --user pylint" , and "cat $(which pylint)" gives #!/usr/bin/python3 # -*- coding: utf-8 -*- import re import sys from pylint import run_pylint if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(run_pylint()) So I'm pretty sure I have the correct version. Is there some configuration paramter to force python3 checking? I couldn't find anything in the docs. I can just turn off that particular warning, but is that what everyone who uses pylint for python 3 does? -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Tue May 2 11:26:53 2017 From: me at the-compiler.org (Florian Bruhin) Date: Tue, 2 May 2017 17:26:53 +0200 Subject: [code-quality] pylint Unnecessary parens after 'print' keyword for python3 In-Reply-To: References: Message-ID: <20170502152652.nxswt63c4q4dtfbb@hooch.localdomain> Hi, On Tue, May 02, 2017 at 02:49:50PM +0000, Thomas Nelson wrote: > I am trying to use pylint to check python3 code. I get "Unnecessary parens > after 'print' keyword" for every print. > I installed it with "pip3 install --user pylint" , and "cat $(which > pylint)" gives > #!/usr/bin/python3 That looks right. What does /usr/bin/python3 --version say? Does anything change when you use /usr/bin/python3 -m pylint? Also, what does "pylint --version" show? > So I'm pretty sure I have the correct version. Is there some configuration > paramter to force python3 checking? I couldn't find anything in the docs. > I can just turn off that particular warning, but is that what everyone who > uses pylint for python 3 does? No configuration necessary, that warning definitely shouldn't get printed if you're actually running an up-to-date pylint with python 3. Florian -- https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc I love long mails! | https://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From chris at subtlety.com Tue May 2 16:15:22 2017 From: chris at subtlety.com (Chris Bergstresser) Date: Tue, 2 May 2017 16:15:22 -0400 Subject: [code-quality] F811 errors with pytest fixtures? Message-ID: Hi all -- We're using flake8 to test our code, and we're using pytest with fixtures. The following code: ---- from staylists.tests.fixtures import fixture1 # noqa: F401 def test_case(fixture1): # noqa: F811 # Test goes here assert 1 == 1 ---- Generates a "lib/python/test.py:3:1: F811 redefinition of unused 'fixture1' from line 1" error during linting. Why does it ignore the noqa flag? Is there a better way to avoid flagging this error? -- Chris From floris.bruynooghe at gmail.com Tue May 2 18:13:11 2017 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Wed, 03 May 2017 00:13:11 +0200 Subject: [code-quality] F811 errors with pytest fixtures? In-Reply-To: References: Message-ID: <87o9vaoqko.fsf@powell.devork.be> Hi Chris, Chris Bergstresser writes: > Hi all -- > > We're using flake8 to test our code, and we're using pytest with > fixtures. The following code: > > ---- > from staylists.tests.fixtures import fixture1 # noqa: F401 Firstly I'd like to warn against importing pytest fixtures. With pytest this is really considered a bad practice and can lead to surprising results. The problem is with fixtures scoped at higher levels then functions, when imported they can appear multiple times and the scope no longer applies. Instead it is recommended to put all fixtures in the correct conftest.py file and rely on the pytest fixture search path to find the fixture. > def test_case(fixture1): # noqa: F811 > # Test goes here > assert 1 == 1 > ---- > > Generates a "lib/python/test.py:3:1: F811 redefinition of unused > 'fixture1' from line 1" error during linting. There is no great answer to this unfortunately. One primary way to avoid this linting warning is to put the fixture in the conftest.py file as described above, there is then no definition in the same file and the warning will go away. For fixtures in the test module itself you can use the somewhat clunky @pytest.fixture(name='foo): def fix_foo(): pass Another option is that we should really teach the linters about pytest. E.g. I'd love a pylint plugin that complains about misspelling fixture etc (and importing fixtures ;-)) > Why does it ignore the noqa flag? I'll pass on this one - I'm not a heavy flake8/pyflakes user. > Is there a better way to avoid flagging this error? I hope I've answered this somewhat reasonably though. Regards, Floris From flub at devork.be Wed May 3 05:41:14 2017 From: flub at devork.be (Floris Bruynooghe) Date: Wed, 03 May 2017 11:41:14 +0200 Subject: [code-quality] F811 errors with pytest fixtures? In-Reply-To: References: Message-ID: <87inlib7lx.fsf@powell.devork.be> Hi Chris, Chris Bergstresser writes: > Hi all -- > We're using flake8 to test our code, and we're using pytest with > fixtures. The following code: > > ---- > from staylists.tests.fixtures import fixture1 # noqa: F401 Firstly I'd like to warn against importing pytest fixtures. With pytest this is really considered a bad practice and can lead to surprising results. The problem is with fixtures scoped at higher levels then functions, when imported they can appear multiple times and the scope no longer applies. Instead it is recommended to put all fixtures in the correct conftest.py file and rely on the pytest fixture search path to find the fixture. > def test_case(fixture1): # noqa: F811 > # Test goes here [ 2 more citation lines. Click/Enter to show. ] > assert 1 == 1 > ---- > > Generates a "lib/python/test.py:3:1: F811 redefinition of unused > 'fixture1' from line 1" error during linting. There is no great answer to this unfortunately. One primary way to avoid this linting warning is to put the fixture in the conftest.py file as described above, there is then no definition in the same file and the warning will go away. For fixtures in the test module itself you can use the somewhat clunky @pytest.fixture(name='foo): def fix_foo(): pass Another option is that we should really teach the linters about pytest. E.g. I'd love a pylint plugin that complains about misspelling fixture etc (and importing fixtures ;-)) > Why does it ignore the noqa flag? I'll pass on this one - I'm not a heavy flake8/pyflakes user. > Is there a better way to avoid flagging this error? I hope I've answered this somewhat reasonably though. Regards, Floris From marius at gedmin.as Thu May 4 05:08:30 2017 From: marius at gedmin.as (Marius Gedminas) Date: Thu, 4 May 2017 12:08:30 +0300 Subject: [code-quality] F811 errors with pytest fixtures? In-Reply-To: References: Message-ID: <20170504090830.7v232lhqkljxbxzt@platonas> On Tue, May 02, 2017 at 04:15:22PM -0400, Chris Bergstresser wrote: > We're using flake8 to test our code, and we're using pytest with > fixtures. The following code: > > ---- > from staylists.tests.fixtures import fixture1 # noqa: F401 > > def test_case(fixture1): # noqa: F811 > # Test goes here > assert 1 == 1 > ---- > > Generates a "lib/python/test.py:3:1: F811 redefinition of unused > 'fixture1' from line 1" error during linting. > > Why does it ignore the noqa flag? This works for me: if I copy your 4-line snippet into a file and run flake8, I get one warning (E302 expected 2 blank lines, found 1). If I remove both noqa comments, I get three warnings (F401, E302, F811). Tried with two flake8 versions -- whatever I had before, which was $ flake8 --version 3.2.1 (pyflakes: 1.3.0, pycodestyle: 2.2.0, mccabe: 0.5.3) CPython 2.7.13 on Linux and the current release, which is 3.3.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.5.0) CPython 2.7.13 on Linux HTH, Marius Gedminas -- The primary purpose of the DATA statement is to give names to constants; instead of referring to PI as 3.141592653589797, at every appearance, the variable PI can be given that value with a DATA statement, and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of PI change. -- Fortran manual for Xerox computers -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 163 bytes Desc: not available URL: From thomasharrisonnelson at gmail.com Thu May 4 08:39:17 2017 From: thomasharrisonnelson at gmail.com (Thomas Nelson) Date: Thu, 04 May 2017 12:39:17 +0000 Subject: [code-quality] pylint Unnecessary parens after 'print' keyword for python3 In-Reply-To: <20170502152652.nxswt63c4q4dtfbb@hooch.localdomain> References: <20170502152652.nxswt63c4q4dtfbb@hooch.localdomain> Message-ID: I tried /usr/bin/python3 -m pylint and it worked, and now it seems like pylint by itself alsow works. Not sure what I was doing wrong, but thanks. On Tue, May 2, 2017 at 9:28 AM Florian Bruhin wrote: > Hi, > > On Tue, May 02, 2017 at 02:49:50PM +0000, Thomas Nelson wrote: > > I am trying to use pylint to check python3 code. I get "Unnecessary > parens > > after 'print' keyword" for every print. > > I installed it with "pip3 install --user pylint" , and "cat $(which > > pylint)" gives > > #!/usr/bin/python3 > > That looks right. What does /usr/bin/python3 --version say? Does > anything change when you use /usr/bin/python3 -m pylint? > > Also, what does "pylint --version" show? > > > So I'm pretty sure I have the correct version. Is there some > configuration > > paramter to force python3 checking? I couldn't find anything in the > docs. > > I can just turn off that particular warning, but is that what everyone > who > > uses pylint for python 3 does? > > No configuration necessary, that warning definitely shouldn't get > printed if you're actually running an up-to-date pylint with python 3. > > Florian > > -- > https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP) > GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc > I love long mails! | https://email.is-not-s.ms/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rajkumar.cs545 at gmail.com Fri May 12 23:12:08 2017 From: rajkumar.cs545 at gmail.com (kumar raja) Date: Sat, 13 May 2017 08:42:08 +0530 Subject: [code-quality] Pylint output Message-ID: Hi, The output of the pylint tool is not grouped by message_types(W, E, R, C) or not in sequence order of line numbers. So is there a way to achieve both these options? -- Regards Kumar Raja -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at semmle.com Sat May 20 11:06:13 2017 From: mark at semmle.com (Mark Shannon) Date: Sat, 20 May 2017 08:06:13 -0700 Subject: [code-quality] Open space at PyCon Message-ID: Hi all, I am planning to run an open space on static analysis at PyCon, this afternoon at 4pm. Everyone is invited. If you are coming, please check the open space board for location and in case I need to change the time. Cheers, Mark. From graffatcolmingov at gmail.com Sat May 20 11:45:45 2017 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Sat, 20 May 2017 10:45:45 -0500 Subject: [code-quality] Open space at PyCon In-Reply-To: References: Message-ID: Hi Mark! Could you or someone else take notes and post them here as a follow-up? I suspect there are a bunch of us who aren't at pycon who'd be interested in what happens. Cheers, Ian Please excuse my top-posting as I'm replying from my pbone On May 20, 2017 10:06 AM, "Mark Shannon" wrote: > Hi all, > > I am planning to run an open space on static analysis at PyCon, this > afternoon at 4pm. > Everyone is invited. > > If you are coming, please check the open space board for location and > in case I need to change the time. > > Cheers, > Mark. > _______________________________________________ > code-quality mailing list > code-quality at python.org > https://mail.python.org/mailman/listinfo/code-quality > -------------- next part -------------- An HTML attachment was scrubbed... URL: