PyLint Best Practices?

amit picture amit · Dec 9, 2010 · Viewed 29.1k times · Source

pyLint looks like a good tool for running analysis of python code. However, our main objective is to catch any potential bugs and not coding convention. Enabling all pyLint check seems to generate lot of noise. Any suggestions on a set of pyLint features you use and is effective?

Answer

muckabout picture muckabout · Dec 9, 2010

You can block any warnings/errors you don't like, via:

pylint --disable=error1,error2

I've blocked the following (description from http://www.logilab.org/card/pylintfeatures):

W0511: Used when a warning note as FIXME or XXX is detected

W0142: Used * or * magic* Used when a function or method is called using *args or **kwargs to dispatch arguments. This doesn't improve readability and should be used with care.

W0141: Used builtin function %r Used when a black listed builtin function is used (see the bad-function option). Usual black listed functions are the ones like map, or filter , where Python offers now some cleaner alternative like list comprehension.

R0912: Too many branches (%s/%s) Used when a function or method has too many branches, making it hard to follow.

R0913: Too many arguments (%s/%s) Used when a function or method takes too many arguments.

R0914: Too many local variables (%s/%s) Used when a function or method has too many local variables.

R0903: Too few public methods (%s/%s) Used when class has too few public methods, so be sure it's really worth it.

W0212: Access to a protected member %s of a client class Used when a protected member (i.e. class member with a name beginning with an underscore) is access outside the class or a descendant of the class where it's defined.

W0312: Found indentation with %ss instead of %ss Used when there are some mixed tabs and spaces in a module.

C0111: Missing docstring Used when a module, function, class or method has no docstring. Some special methods like __init__ don't necessarily require a docstring.

C0103: Invalid name "%s" (should match %s) Used when the name doesn't match the regular expression associated to its type (constant, variable, class...).