views:

987

answers:

5

Hi,

I am python newbie. Can ppl point towards good OSS for automated decent python code review tools. I am churning quite some python code these days. Want to pass it thru some quality tool.

Thanks


Related question: Are there any static analysis tools for Python?

+5  A: 

pylint -- analyzes Python source code looking for bugs and signs of poor quality.

J.F. Sebastian
I like this honest description. The tool _looks_ for bugs (may not find them) and looks for _signs_ of poor quality (not "proof").Apply the tool but then review the results and only make changes to code based on the tool's warnings if the changes are truly code improvements.
talkaboutquality
+4  A: 

Also take a look at pep8 for the "official" style guide. Having consistent style throughout your code always helps maintain quality.

You can also google up some pep8.py scripts to automate the style checking.

JimB
I like using two space instead of four to intend.
Ankur Gupta
+1  A: 

Related Thread http://stackoverflow.com/questions/35470/are-there-any-static-analysis-tools-for-python (Stumbled on it later)

Ankur Gupta
best to just go back and edit the question, rather than 'answering' yourself. The basic idea here at stackoverflow is that answers duke it out via voting to become the 'one true answer', so the link to related info will get lost down the answer stack.
reedstrm
A: 

I personally use pyflakes.

It checks for the following:

  • Syntax errors
  • Missing names (variables or objects or whatever referenced without having been set or imported)

Substantially it does save you from typos and the such, which are the most common source of errors for me.

It does not check for the following:

  • If your imports are correct (which might be a problem, due to the fact I use virtual environments a lot)
  • If the variables are set before accessing it

Substantially, is a static code checker.

+8  A: 

At work, we use a combination of pylint, unittest, and Ned Batchelder's coverage module.

These are automatically run on every svn commit (you are using source control, right?), and an email gets shot to a developer if they fail pylint or unit tests. Every commit gets the unit tests run through coverage, and the coverage reports are available for everyone to use (we've customized them a bit, so that they're in easy-to-read HTML format).

Tony Arkles
There is _so_ much hidden in that word "use" in "...available for everyone to use". Definitely use these tools, but "use" has to mean that the developer (a) reviews the failed results, understands the root cause, and improves the code and (b) reviews results that are passing too often to turn up the strength on the tools so they can find more problems.
talkaboutquality
To clarify then: our automated build process is set up to execute each of these tools for every version control commit. We've established a set of rules (primarily pylint ignore rules) that every commit needs to satisfy, and changing these rules requires team consent.
Tony Arkles