Pyflakes: static code analysis for Python 2
Pyflakes is a tool for finding mistakes in Python code. The code being examined is never executed, so results are fast and accurate. On the other hand, this won't catch everything.
from foo import bar # unused imports def my_function(): x = 1 # unused variables return i_dont_exist() # undefined functions
$ sudo python2 setup.py install
This will place the pyflakes script on your $PATH. You can then do:
$ pyflakes a_python_file.py
which will print any errors found. Alternatively, you can run pyflakes directly:
$ python2 pyflakes/scripts/pyflakes.py a_python_file.py
Pyflakes performs a purely syntactic analysis. For example, if you try to import from a non-existent file or access a non-existent object attribute, pyflakes will not produce an error.
pylint tries to solve a similar problem, but performs a dynamic analysis