.TH PYCHECKER "1" "Jan 2011" "pychecker 0.8.19" "User Commands" .SH NAME \fBpychecker \fP- program to check python scripts for common mistakes .SH SYNOPSIS .nf .fam C \fBpychecker\fP [\fIoptions\fP] files\.\.\. .fam T .fi .SH DESCRIPTION This manual page documents briefly the \fBpychecker\fP command. It was written for the Debian GNU/Linux distribution because the original program does not have a manual page. .PP \fBpychecker\fP is a program that finds common 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. .PP \fBpychecker\fP 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. .SH CHOICE OF PYTHON VERSION .PP By default, the /usr/bin/pychecker script executes pychecker using the default Python interpreter in /usr/bin/python. Some users may want to run pychecker with a different Python interpreter. To accommodate this, the /usr/bin/pychecker script supports the use of $PYTHONVER on the command\-line, i.e. .TP .B PYTHONVER=2.3 pychecker file.py .PP If $PYTHONVER is set, /usr/bin/pychecker will attempt to execute pychecker using /usr/bin/python$PYTHONVER instead of /usr/bin/python. .PP Note, however, that this will only work for versions of the python interpreter supported by the current Debian Python infrastructure, not for any arbitrary Python interpreter installed in /usr/bin. .SH OPTIONS Long \fIoptions\fP can be preceded with no\- to turn off (e.g., no\-namedargs). Default settings are indicated by [brackets] .PP .SS "Major Options:" .TP \fB\-\-only\fR only warn about files passed on the command line [off] .TP \fB\-e\fR, \fB\-\-level\fR the maximum error level of warnings to be displayed .TP \-#, \fB\-\-limit\fR the maximum number of warnings to be displayed [10] .TP \fB\-F\fR, \fB\-\-config\fR specify .pycheckrc file to use .TP \fB\-\-quixote\fR support Quixote's PTL modules .TP \fB\-\-evil\fR list of evil C extensions that crash the interpreter [[]] .SS "Error Control:" .TP \fB\-i\fR, \fB\-\-import\fR unused imports [on] .TP \fB\-k\fR, \fB\-\-pkgimport\fR unused imports from __init__.py [on] .HP \fB\-M\fR, \fB\-\-reimportself\fR module imports itself [on] .TP \fB\-X\fR, \fB\-\-reimport\fR reimporting a module [on] .TP \fB\-x\fR, \fB\-\-miximport\fR module does import and from ... import [on] .TP \fB\-l\fR, \fB\-\-local\fR unused local variables, except tuples [on] .TP \fB\-t\fR, \fB\-\-tuple\fR all unused local variables, including tuples [off] .TP \fB\-9\fR, \fB\-\-members\fR all unused class data members [off] .TP \fB\-v\fR, \fB\-\-var\fR all unused module variables [off] .TP \fB\-p\fR, \fB\-\-privatevar\fR unused private module variables [on] .TP \fB\-g\fR, \fB\-\-allglobals\fR report each occurrence of global warnings [off] .TP \fB\-n\fR, \fB\-\-namedargs\fR functions called with named arguments (like keywords) [off] .TP \fB\-a\fR, \fB\-\-initattr\fR Attributes (members) must be defined in __init__() [off] .HP \fB\-I\fR, \fB\-\-initsubclass\fR Subclass.__init__() not defined [off] .TP \fB\-u\fR, \fB\-\-callinit\fR Baseclass.__init__() not called [on] .TP \fB\-0\fR, \fB\-\-abstract\fR Subclass needs to override methods that only throw exceptions [on] .TP \fB\-N\fR, \fB\-\-initreturn\fR Return None from __init__() [on] .TP \fB\-8\fR, \fB\-\-unreachable\fR unreachable code [off] .TP \fB\-2\fR, \fB\-\-constCond\fR a constant is used in a conditional statement [on] .TP \fB\-1\fR, \fB\-\-constant1\fR 1 is used in a conditional statement (if 1: or while 1:) [off] .TP \fB\-\-stringiter\fR check if iterating over a string [on] .TP \fB\-\-stringfind\fR check improper use of string.find() [on] .TP \fB\-A\fR, \fB\-\-callattr\fR Calling data members as functions [off] .TP \fB\-y\fR, \fB\-\-classattr\fR class attribute does not exist [on] .TP \fB\-S\fR, \fB\-\-self\fR First argument to methods [self] .HP \fB\-\-classmethodargs\fR First argument to classmethods [['cls', 'klass']] .TP \fB\-T\fR, \fB\-\-argsused\fR unused method/function arguments [on] .TP \fB\-z\fR, \fB\-\-varargsused\fR unused method/function variable arguments [on] .TP \fB\-G\fR, \fB\-\-selfused\fR ignore if self is unused in methods [off] .TP \fB\-o\fR, \fB\-\-override\fR check if overridden methods have the same signature [on] .TP \fB\-\-special\fR check if __special__ methods exist and have the correct signature [on] .TP \fB\-U\fR, \fB\-\-reuseattr\fR check if function/class/method names are reused [on] .TP \fB\-Y\fR, \fB\-\-positive\fR check if using unary positive (+) which is usually meaningless [on] .TP \fB\-j\fR, \fB\-\-moddefvalue\fR check if modify (call method) on a parameter that has a default value [on] .TP \fB\-\-changetypes\fR check if variables are set to different types [off] .TP \fB\-\-unpack\fR check if unpacking a non\-sequence [on] .TP \fB\-\-unpacklen\fR check if unpacking sequence with the wrong length [on] .TP \fB\-\-badexcept\fR check if raising or catching bad exceptions [on] .TP \fB\-4\fR, \fB\-\-noeffect\fR check if statement appears to have no effect [on] .TP \fB\-\-modulo1\fR check if using (expr % 1), it has no effect on integers and strings [on] .TP \fB\-\-isliteral\fR check if using (expr is const\-literal), doesn't always work on integers and strings [on] .SS "Possible Errors:" .HP \fB\-r\fR, \fB\-\-returnvalues\fR check consistent return values [on] .HP \fB\-C\fR, \fB\-\-implicitreturns\fR check if using implict and explicit return values [on] .TP \fB\-O\fR, \fB\-\-objattrs\fR check that attributes of objects exist [on] .TP \fB\-7\fR, \fB\-\-slots\fR various warnings about incorrect usage of __slots__ [on] .TP \fB\-3\fR, \fB\-\-properties\fR using properties with classic classes [on] .TP \fB\-\-emptyslots\fR check if __slots__ is empty [on] .TP \fB\-D\fR, \fB\-\-intdivide\fR check if using integer division [on] .TP \fB\-w\fR, \fB\-\-shadow\fR check if local variable shadows a global [on] .HP \fB\-s\fR, \fB\-\-shadowbuiltin\fR check if a variable shadows a builtin [on] .SS "Security:" .TP \fB\-\-input\fR check if input() is used [on] .TP \fB\-6\fR, \fB\-\-exec\fR check if the exec statement is used [off] .SS "Suppressions:" .TP \fB\-q\fR, \fB\-\-stdlib\fR ignore warnings from files under standard library [off] .TP \fB\-b\fR, \fB\-\-blacklist\fR ignore warnings from the list of modules [['Tkinter', 'wxPython', 'gtk', 'GTK', 'GDK']] .TP \fB\-Z\fR, \fB\-\-varlist\fR ignore global variables not used if name is one of these values [['__version__', '__warningregistry__', '__all__', '__credits__', '__test__', '__author__', '__email__', '__revision__', '__id__', '__copyright__', '__license__', '__date__']] .TP \fB\-E\fR, \fB\-\-unusednames\fR ignore unused locals/arguments if name is one of these values [['_', 'empty', 'unused', 'dummy']] .TP \fB\-\-deprecated\fR ignore use of deprecated modules/functions [on] .SS "Complexity:" .TP \fB\-L\fR, \fB\-\-maxlines\fR maximum lines in a function [200] .TP \fB\-B\fR, \fB\-\-maxbranches\fR maximum branches in a function [50] .TP \fB\-R\fR, \fB\-\-maxreturns\fR maximum returns in a function [10] .TP \fB\-J\fR, \fB\-\-maxargs\fR maximum # of arguments to a function [10] .TP \fB\-K\fR, \fB\-\-maxlocals\fR maximum # of locals in a function [40] .TP \fB\-5\fR, \fB\-\-maxrefs\fR maximum # of identifier references (Law of Demeter) [5] .TP \fB\-m\fR, \fB\-\-moduledoc\fR no module doc strings [off] .TP \fB\-c\fR, \fB\-\-classdoc\fR no class doc strings [off] .TP \fB\-f\fR, \fB\-\-funcdoc\fR no function/method doc strings [off] .SS "Debug:" .TP \fB\-\-rcfile\fR print a .pycheckrc file generated from command line args .TP \fB\-P\fR, \fB\-\-printparse\fR print internal checker parse structures [off] .TP \fB\-d\fR, \fB\-\-debug\fR turn on debugging for checker [off] .TP \fB\-Q\fR, \fB\-\-quiet\fR turn off all output except warnings [off] .TP \fB\-V\fR, \fB\-\-version\fR print the version of PyChecker and exit .SH AUTHOR Pychecker was written by Neal Norwitz and Eric C. Newton. Other contributors are listed in .B /usr/share/doc/pychecker/MAINTAINERS This manual page was written by Fredrik Steen for the Debian GNU/Linux system (but may be used by others). It has been subsequently modified by Kenneth J. Pronovici . .SH "SEE ALSO" \fBpython\fP(1) Running .B pychecker \-\-help may provide more complete documentation of program options. The pychecker web page at .B contains some guidance on using the program.