1 pep8 - Python style guide checker
2 =================================
4 pep8 is a tool to check your Python code against some of the style conventions
7 .. _PEP 8: http://www.python.org/dev/peps/pep-0008/
12 http://groups.google.com/group/pep8
18 * Plugin architecture: Adding new checks is easy.
20 * Parseable output: Jump to error location in your editor.
22 * Small: Just one Python file, requires only stdlib. You can use just the
23 pep8.py file for this purpose.
25 * Easy_installable, of course!
31 Just an ``easy_install pep8`` ought to do the trick.
34 Example usage and output
35 ------------------------
40 optparse.py:69:11: E401 multiple imports on one line
41 optparse.py:77:1: E302 expected 2 blank lines, found 1
42 optparse.py:88:5: E301 expected 1 blank line, found 0
43 optparse.py:222:34: W602 deprecated form of raising exception
44 optparse.py:347:31: E211 whitespace before '('
45 optparse.py:357:17: E201 whitespace after '{'
46 optparse.py:472:29: E221 multiple spaces before operator
47 optparse.py:544:21: W601 .has_key() is deprecated, use 'in'
49 You can also make pep8.py show the source code for each error, and
50 even the relevant text from PEP 8::
52 $ pep8 --show-source --show-pep8 testsuite/E111.py
53 testsuite/E111.py:2:3: E111 indentation is not a multiple of four
56 Use 4 spaces per indentation level.
58 For really old code that you don't want to mess up, you can
59 continue to use 8-space tabs.
61 Or you can display how often each error was found::
63 $ pep8 --statistics -qq --filename=*.py Python-2.5/Lib
64 232 E201 whitespace after '['
65 599 E202 whitespace before ')'
66 631 E203 whitespace before ','
67 842 E211 whitespace before '('
68 2531 E221 multiple spaces before operator
69 4473 E301 expected 1 blank line, found 0
70 4006 E302 expected 2 blank lines, found 1
71 165 E303 too many blank lines (4)
72 325 E401 multiple imports on one line
73 3615 E501 line too long (82 characters)
74 612 W601 .has_key() is deprecated, use 'in'
75 1188 W602 deprecated form of raising exception
77 Quick help is available on the command line::
80 Usage: pep8.py [options] input ...
83 --version show program's version number and exit
84 -h, --help show this help message and exit
85 -v, --verbose print status messages, or debug with -vv
86 -q, --quiet report only file names, or nothing with -qq
87 -r, --repeat show all occurrences of the same error
88 --exclude=patterns exclude files or directories which match these comma
89 separated patterns (default: .svn,CVS,.bzr,.hg,.git)
90 --filename=patterns when parsing directories, only check filenames matching
91 these comma separated patterns (default: *.py)
92 --select=errors select errors and warnings (e.g. E,W6)
93 --ignore=errors skip errors and warnings (e.g. E4,W)
94 --show-source show source code for each error
95 --show-pep8 show text of PEP 8 for each error
96 --statistics count errors and warnings
97 --count count total number of errors and warnings
98 --benchmark measure processing speed
99 --testsuite=dir run regression tests from dir
100 --doctest run doctest on myself
105 Your feedback is more than welcome. Write email to
106 johann@rocholl.net or post bugs and feature requests on github:
108 http://github.com/jcrocholl/pep8/issues
113 The source code is currently available on github. Fork away!
115 http://github.com/jcrocholl/pep8/