pep8 API¶
The library provides classes which are usable by third party tools.
Checker Classes¶
The StyleGuide
class is used to configure a style guide checker
instance to check multiple files.
The Checker
class can be used to check a single file.
- class pep8.StyleGuide(parse_argv=False, config_file=None, parser=None, paths=None, report=None, **kwargs)[source]¶
Initialize a PEP-8 instance with few options.
- input_file(filename, lines=None, expected=None, line_offset=0)[source]¶
Run all checks on a Python source file.
- excluded(filename, parent=None)[source]¶
Check if the file should be excluded.
Check if ‘options.exclude’ contains a pattern that matches filename.
Report Classes¶
- class pep8.BaseReport(options)[source]¶
Collect the results of the checks.
Utilities¶
- pep8.expand_indent(line)[source]¶
Return the amount of indentation.
Tabs are expanded to the next multiple of 8.
>>> expand_indent(' ') 4 >>> expand_indent('\t') 8 >>> expand_indent(' \t') 8 >>> expand_indent(' \t') 16
- pep8.mute_string(text)[source]¶
Replace contents with ‘xxx’ to prevent syntax matching.
>>> mute_string('"abc"') '"xxx"' >>> mute_string("'''abc'''") "'''xxx'''" >>> mute_string("r'abc'") "r'xxx'"
- pep8.read_config(options, args, arglist, parser)[source]¶
Read and parse configurations
If a config file is specified on the command line with the “–config” option, then only it is used for configuration.
Otherwise, the user configuration (~/.config/pep8) and any local configurations in the current directory or above will be merged together (in that order) using the read method of ConfigParser.