pylint woes

Steven D'Aprano steve at pearwood.info
Sat May 7 23:25:54 EDT 2016


On Sun, 8 May 2016 02:51 am, DFS wrote:

> This more-anal-than-me program generated almost 2 warnings for every
> line of code in my program.  w t hey?
> 
> 
>                                            DFS comments
> +-------------------------+------------+ -------------------------------
> |message id               |occurrences |
> +=========================+============+
> |mixed-indentation        |186         | I always use tab

Obviously not. There are 186 occurrences where you use mixed tabs and
spaces.

Try running Tabnanny on you file:

python -m tabnanny <path to your file>


> +-------------------------+------------+
> |invalid-name             |82          | every single variable name?!

Maybe. What are they called?


> +-------------------------+------------+
> |bad-whitespace           |65          | mostly because I line up =
>                                           signs:
>                                           var1  = value
>                                           var10 = value

Yuck. How much time do you waste aligning assignments whenever you add or
delete or edit a variable?


> +-------------------------+------------+
> |trailing-whitespace      |59          | heh!
> +-------------------------+------------+
> |multiple-statements      |23          | do this to save lines.
>                                           Will continue doing it.

Why? Do you think that there's a world shortage of newline characters? Is
the Enter key on your keyboard broken?


> +-------------------------+------------+
> |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?

*shrug* More likely with Pylint.


> +-------------------------+------------+
> |line-too-long            |5           | meh
> +-------------------------+------------+
> |wrong-import-order       |4           | does it matter?

Probably not. I'm curious what it thinks is the right import order.



> +-------------------------+------------+
> |missing-docstring        |4           | what's the difference between
>                                           a docstring and a # comment?

Comments exist only in the source code.

Docstrings are available for interactive use with help(), for runtime
introspection, and for doctests.

https://docs.python.org/2/library/doctest.html


> +-------------------------+------------+
> |multiple-imports         |2           | doesn't everyone?

You mean something like this?

import spam, ham, eggs, cheese

*shrug* It's a style thing.


> +-------------------------+------------+
> |consider-using-enumerate |2           | see below [1]

Absolutely use enumerate.


> +-------------------------+------------+
> |bad-builtin              |2           | warning because I used filter?

Well that's just stupid. Bad PyLint. This should absolutely not be turned on
by default.


-- 
Steven




More information about the Python-list mailing list