Dev_Code checkers

willum070 edited this page Mar 6, 2014 · 1 revision

Notes on using PyLint

PyLint (, is a code checker that detects errors in Python code, helping to achieve a consistent coding standard. When you run PyLint on a .py file or module, it checks your code against an assortment of standards and generates a report.

From the virtual environment, PyLint installs with pip:

pip install pylint

At the time of writing, pip install PyLint 1.0.0 which has a severe issue on Windows with trailing whitespace: see A workaround is to manually update which is located under Lib\site-packages\pylint\checkers. Alternatively, use the --disable=trailing-whitespace option.

Using PyLint with CodaLab

To run PyLint against the entire CodaLab project: 1. Navigate to \codalab\codalab (wherever that is located on your local system). 1. Run pylint codalab to scan the entire project.

PyLint Tips

  • To output your report in HTML format, use the -f html option.
  • To pipe the report output into a file, use this syntax: pylint codalab -f html > results.html
  • Use the -rn option to omit the report tables.

Configure PyLint Rules

PyLint's rules are configurable. To generate a default config file:

pylint --generate-rcfile > .pylint-conf

To use the generated config (assuming .pylint-conf is located in the current directory):

pylint –-rcfile=.pylint-conf <module or package>

Below is a set of customizations that will make working with PyLint a bit easier.

  • Output format. PyLint can format its output multiple ways. I find the HTML format to be convenient.
  • Line length. PyLint enforces an 80 character line length by default. It is on the short side.
  • Number of methods on a class. PyLint likes at least two methods on a class. It also has an upper-limit which is too low when writing a class derived from TestCase for example.
  • Dealing with Django generated members such as objects:
  • The disable flag allows to turn off rules using their ID:
* R0921: Abstract class not references (

Related tools

pep8: Compared to PyLint, pep8 feels more lightweight in its feedback and probably too much so.