How to install pylint

From EdnaWiki
Jump to: navigation, search

Stand-alone application of Pylint

Pylint "http://www.logilab.org/project/pylint" is a Python code analyser that checks for source for bugs and code of dubious quality.

Under an Ubuntu or a debian computer:

$ sudo aptitude install pylint

To analyse a piece of python just type:

$ pylint myCode.py

There is also a GUI version of Pylint called pylint-gui

Under Windows, download the installer for setup tools first from http://pypi.python.org/pypi/setuptools and run it. Using a command prompt window, navigate to the scripts sub-directory in the python installation and run

>easy_install.exe pylint


Coding convention

By default Pylint uses the coding convention of Logilab (with underscores), those in EDNA are with camelCase variable names. For this you will need to edit ~/.pylintrc and modify some parameters, I modified only few of them to be compatible with EDNA. Here is my complete configuration file for Pylint.

[MASTER]
profile=no
ignore=CVS
persistent=yes
cache-size=500
load-plugins=

[MESSAGES CONTROL]
disable-msg-cat=I
disable-msg=W0704

[REPORTS]
output-format=text
include-ids=no
files-output=no
reports=yes
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
comment=yes

[BASIC]
required-attributes=
no-docstring-rgx=__.*__
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
const-rgx=(([A-Za-z_][A-Za-z0-9_]*)|(__.*__))$
class-rgx=[A-Z_][a-zA-Z0-9]+$
function-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
method-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
attr-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
argument-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
variable-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
good-names=i,j,k,ex,Run,_,x,y,z
bad-names=foo,bar,baz,toto,tutu,tata
bad-functions=filter,apply,input

[VARIABLES]
init-import=no
dummy-variables-rgx=_|dummy
additional-builtins=

[TYPECHECK]
ignore-mixin-members=yes
ignored-classes=SQLObject
zope=no
generated-members=REQUEST,acl_users,aq_parent

[IMPORTS]
deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
import-graph=
ext-import-graph=
int-import-graph=

[DESIGN]
max-args=10
max-locals=25
max-returns=6
max-branchs=15
max-statements=50
max-parents=7
max-attributes=30
min-public-methods=2
max-public-methods=20

[CLASSES]
ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
defining-attr-methods=__init__,__new__,setUp

[MISCELLANEOUS]
notes=FIXME,XXX,TODO

[FORMAT]
max-line-length=200
max-module-lines=1000
indent-string='    '

[SIMILARITIES]
min-similarity-lines=4
ignore-comments=yes
ignore-docstrings=yes

Definition of your PYTHONPATH

This can be done by:

export PYTHONPATH=$PYTHONPATH:$EDNA_HOME/kernel/src:$EDNA_HOME/kernel/tests/src

Pylint under Eclipse

There is documentation on using Pylint in Pydev: http://pydev.org/manual_adv_pylint.html