Pylint -- so which is it?

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.)

* Stephen Satchell <list@satchell.net>, 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

Stephen Satchell <list@satchell.net> 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

On 04/04/2017 10:24 AM, Ben Finney wrote:
Stephen Satchell <list@satchell.net> 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???
participants (3)
-
Ben Finney
-
Jakub Wilk
-
Stephen Satchell