
PyChecker is a tool for finding bugs in python source code.
It finds problems that are typically caught by a compiler for less
dynamic languages, like C and C++.  Because of the dynamic nature
of python, some warnings may be incorrect; however,
spurious warnings should be fairly infrequent.

PyChecker works in a combination of ways.  First, it imports each
module.  If there is an import error, the module cannot be processed.
The import provides some basic information about the module.  The code
for each function, class, and method is checked for possible problems.

Types of problems that can be found include:

  * No global found (e.g., using a module without importing it)
  * Passing the wrong number of parameters to functions/methods/constructors
  * Using format strings that don't match arguments
  * Using class methods and attributes that don't exist
  * Changing signature when overriding a method
  * Redefining a function/class/method in the same scope
  * Using a variable before setting it
  * self not the first parameter to a method
  * Unused globals and locals (module or variable)
  * Unused function/method arguments (can ignore self)
  * No doc strings in modules, classes, functions, and methods

To use PyChecker, pass the python source files you want to check
on the command line:

	python pychecker/checker.py file1.py file2.py ...

If there are import dependencies in your source files, you should
import those files first on the command line in order to get as many
files checked as possible.

PyChecker works with Python 1.5.2, 2.0, and 2.1.

You can use the test files as examples:

	python pychecker/checker.py test_input/*.py

If you want to change the default behaviour, you can pass command line options
or define a .pycheckrc file.  For an example, look at pycheckrc.

To show the available options, do:

	python pychecker/checker.py -h

If you want to suppress warnings on a module/function/class/method,
you can define a suppressions dictionary in .pycheckrc.
Examples of keys are:  'module', 'module.function',
		       'module.class', 'module.class.method', etc.

You can also define suppressions in your code by doing:

	__pychecker__ = 'no-namedargs maxlines=0 maxreturns=0'

The format for __pychecker__ values and values in the suppressions dictionary
are the same.  Dashes (--) are optional when preceding long option names.

If you find a bug in PyChecker, meaning you see something like:

	python pychecker/checker.py myfile.py

	myfile.py:13 INTERNAL ERROR -- STOPPED PROCESSING FUNCTION --
        Traceback (most recent call last):
          File "./pychecker/warn.py", line 364, in _checkFunction
            stack, oparg, lastLineNum)
          File "./pychecker/warn.py", line 195, in _handleFunctionCall
            kwArgs.append(stack[i].data)
        IndexError: list index out of range

Please send mail indicating the version of PyChecker, *your source file*
which broke PyChecker (myfile.py in the example above), and the traceback.
It is very helpful to provide a simple test case to demonstrate the problem.
It helps to have the entire file and all the dependencies if you cannot
produce a simple test case.  But if you can't provide a test case nor
the file(s), I may be able to figure out the problem with just the line
which broke PyChecker (myfile.py:13 in the example above).

Good Luck!  As always, feedback is greatly appreciated.

Neal
pychecker@metaslash.com

PyChecker can be found on SourceForge at:
	http://pychecker.sourceforge.net/
	http://sourceforge.net/projects/pychecker

