From list at satchell.net Mon Apr 3 14:27:54 2017 From: list at satchell.net (Stephen Satchell) Date: Mon, 3 Apr 2017 11:27:54 -0700 Subject: [code-quality] Pylint -- so which is it? Message-ID: I have a python2.7 project, and when I run PyLint 1.5.2, astroid 1.3.3 on files, I get a Catch-22 situation. When I have: import logging import pexpct import re import time I get messages about wrong import order, specifically that re and time comes after pexpect. OK, apply the obvious fix: import logging import re import time import pexect and now the diagnostics I get are "standard import "re" comes before "pexpect". ditto "time". Can't win for losing. So how do I fix this, other than abandoning programming and take up advanced backet-weaving as a profession? :) (Yes, I did check back six months in the mailing list archives, and didn't see any discussion.) From ben+python at benfinney.id.au Tue Apr 4 13:24:45 2017 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 05 Apr 2017 03:24:45 +1000 Subject: [code-quality] Pylint -- so which is it? References: Message-ID: <8560ikdr1e.fsf@benfinney.id.au> Stephen Satchell writes: > I have a python2.7 project, and when I run PyLint 1.5.2, astroid 1.3.3 I have:: $ pylint --version No config file found, using default configuration pylint 1.6.5, astroid 1.4.9 Python 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118] > When I have: > import logging > import pexpct > import re > import time > > I get messages about wrong import order, specifically that re and time > comes after pexpect. You've got a different name than ?pexpect?, there. I wonder whether you actually tried that code? When I correct the name to ?pexpect?, I get:: $ cat foo.py import logging import pexpect import re import time $ pylint foo.py No config file found, using default configuration ************* Module foo C: 1, 0: Black listed name "foo" (blacklisted-name) C: 1, 0: Missing module docstring (missing-docstring) W: 1, 0: Unused import logging (unused-import) W: 2, 0: Unused import pexpect (unused-import) W: 3, 0: Unused import re (unused-import) W: 4, 0: Unused import time (unused-import) C: 3, 0: standard import "import re" comes before "import pexpect" (wrong-import-order) C: 4, 0: standard import "import time" comes before "import pexpect" (wrong-import-order) > OK, apply the obvious fix: > import logging > import re > import time > > import pexect > > and now the diagnostics I get are "standard import "re" comes before > "pexpect". ditto "time". Again, a different name from ?pexpect?. Did you actually try that code? When I correct the name to ?pexpect?, I get:: $ cat bar.py import logging import re import time import pexpect $ pylint bar.py No config file found, using default configuration ************* Module bar C: 1, 0: Black listed name "bar" (blacklisted-name) C: 1, 0: Missing module docstring (missing-docstring) W: 1, 0: Unused import logging (unused-import) W: 2, 0: Unused import re (unused-import) W: 3, 0: Unused import time (unused-import) W: 5, 0: Unused import pexpect (unused-import) > So how do I fix this, other than abandoning programming and take up > advanced backet-weaving as a profession? :) I suspect the problem is related to something you're not showing us, because the code you showed does not produce the problem you described. Please make an extremely minimal example ? like the ones you've shown here ? that you actually run and demonstrate the problem behaviour. -- \ ?If nature has made any one thing less susceptible than all | `\ others of exclusive property, it is the action of the thinking | _o__) power called an idea? ?Thomas Jefferson, 1813-08-13 | Ben Finney From jwilk at jwilk.net Tue Apr 4 11:04:58 2017 From: jwilk at jwilk.net (Jakub Wilk) Date: Tue, 4 Apr 2017 17:04:58 +0200 Subject: [code-quality] Pylint -- so which is it? In-Reply-To: References: Message-ID: <20170404150458.wlc2qu4hqjcgqzo6@jwilk.net> * Stephen Satchell , 2017-04-03, 11:27: >I have a python2.7 project, and when I run PyLint 1.5.2, astroid 1.3.3 That's an unlikely combination. This version of Pylint requires astroid >= 1.4. >When I have: > import logging > import pexpct > import re > import time > >I get messages about wrong import order, specifically that re and time comes >after pexpect. After fixing the typo, I get: C: 3, 0: standard import "import re" comes before "import pexpect" (wrong-import-order) C: 4, 0: standard import "import time" comes before "import pexpect" (wrong-import-order) ...which seems backwards? The problem is that these imports are AFTER "import pexpect", but they should be before. >OK, apply the obvious fix: > import logging > import re > import time > > import pexect This looks fine to me, except for another typo. And indeed, I don't get any warnings about import order this time. >So how do I fix this, I'd start with producing a complete, minimal example, so that other people can reproduce the bug you're seeing. :) -- Jakub Wilk From list at satchell.net Tue Apr 4 20:57:57 2017 From: list at satchell.net (Stephen Satchell) Date: Tue, 4 Apr 2017 17:57:57 -0700 Subject: [code-quality] Pylint -- so which is it? [FIXED] In-Reply-To: <8560ikdr1e.fsf@benfinney.id.au> References: <8560ikdr1e.fsf@benfinney.id.au> Message-ID: <6da0d9d6-7cd5-ad94-9884-bbecc9056247@satchell.net> On 04/04/2017 10:24 AM, Ben Finney wrote: > Stephen Satchell writes: > >> I have a python2.7 project, and when I run PyLint 1.5.2, astroid 1.3.3 The fix for my import-order problem, where I got conflicting messages about where "pexpect" should be in the list, proved to be tedious and somewhat painful, but it meant I'm using a later version of PyLint. Loaded a virtual machine with Fedora 25 Workstation Edition and went with the PyLint provided by that distribution: pylint 1.6.4 astroid 1.4.5 python 2.7.13 Also, all my import problems went away. Happy camper here. Even if I have to now remove the final new-line from my .py files. Cf. https://bitbucket.org/logilab/pylint/issue/682 I can live with that. I end my program files with #==30== to avoid some issues with editors making the last line difficult to edit for this old guy, so whether the \n is there or not is unimportant. Just how far behind are the various distributions in their PyLint versions??? From josh.powers at canonical.com Thu Apr 6 17:30:35 2017 From: josh.powers at canonical.com (Josh Powers) Date: Thu, 6 Apr 2017 14:30:35 -0700 Subject: [code-quality] W0602 global-variable-not-assigned Message-ID: Hi, I have code similar to [1] where instead of directly assigning a dictionary global variable the dictionary method update is used. Right now this results in a W0602 global-variable-not-assigned. Is this expected behavior and if so is there a better way to write the above? The actual code giving me this message is in cloud-init [2]. [1] https://paste.ubuntu.com/24330114/ [2] https://github.com/cloud-init/cloud-init/blob/master/cloudinit/util.py#L114 --- Josh Powers Ubuntu Server Canonical Ltd -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwilk at jwilk.net Thu Apr 6 18:27:36 2017 From: jwilk at jwilk.net (Jakub Wilk) Date: Fri, 7 Apr 2017 00:27:36 +0200 Subject: [code-quality] W0602 global-variable-not-assigned In-Reply-To: References: Message-ID: <20170406222736.5pseyk4j5qglao4c@jwilk.net> * Josh Powers , 2017-04-06, 14:30: >I have code similar to [1] where instead of directly assigning a dictionary >global variable the dictionary method update is used. Right now this results >in a W0602 global-variable-not-assigned. > >Is this expected behavior and if so is there a better way to write the above? Yes. The global statement only affects variable assignments. If you don't assign to the variable, the global statement doesn't do anything and can be removed. -- Jakub Wilk From marc at rintsch.de Thu Apr 6 18:47:12 2017 From: marc at rintsch.de (Marc 'BlackJack' Rintsch) Date: Fri, 7 Apr 2017 00:47:12 +0200 Subject: [code-quality] W0602 global-variable-not-assigned In-Reply-To: References: Message-ID: <7929c70e-ff91-4c1f-17d0-2928392b6367@rintsch.de> On 06/04/17 23:30, Josh Powers wrote: > Hi, > > I have code similar to [1] where instead of directly assigning a > dictionary global variable the dictionary method update is used. Right > now this results in a W0602 global-variable-not-assigned. > > Is this expected behavior and if so is there a better way to write the > above? Yes it is expected (IMHO) and the way to avoid this warning is to remove the unnecessary ``global`` declaration. You don't assign a value to the name, so don't declare it as ``global``. Ciao, Marc 'BlackJack' Rintsch -- ?Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.? -- Alan J. Perlis -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: From pcmanticore at gmail.com Thu Apr 13 11:34:09 2017 From: pcmanticore at gmail.com (Claudiu Popa) Date: Thu, 13 Apr 2017 18:34:09 +0300 Subject: [code-quality] Pylint 1.7.0 was released Message-ID: Hey folks, We just released a new version of Pylint, 1.7.0, after a long period of time since the last release. You can find more details about what's new in this release over here: https://pylint.readthedocs.io/en/latest/whatsnew/1.7.html Thanks and enjoy, Claudiu -------------- next part -------------- An HTML attachment was scrubbed... URL: From shenglior at 126.com Mon Apr 17 05:16:46 2017 From: shenglior at 126.com (=?GBK?B?1cXKpMD7?=) Date: Mon, 17 Apr 2017 17:16:46 +0800 (CST) Subject: [code-quality] Bug Report: pylint on Windows has problems dealing with Python directory with spaces Message-ID: <46a93ca7.9346.15b7b333b95.Coremail.shenglior@126.com> Hi pylint team: Bug Report: pylint on Windows has problems dealing with Python directory with spaces. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pylint-windows.png Type: image/png Size: 16117 bytes Desc: not available URL: From m.overmeyer at yahoo.ca Wed Apr 19 13:41:37 2017 From: m.overmeyer at yahoo.ca (Michael Overmeyer) Date: Wed, 19 Apr 2017 17:41:37 +0000 (UTC) Subject: [code-quality] Proposal to extend pylintrc syntax to allow multiple disable/enable parameters References: <907849885.4081919.1492623697588.ref@mail.yahoo.com> Message-ID: <907849885.4081919.1492623697588@mail.yahoo.com> Hello, I'm trying to set up my build system to use pylintrc files during the build. For example, in my pylintrc file I was going to do something like: ``` disable=all enable=E disable=import-error ``` Which (of course) doesn't work: ``` $>pylint --rcfile=pylintrc my_file.py ??? ??? backports.configparser.DuplicateOptionError: While reading from 'pylintrc' [line 24]: option u'disable' in section u'MESSAGES CONTROL' already exists ``` Once I realised that they are INI files, it made more sense. INI files do not allow for multiple values for a key (within a section), and different parsers handle this case differently. Since strict=True was being used by the Python parser, it raise this exception. The annoying part is that you can pass multiple 'enable/disable' arguments on the command line. In fact, there is an example in the documentation auto-generated by `pylint --generate-rcfile`: ??? "If you want to run only the classes checker, but have no Warning level messages displayed, use '--disable=all --enable=classes --disable=W'" ??? But this cannot be done in the pylintrc file. Annoying, since I was not going to use the command line and changing my build system to do would be non-trivial. I would like to see the pylintrc file have at least as much capability as the command line. I would like to propose to extend the syntax to provide an ordering. Proposal: Today we have "disable" and "enable", with "enable" taking precedent. Perhaps we could change the syntax to be "disableX" "enableY", with X and Y being positive integers. Higher precedence would be determined by higher integers. "enable" would still have precedent within a given integer level. It would be backwards compatible, with 'disable' being an alias for 'disable1' and 'enable' being an alias for 'enable1'. Some examples: ``` disable=all enable=classes disable2=W ``` would be equivalent to: ``` disable1=all enable1=classes disable2=W ``` There could easily be a better way to do that this, or some pattern/syntax people already use when dealing with INI files in order to work around this. I would like to see the pylintrc file have at least as much capability as the command line. Let me know what you think, Michael Overmeyer -------------- next part -------------- An HTML attachment was scrubbed... URL: From Mark.Syms at citrix.com Thu Apr 20 12:18:30 2017 From: Mark.Syms at citrix.com (Mark Syms) Date: Thu, 20 Apr 2017 16:18:30 +0000 Subject: [code-quality] Why does pylint flag this? Message-ID: <37f047620fd343458ab7bd7106801362@AMSPEX02CL02.citrite.net> We've recently started to see pylint flag issues on a piece of code that looks similar to this - --------------------------------------- #!/bin/python """ Test the TemporaryFile iterator """ import os import tempfile with tempfile.TemporaryFile() as nullfh: nullfh.write(b'Hello world!') nullfh.seek(0, os.SEEK_SET) for line in nullfh: line = line.strip() print line --------------------------------------- With pylint 1.7.1, astroid 1.5.2 Python 2.7.5 (default, Nov 6 2016, 00:28:07) This reports - E: 13,16: Non-iterable value nullfh is used in an iterating context (not-an-iterable) However the code is functional so nullfh does work in the iterating context. Any clues as to why this is being flagged would be appreciated. Thanks, Mark. From ben+python at benfinney.id.au Thu Apr 20 15:53:53 2017 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 21 Apr 2017 05:53:53 +1000 Subject: [code-quality] Why does pylint flag this? References: <37f047620fd343458ab7bd7106801362@AMSPEX02CL02.citrite.net> Message-ID: <85r30m97ou.fsf@benfinney.id.au> Mark Syms writes: > E: 13,16: Non-iterable value nullfh is used in an iterating context (not-an-iterable) Bear in mind that PyLint performs static analysis; it doesn't execute the code, and so does not have access to the Python objects that running statements produce. Since Python objects are dynamically typed, a static analysis cannot be certain of the type of any object. > However the code is functional so nullfh does work in the iterating > context. I expect PyLint makes an incorrect guess about the type of the return value from ?tempfile.TemporaryFile()?. -- \ ?You can never entirely stop being what you once were. That's | `\ why it's important to be the right person today, and not put it | _o__) off until tomorrow.? ?Larry Wall | Ben Finney From kevin.hock.opentoall at gmail.com Fri Apr 21 02:45:14 2017 From: kevin.hock.opentoall at gmail.com (Kevin Hock) Date: Fri, 21 Apr 2017 02:45:14 -0400 Subject: [code-quality] New Static Analysis Security Tool Message-ID: Hi, I just wanted to send you a link to a Python security project you or coworkers might be interested in https://github.com/python-security/pyt -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwilk at jwilk.net Sat Apr 22 15:10:23 2017 From: jwilk at jwilk.net (Jakub Wilk) Date: Sat, 22 Apr 2017 21:10:23 +0200 Subject: [code-quality] New Static Analysis Security Tool In-Reply-To: References: Message-ID: <20170422191022.h73vgda6lzdcgsrl@jwilk.net> * Kevin Hock , 2017-04-21, 02:45: >I just wanted to send you a link to a Python security project you or coworkers >might be interested in https://github.com/python-security/pyt That's an unfortunate name. There's an unrelated project named "pyt" already on PyPI: https://pypi.python.org/pypi/pyt -- Jakub Wilk From amir at rachum.com Sun Apr 23 14:52:54 2017 From: amir at rachum.com (Amir Rachum) Date: Sun, 23 Apr 2017 21:52:54 +0300 Subject: [code-quality] Pydocstyle 2.0.0 released Message-ID: Hi friends, Pydocstyle 2.0.0 was released and the new major version includes numpy convention support! You can find the full release notes here: http://www.pydocstyle.org/en/latest/release_notes.html#april-18th-2017 If you find any issues with this (or any other) version, please report them at our GitHub repo at: https://github.com/PyCQA/pydocstyle Cheers! Amir Rachum -------------- next part -------------- An HTML attachment was scrubbed... URL: From diek at bellaliant.net Thu Apr 27 18:46:09 2017 From: diek at bellaliant.net (diek) Date: Thu, 27 Apr 2017 19:46:09 -0300 Subject: [code-quality] Flake8 and Python 3 Message-ID: Good Day,? I have searched and read some posts on reddit and stack but I cannot get flake8 to use Python3. I looked at your docs, but I cannot find it. ?I am using a Python3 virtualenv, and I pip installed Flake8. Flake8 is installed: _env/lib/python3.6/site-packages/flake8/utils.py Running version: 3.3.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.5.0) CPython 2.7.13 on Darwin It is showing errors for items that are valid syntax. I require both Python 2 and 3 on my computer. I am sure I am not the first person to have this issue, please how do I resolve this? Thank you, derrick? -------------- next part -------------- An HTML attachment was scrubbed... URL: From graffatcolmingov at gmail.com Thu Apr 27 19:48:15 2017 From: graffatcolmingov at gmail.com (Ian Cordasco) Date: Thu, 27 Apr 2017 18:48:15 -0500 Subject: [code-quality] Flake8 and Python 3 In-Reply-To: References: Message-ID: On Thu, Apr 27, 2017 at 5:46 PM, diek wrote: > Good Day, > I have searched and read some posts on reddit and stack but I cannot get > flake8 to use Python3. I looked at your docs, but I cannot find it. I am > using a Python3 virtualenv, and I pip installed Flake8. > Flake8 is installed: > _env/lib/python3.6/site-packages/flake8/utils.py > Running version: > 3.3.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.5.0) CPython 2.7.13 on > Darwin This tells me that the version of Flake8 that is being run is not the one in your virtual environment. > It is showing errors for items that are valid syntax. I require both Python > 2 and 3 on my computer. If python points to the virtualenv python, try using the documented method of python -m flake8 Cheers! From edreamleo at gmail.com Fri Apr 28 04:25:19 2017 From: edreamleo at gmail.com (Edward K. Ream) Date: Fri, 28 Apr 2017 03:25:19 -0500 Subject: [code-quality] Thanks for pyflakes Message-ID: I just wanted to thank the pyflakes devs for having written the most useful checker in the python world. Pyflakes catches roughly 90% of the programming blunders I make, before ever I run the code. My configuration of Leo ensures that: - pyflakes checks all changed .py files as Leo writes them, - Leo raises a dialog so that I can't ignore pyflakes warnings :-) ?In other words, the pyflakes warnings are so important that it's worthwhile to stop everything and deal with them. 11 months ago I studied pyflakes in detail in this repo . The introductory remarks called pyflakes a work of genius. My admiration for pyflakes has only grown since then. At that time I suggested some changes that would make pyflakes about 10% faster at the cost of making the code more complex. I regret making those suggestions. Pyflakes is plenty fast, even on Leo's biggest source files, some of which are almost 300K in size. Again, thank you for a truly great tool. Edward ------------------------------------------------------------------------------------------ Edward K. Ream: edreamleo at gmail.com Leo: http://leoeditor.com/ ------------------------------------------------------------------------------------------ -------------- next part -------------- An HTML attachment was scrubbed... URL: