| |
- blank_lines(logical_line, blank_lines, indent_level, line_number, previous_logical)
- Separate top-level function and class definitions with two blank lines.
Method definitions inside a class are separated by a single blank line.
Extra blank lines may be used (sparingly) to separate groups of related
functions. Blank lines may be omitted between a bunch of related
one-liners (e.g. a set of dummy implementations).
Use blank lines in functions, sparingly, to indicate logical sections.
- compound_statements(logical_line)
- Compound statements (multiple statements on the same line) are
generally discouraged.
- excluded(filename)
- Check if options.exclude contains a pattern that matches filename.
- expand_indent(line)
- 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')
8
>>> expand_indent(' \t')
16
- extraneous_whitespace(logical_line)
- Avoid extraneous whitespace in the following situations:
- Immediately inside parentheses, brackets or braces.
- Immediately before a comma, semicolon, or colon.
- filename_match(filename)
- Check if options.filename contains a pattern that matches filename.
If options.filename is unspecified, this always returns True.
- find_checks(argument_name)
- Find all globally visible functions where the first argument name
starts with argument_name.
- get_error_statistics()
- Get error statistics.
- get_statistics(prefix='')
- Get statistics for message codes that start with the prefix.
prefix='' matches all errors and warnings
prefix='E' matches all errors
prefix='W' matches all warnings
prefix='E4' matches all errors that have to do with imports
- get_warning_statistics()
- Get warning statistics.
- ignore_code(code)
- Check if options.ignore contains a prefix of the error code.
- imports_on_separate_lines(logical_line)
- Imports should usually be on separate lines.
- indent_match = match(...)
- match(string[, pos[, endpos]]) --> match object or None.
Matches zero or more characters at the beginning of the string
- indentation(logical_line, previous_logical, indent_char, indent_level, previous_indent_level)
- Use 4 spaces per indentation level.
For really old code that you don't want to mess up, you can continue to
use 8-space tabs.
- input_dir(dirname)
- Check all Python source files in this directory and all subdirectories.
- input_file(filename)
- Run all checks on a Python source file.
- iskeyword = __contains__(...)
- x.__contains__(y) <==> y in x.
- maximum_line_length(physical_line)
- Limit all lines to a maximum of 79 characters.
There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to have
several windows side-by-side. The default wrapping on such devices looks
ugly. Therefore, please limit all lines to a maximum of 79 characters.
For flowing long blocks of text (docstrings or comments), limiting the
length to 72 characters is recommended.
- message(text)
- Print a message.
- missing_newline(physical_line)
- JCR: The last line should have a newline.
- missing_whitespace(logical_line)
- JCR: Each comma, semicolon or colon should be followed by whitespace.
- mute_string(text)
- Replace contents with 'xxx' to prevent syntax matching.
>>> mute_string('"abc"')
'"xxx"'
>>> mute_string("'''abc'''")
"'''xxx'''"
>>> mute_string("r'abc'")
"r'xxx'"
- print_benchmark(elapsed)
- Print benchmark numbers.
- print_statistics(prefix='')
- Print overall statistics (number of errors and warnings).
- process_options(arglist=None)
- Process options passed either via arglist or via command line args.
- python_3000_has_key(logical_line)
- The {}.has_key() method will be removed in the future version of
Python. Use the 'in' operation instead, like:
d = {"a": 1, "b": 2}
if "b" in d:
print d["b"]
- python_3000_raise_comma(logical_line)
- When raising an exception, use "raise ValueError('message')"
instead of the older form "raise ValueError, 'message'".
The paren-using form is preferred because when the exception arguments
are long or include string formatting, you don't need to use line
continuation characters thanks to the containing parentheses. The older
form will be removed in Python 3000.
- raise_comma_match = match(...)
- match(string[, pos[, endpos]]) --> match object or None.
Matches zero or more characters at the beginning of the string
- tabs_obsolete(physical_line)
- For new projects, spaces-only are strongly recommended over tabs. Most
editors have features that make this easy to do.
- tabs_or_spaces(physical_line, indent_char)
- Never mix tabs and spaces.
The most popular way of indenting Python is with spaces only. The
second-most popular way is with tabs only. Code indented with a mixture
of tabs and spaces should be converted to using spaces exclusively. When
invoking the Python command line interpreter with the -t option, it issues
warnings about code that illegally mixes tabs and spaces. When using -tt
these warnings become errors. These options are highly recommended!
- trailing_blank_lines(physical_line, lines, line_number)
- JCR: Trailing blank lines are superfluous.
- trailing_whitespace(physical_line)
- JCR: Trailing whitespace is superfluous.
- whitespace_around_comma(logical_line)
- Avoid extraneous whitespace in the following situations:
- More than one space around an assignment (or other) operator to
align it with another.
JCR: This should also be applied around comma etc.
- whitespace_around_operator(logical_line)
- Avoid extraneous whitespace in the following situations:
- More than one space around an assignment (or other) operator to
align it with another.
- whitespace_before_parameters(logical_line, tokens)
- Avoid extraneous whitespace in the following situations:
- Immediately before the open parenthesis that starts the argument
list of a function call.
- Immediately before the open parenthesis that starts an indexing or
slicing.
|