The source code is currently available on GitHub under the terms and conditions of the Expat license. Fork away!
You can add checks to this program by writing plugins. Each plugin is a simple function that is called for each line of source code, either physical or logical.
Physical line:
Logical line:
The check function requests physical or logical lines by the name of the first argument:
def maximum_line_length(physical_line)
def extraneous_whitespace(logical_line)
def blank_lines(logical_line, blank_lines, indent_level, line_number)
The last example above demonstrates how check plugins can request additional information with extra arguments. All attributes of the Checker object are available. Some examples:
Check plugins can also maintain per-file state. If you need this, declare a parameter named checker_state. You will be passed a dict, which will be the same one for all lines in the same file but a different one for different files. Each check plugin gets its own dict, so you don’t need to worry about clobbering the state of other plugins.
The docstring of each check function shall be the relevant part of text from PEP 8. It is printed if the user enables --show-pep8. Several docstrings contain examples directly from the PEP 8 document.
Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})
These examples are verified automatically when pep8.py is run with the --doctest option. You can add examples for your own check functions. The format is simple: "Okay" or error/warning code followed by colon and space, the rest of the line is example source code. If you put 'r' before the docstring, you can use \n for newline and \t for tab.
Then be sure to pass the tests:
$ python pep8.py --testsuite testsuite
$ python pep8.py --doctest
$ python pep8.py --verbose pep8.py
Changes:
Bugs:
Changes:
Bugs:
News:
Changes:
Bug fixes:
Bug fixes:
Bug fixes:
Bug fixes:
Changes:
Bug fixes:
Changes:
Bug fixes:
Changes:
Bug fixes:
Warning
The internal API is backwards incompatible.
[1] | (1, 2, 3, 4, 5, 6) These issues refer to the previous issue tracker. |