[code-quality] Pylint -- so which is it?
Ben Finney
ben+python at benfinney.id.au
Tue Apr 4 13:24:45 EDT 2017
Stephen Satchell <list at 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
More information about the code-quality
mailing list