pylint woes
DFS
nospam at dfs.com
Sat May 7 23:28:54 EDT 2016
On 5/7/2016 3:40 PM, Terry Reedy wrote:
> On 5/7/2016 12:51 PM, DFS wrote:
>> This more-anal-than-me program generated almost 2 warnings for every
>> line of code in my program. w t hey?
>
> If you don't like it, why do you use it?
I've never used it before last night. I was shocked at what it spewed
back at me.
> I suppose the answer is that it did find a few things to check. You
> might be happier with pychecker, which is much less aggressive.
I'll give it a shot.
> I believe will find the things you did fix.
I'm not parsing this statement. You mean pychecker will find the same
things pylint found, and that I fixed?
If it finds them after I fixed them... it's a magical program :)
DFS comments
>> +-------------------------+------------+ -------------------------------
>> |message id |occurrences |
>> +=========================+============+
>> |mixed-indentation |186 | I always use tab
>> +-------------------------+------------+
>> |invalid-name |82 | every single variable name?!
>
> I would need examples to comment.
Invalid constant name "cityzip" (invalid-name)
Invalid constant name "state" (invalid-name)
Invalid constant name "miles" (invalid-name)
Invalid constant name "store" (invalid-name)
Invalid variable name "rs" (invalid-name)
>> +-------------------------+------------+
>> |trailing-whitespace |59 | heh!
>
> Any code editor should have a command to fix this.
> IDLE: Format => strip trailing whitespace
> Notepad++: Macro => trim trailing and save, Alt-Shift-S
> others ...
That did it.
>> +-------------------------+------------+
>> |no-member |5 |
>>
>> "Module 'pyodbc' has no 'connect' member" Yes it does.
>> "Module 'pyodbc' has no 'Error' member" Yes it does.
>>
>> Issue with pylint, or pyodbc?
>
> Worth looking into. Could be a bug somewhere. But I don't have pyodbc
> installed.
>
>> +-------------------------+------------+
>> |line-too-long |5 | meh
>
> For following the PEP guideline when patching CPython, this is helpful.
>
>> +-------------------------+------------+
>> |wrong-import-order |4 | does it matter?
>
> Consistency in imports ultimately makes easier reading.
> Many idlelib files use this order: stdlib modules other than tkinter and
> idlelib (alphabetically); tkinter (tkinter first, then submodules);
> idlelib (alphabetically). When I edit files, I sometimes reorder
> imports to conform.
It complains 2x about this:
import os, sys, time, datetime
import pyodbc, sqlite3
import re, requests
from lxml import html
But I think there are some pylint bugs here:
-------------------------------------------------------------------------
standard import "import pyodbc, sqlite3" comes before "import pyodbc,
sqlite3" (wrong-import-order)
* complains that the line comes before itself?
-------------------------------------------------------------------------
standard import "import re, requests" comes before "import pyodbc,
sqlite3" (wrong-import-order)
* So I switched them, and then it complained about that:
standard import "import pyodbc, sqlite3" comes before "import re,
requests" (wrong-import-order)
-------------------------------------------------------------------------
You can't win with pylint...
And, the author probably isn't a native English-speaker, since when he
says 'comes before' I think he means 'should come before'.
>> +-------------------------+------------+
>> |missing-docstring |4 | what's the difference between
>> a docstring and a # comment?
>
> # Comments only appear in the source
> '''Docstrings are copied to the compiled code object, are interactively
> accessible, and are used for help(ojb) output.'''
>
>
>> +-------------------------+------------+
>> |superfluous-parens |3 | I like to surround 'or'
>> statments with parens
>
> I would need examples to comment
if ("Please choose a state" in str(matches)):
if (var == "val" or var2 == "val2"):
>> +-------------------------+------------+
>> |bad-builtin |2 | warning because I used filter?
>
> If they are still doing this in the latest release, it is an arrogance
> and inconsistency bug on their part. Disable this check.
$ pylint --version
No config file found, using default configuration
pylint 1.5.5,
astroid 1.4.5
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500
32 bit (Intel)]
It says "Used builtin function 'filter'. Using a list comprehension can
be clearer. (bad-builtin)"
>> +-------------------------+------------+
>> |missing-final-newline |1 | I'm using Notepad++, with
>> EOL Conversion set to
>> 'Windows Format'.
>
> That says to replace final '\n' with '\r\n'. It does not affect a
> missing final newline ;-)
>
> How or should I fix this?
>
> Fix by hitting 'Enter' at the end of the last line.
> Should you? I think it a good habit.
Done
>> After fixes and disabling various warnings:
>> "Your code has been rated at 8.37/10"
>
> Being able to customize pylint by turning off warnings is its saving
> feature.
Yes. If I had to see 300-350 lines of output every time I wouldn't ever
use it again.
Overall, I do like a majority of the things it suggested.
More information about the Python-list
mailing list