Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle.html

Sat, 21 Apr 2018 17:43:41 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 21 Apr 2018 17:43:41 +0200
changeset 6264
04a671fa4adb
parent 6253
a148632e9610
child 6756
7556c951dce8
permissions
-rw-r--r--

code style checker: extended the dialog to be able to define the number of blank lines before class and function/method definitions

<!DOCTYPE html>
<html><head>
<title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</title>
<meta charset="UTF-8">
<style>
body {
    background: #EDECE6;
    margin: 0em 1em 10em 1em;
    color: black;
}

h1 { color: white; background: #85774A; }
h2 { color: white; background: #85774A; }
h3 { color: white; background: #9D936E; }
h4 { color: white; background: #9D936E; }
    
a { color: #BA6D36; }

</style>
</head>
<body><a NAME="top" ID="top"></a>
<h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</h1>

<h3>Global Attributes</h3>
<table>
<tr><td>ARITHMETIC_OP</td></tr><tr><td>BENCHMARK_KEYS</td></tr><tr><td>BLANK_LINES_CONFIG</td></tr><tr><td>COMMENT_WITH_NL</td></tr><tr><td>COMPARE_NEGATIVE_REGEX</td></tr><tr><td>COMPARE_SINGLETON_REGEX</td></tr><tr><td>COMPARE_TYPE_REGEX</td></tr><tr><td>DEFAULT_EXCLUDE</td></tr><tr><td>DEFAULT_IGNORE</td></tr><tr><td>DOCSTRING_REGEX</td></tr><tr><td>DUNDER_REGEX</td></tr><tr><td>ERRORCODE_REGEX</td></tr><tr><td>EXTRANEOUS_WHITESPACE_REGEX</td></tr><tr><td>HUNK_REGEX</td></tr><tr><td>INDENT_REGEX</td></tr><tr><td>KEYWORDS</td></tr><tr><td>KEYWORD_REGEX</td></tr><tr><td>LAMBDA_REGEX</td></tr><tr><td>MAX_LINE_LENGTH</td></tr><tr><td>NEWLINE</td></tr><tr><td>OPERATOR_REGEX</td></tr><tr><td>PROJECT_CONFIG</td></tr><tr><td>PyCF_ONLY_AST</td></tr><tr><td>RAISE_COMMA_REGEX</td></tr><tr><td>REPORT_FORMAT</td></tr><tr><td>RERAISE_COMMA_REGEX</td></tr><tr><td>SINGLETONS</td></tr><tr><td>SKIP_COMMENTS</td></tr><tr><td>SKIP_TOKENS</td></tr><tr><td>STARTSWITH_DEF_REGEX</td></tr><tr><td>STARTSWITH_INDENT_STATEMENT_REGEX</td></tr><tr><td>STARTSWITH_TOP_LEVEL_REGEX</td></tr><tr><td>TESTSUITE_PATH</td></tr><tr><td>UNARY_OPERATORS</td></tr><tr><td>WHITESPACE</td></tr><tr><td>WHITESPACE_AFTER_COMMA_REGEX</td></tr><tr><td>WS_NEEDED_OPERATORS</td></tr><tr><td>WS_OPTIONAL_OPERATORS</td></tr><tr><td>__version__</td></tr><tr><td>_checks</td></tr><tr><td>noqa</td></tr>
</table>
<h3>Classes</h3>
<table>
<tr>
<td><a href="#BaseReport">BaseReport</a></td>
<td>Collect the results of the checks.</td>
</tr><tr>
<td><a href="#Checker">Checker</a></td>
<td>Load a Python source file, tokenize it, check coding style.</td>
</tr><tr>
<td><a href="#DiffReport">DiffReport</a></td>
<td>Collect and print the results for the changed lines only.</td>
</tr><tr>
<td><a href="#FileReport">FileReport</a></td>
<td>Collect the results of the checks and print only the filenames.</td>
</tr><tr>
<td><a href="#StandardReport">StandardReport</a></td>
<td>Collect and print the results of the checks.</td>
</tr><tr>
<td><a href="#StyleGuide">StyleGuide</a></td>
<td>Initialize a PEP-8 instance with few options.</td>
</tr>
</table>
<h3>Functions</h3>
<table>
<tr>
<td><a href="#__init__">__init__</a></td>
<td></td>
</tr><tr>
<td><a href="#__init___1">__init__</a></td>
<td></td>
</tr><tr>
<td><a href="#__init___2">__init__</a></td>
<td></td>
</tr><tr>
<td><a href="#__init___3">__init__</a></td>
<td></td>
</tr><tr>
<td><a href="#__init___4">__init__</a></td>
<td></td>
</tr><tr>
<td><a href="#_add_check">_add_check</a></td>
<td></td>
</tr><tr>
<td><a href="#_break_around_binary_operators">_break_around_binary_operators</a></td>
<td>Private function to reduce duplication.</td>
</tr><tr>
<td><a href="#_get_parameters">_get_parameters</a></td>
<td></td>
</tr><tr>
<td><a href="#_is_binary_operator">_is_binary_operator</a></td>
<td></td>
</tr><tr>
<td><a href="#_is_eol_token">_is_eol_token</a></td>
<td></td>
</tr><tr>
<td><a href="#_is_eol_token_1">_is_eol_token</a></td>
<td></td>
</tr><tr>
<td><a href="#_main">_main</a></td>
<td>Parse options and run checks on Python source.</td>
</tr><tr>
<td><a href="#_parse_multi_options">_parse_multi_options</a></td>
<td>Split and strip and discard empties.</td>
</tr><tr>
<td><a href="#ambiguous_identifier">ambiguous_identifier</a></td>
<td>Never use the characters 'l', 'O', or 'I' as variable names.</td>
</tr><tr>
<td><a href="#bare_except">bare_except</a></td>
<td>When catching exceptions, mention specific exceptions when possible.</td>
</tr><tr>
<td><a href="#blank_lines">blank_lines</a></td>
<td>Separate top-level function and class definitions with two blank lines.</td>
</tr><tr>
<td><a href="#break_after_binary_operator">break_after_binary_operator</a></td>
<td>Avoid breaks after binary operators.</td>
</tr><tr>
<td><a href="#break_before_binary_operator">break_before_binary_operator</a></td>
<td>Avoid breaks before binary operators.</td>
</tr><tr>
<td><a href="#build_tokens_line">build_tokens_line</a></td>
<td>Build a logical line from tokens.</td>
</tr><tr>
<td><a href="#check_all">check_all</a></td>
<td>Run all checks on the input file.</td>
</tr><tr>
<td><a href="#check_ast">check_ast</a></td>
<td>Build the file's AST and run all AST checks.</td>
</tr><tr>
<td><a href="#check_files">check_files</a></td>
<td>Run all checks on the paths.</td>
</tr><tr>
<td><a href="#check_logical">check_logical</a></td>
<td>Build a line from tokens and run all logical checks on it.</td>
</tr><tr>
<td><a href="#check_physical">check_physical</a></td>
<td>Run all physical checks on a raw input line.</td>
</tr><tr>
<td><a href="#comparison_negative">comparison_negative</a></td>
<td>Negative comparison should be done using "not in" and "is not".</td>
</tr><tr>
<td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
<td>Comparison to singletons should use "is" or "is not".</td>
</tr><tr>
<td><a href="#comparison_type">comparison_type</a></td>
<td>Object type comparisons should always use isinstance().</td>
</tr><tr>
<td><a href="#compound_statements">compound_statements</a></td>
<td>Compound statements (on the same line) are generally discouraged.</td>
</tr><tr>
<td><a href="#continued_indentation">continued_indentation</a></td>
<td>Continuation lines indentation.</td>
</tr><tr>
<td><a href="#error">error</a></td>
<td>Report an error, according to options.</td>
</tr><tr>
<td><a href="#error_1">error</a></td>
<td>Report an error, according to options.</td>
</tr><tr>
<td><a href="#error_2">error</a></td>
<td></td>
</tr><tr>
<td><a href="#error_args">error_args</a></td>
<td>Report an error, according to options.</td>
</tr><tr>
<td><a href="#error_args_1">error_args</a></td>
<td>Report an error, according to options.</td>
</tr><tr>
<td><a href="#excluded">excluded</a></td>
<td>Check if the file should be excluded.</td>
</tr><tr>
<td><a href="#expand_indent">expand_indent</a></td>
<td>Return the amount of indentation.</td>
</tr><tr>
<td><a href="#explicit_line_join">explicit_line_join</a></td>
<td>Avoid explicit line join between brackets.</td>
</tr><tr>
<td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
<td>Avoid extraneous whitespace.</td>
</tr><tr>
<td><a href="#filename_match">filename_match</a></td>
<td>Check if patterns contains a pattern that matches filename.</td>
</tr><tr>
<td><a href="#generate_tokens">generate_tokens</a></td>
<td>Tokenize the file, run physical line checks and yield tokens.</td>
</tr><tr>
<td><a href="#get_checks">get_checks</a></td>
<td>Get all the checks for this category.</td>
</tr><tr>
<td><a href="#get_count">get_count</a></td>
<td>Return the total count of errors and warnings.</td>
</tr><tr>
<td><a href="#get_file_results">get_file_results</a></td>
<td>Return the count of errors and warnings for this file.</td>
</tr><tr>
<td><a href="#get_file_results_1">get_file_results</a></td>
<td>Print the result and return the overall count for this file.</td>
</tr><tr>
<td><a href="#get_parser">get_parser</a></td>
<td>Create the parser for the program.</td>
</tr><tr>
<td><a href="#get_statistics">get_statistics</a></td>
<td>Get statistics for message codes that start with the prefix.</td>
</tr><tr>
<td><a href="#ignore_code">ignore_code</a></td>
<td>Check if the error code should be ignored.</td>
</tr><tr>
<td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
<td>Place imports on separate lines.</td>
</tr><tr>
<td><a href="#increment_logical_line">increment_logical_line</a></td>
<td>Signal a new logical line.</td>
</tr><tr>
<td><a href="#indentation">indentation</a></td>
<td>Use 4 spaces per indentation level.</td>
</tr><tr>
<td><a href="#init_checker_state">init_checker_state</a></td>
<td>Prepare custom state for the specific checker plugin.</td>
</tr><tr>
<td><a href="#init_file">init_file</a></td>
<td>Signal a new file.</td>
</tr><tr>
<td><a href="#init_file_1">init_file</a></td>
<td>Signal a new file.</td>
</tr><tr>
<td><a href="#init_report">init_report</a></td>
<td>Initialize the report instance.</td>
</tr><tr>
<td><a href="#input_dir">input_dir</a></td>
<td>Check all files in this directory and all subdirectories.</td>
</tr><tr>
<td><a href="#input_file">input_file</a></td>
<td>Run all checks on a Python source file.</td>
</tr><tr>
<td><a href="#is_string_literal">is_string_literal</a></td>
<td></td>
</tr><tr>
<td><a href="#lru_cache">lru_cache</a></td>
<td></td>
</tr><tr>
<td><a href="#maximum_line_length">maximum_line_length</a></td>
<td>Limit all lines to a maximum of 79 characters.</td>
</tr><tr>
<td><a href="#maybe_check_physical">maybe_check_physical</a></td>
<td>If appropriate (based on token), check current physical line(s).</td>
</tr><tr>
<td><a href="#missing_whitespace">missing_whitespace</a></td>
<td>Each comma, semicolon or colon should be followed by whitespace.</td>
</tr><tr>
<td><a href="#missing_whitespace_after_import_keyword">missing_whitespace_after_import_keyword</a></td>
<td>Multiple imports in form from x import (a, b, c) should have space between import statement and parenthesised name list.</td>
</tr><tr>
<td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td>
<td>Surround operators with a single space on either side.</td>
</tr><tr>
<td><a href="#module_imports_on_top_of_file">module_imports_on_top_of_file</a></td>
<td>Place imports at the top of the file.</td>
</tr><tr>
<td><a href="#mute_string">mute_string</a></td>
<td>Replace contents with 'xxx' to prevent syntax matching.</td>
</tr><tr>
<td><a href="#normalize_paths">normalize_paths</a></td>
<td>Parse a comma-separated list of paths.</td>
</tr><tr>
<td><a href="#parse_udiff">parse_udiff</a></td>
<td>Return a dictionary of matching lines.</td>
</tr><tr>
<td><a href="#print_benchmark">print_benchmark</a></td>
<td>Print benchmark numbers.</td>
</tr><tr>
<td><a href="#print_statistics">print_statistics</a></td>
<td>Print overall statistics (number of errors and warnings).</td>
</tr><tr>
<td><a href="#process_options">process_options</a></td>
<td>Process options passed either via arglist or via command line args.</td>
</tr><tr>
<td><a href="#python_3000_async_await_keywords">python_3000_async_await_keywords</a></td>
<td>'async' and 'await' are reserved keywords starting with Python 3.7</td>
</tr><tr>
<td><a href="#python_3000_backticks">python_3000_backticks</a></td>
<td>Use repr() instead of backticks in Python 3.</td>
</tr><tr>
<td><a href="#python_3000_has_key">python_3000_has_key</a></td>
<td>The {}.has_key() method is removed in Python 3: use the 'in' operator.</td>
</tr><tr>
<td><a href="#python_3000_invalid_escape_sequence">python_3000_invalid_escape_sequence</a></td>
<td>Invalid escape sequences are deprecated in Python 3.6.</td>
</tr><tr>
<td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
<td>New code should always use != instead of <>.</td>
</tr><tr>
<td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td>
<td>When raising an exception, use "raise ValueError('message')".</td>
</tr><tr>
<td><a href="#read_config">read_config</a></td>
<td>Read and parse configurations.</td>
</tr><tr>
<td><a href="#readline">readline</a></td>
<td>Get the next line from the input buffer.</td>
</tr><tr>
<td><a href="#readlines">readlines</a></td>
<td>Read the source code.</td>
</tr><tr>
<td><a href="#readlines_1">readlines</a></td>
<td>Read the source code.</td>
</tr><tr>
<td><a href="#register_check">register_check</a></td>
<td>Register a new check object.</td>
</tr><tr>
<td><a href="#report_invalid_syntax">report_invalid_syntax</a></td>
<td>Check if the syntax is valid.</td>
</tr><tr>
<td><a href="#run_check">run_check</a></td>
<td>Run a check plugin.</td>
</tr><tr>
<td><a href="#start">start</a></td>
<td>Start the timer.</td>
</tr><tr>
<td><a href="#stdin_get_value">stdin_get_value</a></td>
<td>Read the value from stdin.</td>
</tr><tr>
<td><a href="#stop">stop</a></td>
<td>Stop the timer.</td>
</tr><tr>
<td><a href="#tabs_obsolete">tabs_obsolete</a></td>
<td>For new projects, spaces-only are strongly recommended over tabs.</td>
</tr><tr>
<td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
<td>Never mix tabs and spaces.</td>
</tr><tr>
<td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
<td>Trailing blank lines are superfluous.</td>
</tr><tr>
<td><a href="#trailing_whitespace">trailing_whitespace</a></td>
<td>Trailing whitespace is superfluous.</td>
</tr><tr>
<td><a href="#update_counts">update_counts</a></td>
<td>Adds one to the counts of each appearance of characters in s, for characters in counts</td>
</tr><tr>
<td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
<td>Avoid extraneous whitespace after a comma or a colon.</td>
</tr><tr>
<td><a href="#whitespace_around_keywords">whitespace_around_keywords</a></td>
<td>Avoid extraneous whitespace around keywords.</td>
</tr><tr>
<td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
<td>Don't use spaces around the '=' sign in function arguments.</td>
</tr><tr>
<td><a href="#whitespace_around_operator">whitespace_around_operator</a></td>
<td>Avoid extraneous whitespace around an operator.</td>
</tr><tr>
<td><a href="#whitespace_before_comment">whitespace_before_comment</a></td>
<td>Separate inline comments by at least two spaces.</td>
</tr><tr>
<td><a href="#whitespace_before_parameters">whitespace_before_parameters</a></td>
<td>Avoid extraneous whitespace.</td>
</tr>
</table>
<hr /><hr />
<a NAME="BaseReport" ID="BaseReport"></a>
<h2>BaseReport</h2>
<p>
Collect the results of the checks.
</p>
<h3>Derived from</h3>
object
<h3>Class Attributes</h3>
<table>
<tr><td>print_filename</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="Checker" ID="Checker"></a>
<h2>Checker</h2>
<p>
Load a Python source file, tokenize it, check coding style.
</p>
<h3>Derived from</h3>
object
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="DiffReport" ID="DiffReport"></a>
<h2>DiffReport</h2>
<p>
Collect and print the results for the changed lines only.
</p>
<h3>Derived from</h3>
StandardReport
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="FileReport" ID="FileReport"></a>
<h2>FileReport</h2>
<p>
Collect the results of the checks and print only the filenames.
</p>
<h3>Derived from</h3>
BaseReport
<h3>Class Attributes</h3>
<table>
<tr><td>print_filename</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="StandardReport" ID="StandardReport"></a>
<h2>StandardReport</h2>
<p>
Collect and print the results of the checks.
</p>
<h3>Derived from</h3>
BaseReport
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="StyleGuide" ID="StyleGuide"></a>
<h2>StyleGuide</h2>
<p>
Initialize a PEP-8 instance with few options.
</p>
<h3>Derived from</h3>
object
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="__init__" ID="__init__"></a>
<h2>__init__</h2>
<b>__init__</b>(<i>self, filename=None, lines=None, options=None, report=None, **kwargs</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="__init___1" ID="__init___1"></a>
<h2>__init__</h2>
<b>__init__</b>(<i>self, options</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="__init___2" ID="__init___2"></a>
<h2>__init__</h2>
<b>__init__</b>(<i>self, options</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="__init___3" ID="__init___3"></a>
<h2>__init__</h2>
<b>__init__</b>(<i>self, options</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="__init___4" ID="__init___4"></a>
<h2>__init__</h2>
<b>__init__</b>(<i>self, *args, **kwargs</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_add_check" ID="_add_check"></a>
<h2>_add_check</h2>
<b>_add_check</b>(<i>check, kind, codes, args</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_break_around_binary_operators" ID="_break_around_binary_operators"></a>
<h2>_break_around_binary_operators</h2>
<b>_break_around_binary_operators</b>(<i>tokens</i>)
<p>
Private function to reduce duplication.
</p><p>
    This factors out the shared details between
    :func:`break_before_binary_operator` and
    :func:`break_after_binary_operator`.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_get_parameters" ID="_get_parameters"></a>
<h2>_get_parameters</h2>
<b>_get_parameters</b>(<i>function</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_is_binary_operator" ID="_is_binary_operator"></a>
<h2>_is_binary_operator</h2>
<b>_is_binary_operator</b>(<i>token_type, text</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_is_eol_token" ID="_is_eol_token"></a>
<h2>_is_eol_token</h2>
<b>_is_eol_token</b>(<i>token</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_is_eol_token_1" ID="_is_eol_token_1"></a>
<h2>_is_eol_token</h2>
<b>_is_eol_token</b>(<i>token, _eol_token=_is_eol_token</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_main" ID="_main"></a>
<h2>_main</h2>
<b>_main</b>(<i></i>)
<p>
Parse options and run checks on Python source.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="_parse_multi_options" ID="_parse_multi_options"></a>
<h2>_parse_multi_options</h2>
<b>_parse_multi_options</b>(<i>options, split_token=', '</i>)
<p>
Split and strip and discard empties.
</p><p>
    Turns the following:
</p><p>
    A,
    B,
</p><p>
    into ["A", "B"]
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="ambiguous_identifier" ID="ambiguous_identifier"></a>
<h2>ambiguous_identifier</h2>
<b>ambiguous_identifier</b>(<i>logical_line, tokens</i>)
<p>
Never use the characters 'l', 'O', or 'I' as variable names.
</p><p>
    In some fonts, these characters are indistinguishable from the numerals
    one and zero. When tempted to use 'l', use 'L' instead.
</p><p>
    Okay: L = 0
    Okay: o = 123
    Okay: i = 42
    E741: l = 0
    E741: O = 123
    E741: I = 42
</p><p>
    Variables can be bound in several other contexts, including class and
    function definitions, 'global' and 'nonlocal' statements, exception
    handlers, and 'with' statements.
</p><p>
    Okay: except AttributeError as o:
    Okay: with lock as L:
    E741: except AttributeError as O:
    E741: with lock as l:
    E741: global I
    E741: nonlocal l
    E742: class I(object):
    E743: def l(x):
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="bare_except" ID="bare_except"></a>
<h2>bare_except</h2>
<b>bare_except</b>(<i>logical_line, noqa</i>)
<p>
When catching exceptions, mention specific exceptions when possible.
</p><p>
    Okay: except Exception:
    Okay: except BaseException:
    E722: except:
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="blank_lines" ID="blank_lines"></a>
<h2>blank_lines</h2>
<b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, blank_before, previous_logical, previous_unindented_logical_line, previous_indent_level, lines</i>)
<p>
Separate top-level function and class definitions with two blank lines.
</p><p>
    Method definitions inside a class are separated by a single blank line.
</p><p>
    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).
</p><p>
    Use blank lines in functions, sparingly, to indicate logical sections.
</p><p>
    Okay: def a():\n    pass\n\n\ndef b():\n    pass
    Okay: def a():\n    pass\n\n\nasync def b():\n    pass
    Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
    Okay: default = 1\nfoo = 1
    Okay: classify = 1\nfoo = 1
</p><p>
    E301: class Foo:\n    b = 0\n    def bar():\n        pass
    E302: def a():\n    pass\n\ndef b(n):\n    pass
    E302: def a():\n    pass\n\nasync def b(n):\n    pass
    E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
    E304: @decorator\n\ndef a():\n    pass
    E305: def a():\n    pass\na()
    E306: def a():\n    def b():\n        pass\n    def c():\n        pass
    E307: def a():\n    def b():\n        pass\n\n\n    def c():\n        pass
    E308: def a():\n\n\n\n    pass
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="break_after_binary_operator" ID="break_after_binary_operator"></a>
<h2>break_after_binary_operator</h2>
<b>break_after_binary_operator</b>(<i>logical_line, tokens</i>)
<p>
    Avoid breaks after binary operators.
</p><p>
    The preferred place to break around a binary operator is before the
    operator, not after it.
</p><p>
    W504: (width == 0 +\n height == 0)
    W504: (width == 0 and\n height == 0)
    W504: var = (1 &\n       ~2)
</p><p>
    Okay: foo(\n    -x)
    Okay: foo(x\n    [])
    Okay: x = '''\n''' + ''
    Okay: x = '' + '''\n'''
    Okay: foo(x,\n    -y)
    Okay: foo(x,  # comment\n    -y)
</p><p>
    The following should be W504 but unary_context is tricky with these
    Okay: var = (1 /\n       -2)
    Okay: var = (1 +\n       -1 +\n       -2)
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="break_before_binary_operator" ID="break_before_binary_operator"></a>
<h2>break_before_binary_operator</h2>
<b>break_before_binary_operator</b>(<i>logical_line, tokens</i>)
<p>
    Avoid breaks before binary operators.
</p><p>
    The preferred place to break around a binary operator is after the
    operator, not before it.
</p><p>
    W503: (width == 0\n + height == 0)
    W503: (width == 0\n and height == 0)
    W503: var = (1\n       & ~2)
    W503: var = (1\n       / -2)
    W503: var = (1\n       + -1\n       + -2)
</p><p>
    Okay: foo(\n    -x)
    Okay: foo(x\n    [])
    Okay: x = '''\n''' + ''
    Okay: foo(x,\n    -y)
    Okay: foo(x,  # comment\n    -y)
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="build_tokens_line" ID="build_tokens_line"></a>
<h2>build_tokens_line</h2>
<b>build_tokens_line</b>(<i>self</i>)
<p>
Build a logical line from tokens.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="check_all" ID="check_all"></a>
<h2>check_all</h2>
<b>check_all</b>(<i>self, expected=None, line_offset=0</i>)
<p>
Run all checks on the input file.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="check_ast" ID="check_ast"></a>
<h2>check_ast</h2>
<b>check_ast</b>(<i>self</i>)
<p>
Build the file's AST and run all AST checks.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="check_files" ID="check_files"></a>
<h2>check_files</h2>
<b>check_files</b>(<i>self, paths=None</i>)
<p>
Run all checks on the paths.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="check_logical" ID="check_logical"></a>
<h2>check_logical</h2>
<b>check_logical</b>(<i>self</i>)
<p>
Build a line from tokens and run all logical checks on it.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="check_physical" ID="check_physical"></a>
<h2>check_physical</h2>
<b>check_physical</b>(<i>self, line</i>)
<p>
Run all physical checks on a raw input line.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="comparison_negative" ID="comparison_negative"></a>
<h2>comparison_negative</h2>
<b>comparison_negative</b>(<i>logical_line</i>)
<p>
Negative comparison should be done using "not in" and "is not".
</p><p>
    Okay: if x not in y:\n    pass
    Okay: assert (X in Y or X is Z)
    Okay: if not (X in Y):\n    pass
    Okay: zz = x is not y
    E713: Z = not X in Y
    E713: if not X.B in Y:\n    pass
    E714: if not X is Y:\n    pass
    E714: Z = not X.B is Y
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="comparison_to_singleton" ID="comparison_to_singleton"></a>
<h2>comparison_to_singleton</h2>
<b>comparison_to_singleton</b>(<i>logical_line, noqa</i>)
<p>
Comparison to singletons should use "is" or "is not".
</p><p>
    Comparisons to singletons like None should always be done
    with "is" or "is not", never the equality operators.
</p><p>
    Okay: if arg is not None:
    E711: if arg != None:
    E711: if None == arg:
    E712: if arg == True:
    E712: if False == arg:
</p><p>
    Also, beware of writing if x when you really mean if x is not None --
    e.g. when testing whether a variable or argument that defaults to None was
    set to some other value.  The other value might have a type (such as a
    container) that could be false in a boolean context!
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="comparison_type" ID="comparison_type"></a>
<h2>comparison_type</h2>
<b>comparison_type</b>(<i>logical_line, noqa</i>)
<p>
Object type comparisons should always use isinstance().
</p><p>
    Do not compare types directly.
</p><p>
    Okay: if isinstance(obj, int):
    E721: if type(obj) is type(1):
</p><p>
    When checking if an object is a string, keep in mind that it might be a
    unicode string too! In Python 2.3, str and unicode have a common base
    class, basestring, so you can do:
</p><p>
    Okay: if isinstance(obj, basestring):
    Okay: if type(a1) is type(b1):
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="compound_statements" ID="compound_statements"></a>
<h2>compound_statements</h2>
<b>compound_statements</b>(<i>logical_line</i>)
<p>
Compound statements (on the same line) are generally discouraged.
</p><p>
    While sometimes it's okay to put an if/for/while with a small body
    on the same line, never do this for multi-clause statements.
    Also avoid folding such long lines!
</p><p>
    Always use a def statement instead of an assignment statement that
    binds a lambda expression directly to a name.
</p><p>
    Okay: if foo == 'blah':\n    do_blah_thing()
    Okay: do_one()
    Okay: do_two()
    Okay: do_three()
</p><p>
    E701: if foo == 'blah': do_blah_thing()
    E701: for x in lst: total += x
    E701: while t < 10: t = delay()
    E701: if foo == 'blah': do_blah_thing()
    E701: else: do_non_blah_thing()
    E701: try: something()
    E701: finally: cleanup()
    E701: if foo == 'blah': one(); two(); three()
    E702: do_one(); do_two(); do_three()
    E703: do_four();  # useless semicolon
    E704: def f(x): return 2*x
    E731: f = lambda x: 2*x
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="continued_indentation" ID="continued_indentation"></a>
<h2>continued_indentation</h2>
<b>continued_indentation</b>(<i>logical_line, tokens, indent_level, hang_closing, indent_char, noqa, verbose</i>)
<p>
Continuation lines indentation.
</p><p>
    Continuation lines should align wrapped elements either vertically
    using Python's implicit line joining inside parentheses, brackets
    and braces, or using a hanging indent.
</p><p>
    When using a hanging indent these considerations should be applied:
    - there should be no arguments on the first line, and
    - further indentation should be used to clearly distinguish itself as a
      continuation line.
</p><p>
    Okay: a = (\n)
    E123: a = (\n    )
</p><p>
    Okay: a = (\n    42)
    E121: a = (\n   42)
    E122: a = (\n42)
    E123: a = (\n    42\n    )
    E124: a = (24,\n     42\n)
    E125: if (\n    b):\n    pass
    E126: a = (\n        42)
    E127: a = (24,\n      42)
    E128: a = (24,\n    42)
    E129: if (a or\n    b):\n    pass
    E131: a = (\n    42\n 24)
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="error" ID="error"></a>
<h2>error</h2>
<b>error</b>(<i>self, line_number, offset, text, check</i>)
<p>
Report an error, according to options.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="error_1" ID="error_1"></a>
<h2>error</h2>
<b>error</b>(<i>self, line_number, offset, text, check</i>)
<p>
Report an error, according to options.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="error_2" ID="error_2"></a>
<h2>error</h2>
<b>error</b>(<i>self, line_number, offset, text, check</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="error_args" ID="error_args"></a>
<h2>error_args</h2>
<b>error_args</b>(<i>self, line_number, offset, text, check, *args</i>)
<p>
Report an error, according to options.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="error_args_1" ID="error_args_1"></a>
<h2>error_args</h2>
<b>error_args</b>(<i>self, line_number, offset, code, check, *args</i>)
<p>
Report an error, according to options.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="excluded" ID="excluded"></a>
<h2>excluded</h2>
<b>excluded</b>(<i>self, filename, parent=None</i>)
<p>
Check if the file should be excluded.
</p><p>
        Check if 'options.exclude' contains a pattern that matches filename.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="expand_indent" ID="expand_indent"></a>
<h2>expand_indent</h2>
<b>expand_indent</b>(<i>line</i>)
<p>
Return the amount of indentation.
</p><p>
    Tabs are expanded to the next multiple of 8.
</p><p>
    >>> expand_indent('    ')
    4
    >>> expand_indent('\t')
    8
    >>> expand_indent('       \t')
    8
    >>> expand_indent('        \t')
    16
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="explicit_line_join" ID="explicit_line_join"></a>
<h2>explicit_line_join</h2>
<b>explicit_line_join</b>(<i>logical_line, tokens</i>)
<p>
Avoid explicit line join between brackets.
</p><p>
    The preferred way of wrapping long lines is by using Python's implied line
    continuation inside parentheses, brackets and braces.  Long lines can be
    broken over multiple lines by wrapping expressions in parentheses.  These
    should be used in preference to using a backslash for line continuation.
</p><p>
    E502: aaa = [123, \\n       123]
    E502: aaa = ("bbb " \\n       "ccc")
</p><p>
    Okay: aaa = [123,\n       123]
    Okay: aaa = ("bbb "\n       "ccc")
    Okay: aaa = "bbb " \\n    "ccc"
    Okay: aaa = 123  # \\
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
<h2>extraneous_whitespace</h2>
<b>extraneous_whitespace</b>(<i>logical_line</i>)
<p>
Avoid extraneous whitespace.
</p><p>
    Avoid extraneous whitespace in these situations:
    - Immediately inside parentheses, brackets or braces.
    - Immediately before a comma, semicolon, or colon.
</p><p>
    Okay: spam(ham[1], {eggs: 2})
    E201: spam( ham[1], {eggs: 2})
    E201: spam(ham[ 1], {eggs: 2})
    E201: spam(ham[1], { eggs: 2})
    E202: spam(ham[1], {eggs: 2} )
    E202: spam(ham[1 ], {eggs: 2})
    E202: spam(ham[1], {eggs: 2 })
</p><p>
    E203: if x == 4: print x, y; x, y = y , x
    E203: if x == 4: print x, y ; x, y = y, x
    E203: if x == 4 : print x, y; x, y = y, x
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="filename_match" ID="filename_match"></a>
<h2>filename_match</h2>
<b>filename_match</b>(<i>filename, patterns, default=True</i>)
<p>
Check if patterns contains a pattern that matches filename.
</p><p>
    If patterns is unspecified, this always returns True.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="generate_tokens" ID="generate_tokens"></a>
<h2>generate_tokens</h2>
<b>generate_tokens</b>(<i>self</i>)
<p>
Tokenize the file, run physical line checks and yield tokens.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="get_checks" ID="get_checks"></a>
<h2>get_checks</h2>
<b>get_checks</b>(<i>self, argument_name</i>)
<p>
Get all the checks for this category.
</p><p>
        Find all globally visible functions where the first argument name
        starts with argument_name and which contain selected tests.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="get_count" ID="get_count"></a>
<h2>get_count</h2>
<b>get_count</b>(<i>self, prefix=''</i>)
<p>
Return the total count of errors and warnings.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="get_file_results" ID="get_file_results"></a>
<h2>get_file_results</h2>
<b>get_file_results</b>(<i>self</i>)
<p>
Return the count of errors and warnings for this file.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="get_file_results_1" ID="get_file_results_1"></a>
<h2>get_file_results</h2>
<b>get_file_results</b>(<i>self</i>)
<p>
Print the result and return the overall count for this file.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="get_parser" ID="get_parser"></a>
<h2>get_parser</h2>
<b>get_parser</b>(<i>prog='pycodestyle', version=__version__</i>)
<p>
Create the parser for the program.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="get_statistics" ID="get_statistics"></a>
<h2>get_statistics</h2>
<b>get_statistics</b>(<i>self, prefix=''</i>)
<p>
Get statistics for message codes that start with the prefix.
</p><p>
        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
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="ignore_code" ID="ignore_code"></a>
<h2>ignore_code</h2>
<b>ignore_code</b>(<i>self, code</i>)
<p>
Check if the error code should be ignored.
</p><p>
        If 'options.select' contains a prefix of the error code,
        return False.  Else, if 'options.ignore' contains a prefix of
        the error code, return True.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
<h2>imports_on_separate_lines</h2>
<b>imports_on_separate_lines</b>(<i>logical_line</i>)
<p>
Place imports on separate lines.
</p><p>
    Okay: import os\nimport sys
    E401: import sys, os
</p><p>
    Okay: from subprocess import Popen, PIPE
    Okay: from myclas import MyClass
    Okay: from foo.bar.yourclass import YourClass
    Okay: import myclass
    Okay: import foo.bar.yourclass
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="increment_logical_line" ID="increment_logical_line"></a>
<h2>increment_logical_line</h2>
<b>increment_logical_line</b>(<i>self</i>)
<p>
Signal a new logical line.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="indentation" ID="indentation"></a>
<h2>indentation</h2>
<b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
<p>
Use 4 spaces per indentation level.
</p><p>
    For really old code that you don't want to mess up, you can continue to
    use 8-space tabs.
</p><p>
    Okay: a = 1
    Okay: if a == 0:\n    a = 1
    E111:   a = 1
    E114:   # a = 1
</p><p>
    Okay: for item in items:\n    pass
    E112: for item in items:\npass
    E115: for item in items:\n# Hi\n    pass
</p><p>
    Okay: a = 1\nb = 2
    E113: a = 1\n    b = 2
    E116: a = 1\n    # b = 2
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="init_checker_state" ID="init_checker_state"></a>
<h2>init_checker_state</h2>
<b>init_checker_state</b>(<i>self, name, argument_names</i>)
<p>
Prepare custom state for the specific checker plugin.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="init_file" ID="init_file"></a>
<h2>init_file</h2>
<b>init_file</b>(<i>self, filename, lines, expected, line_offset</i>)
<p>
Signal a new file.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="init_file_1" ID="init_file_1"></a>
<h2>init_file</h2>
<b>init_file</b>(<i>self, filename, lines, expected, line_offset</i>)
<p>
Signal a new file.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="init_report" ID="init_report"></a>
<h2>init_report</h2>
<b>init_report</b>(<i>self, reporter=None</i>)
<p>
Initialize the report instance.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="input_dir" ID="input_dir"></a>
<h2>input_dir</h2>
<b>input_dir</b>(<i>self, dirname</i>)
<p>
Check all files in this directory and all subdirectories.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="input_file" ID="input_file"></a>
<h2>input_file</h2>
<b>input_file</b>(<i>self, filename, lines=None, expected=None, line_offset=0</i>)
<p>
Run all checks on a Python source file.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="is_string_literal" ID="is_string_literal"></a>
<h2>is_string_literal</h2>
<b>is_string_literal</b>(<i>line</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="lru_cache" ID="lru_cache"></a>
<h2>lru_cache</h2>
<b>lru_cache</b>(<i>maxsize=128</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="maximum_line_length" ID="maximum_line_length"></a>
<h2>maximum_line_length</h2>
<b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline, line_number, noqa</i>)
<p>
Limit all lines to a maximum of 79 characters.
</p><p>
    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.
</p><p>
    Reports error E501.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="maybe_check_physical" ID="maybe_check_physical"></a>
<h2>maybe_check_physical</h2>
<b>maybe_check_physical</b>(<i>self, token</i>)
<p>
If appropriate (based on token), check current physical line(s).
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="missing_whitespace" ID="missing_whitespace"></a>
<h2>missing_whitespace</h2>
<b>missing_whitespace</b>(<i>logical_line</i>)
<p>
Each comma, semicolon or colon should be followed by whitespace.
</p><p>
    Okay: [a, b]
    Okay: (3,)
    Okay: a[1:4]
    Okay: a[:4]
    Okay: a[1:]
    Okay: a[1:4:2]
    E231: ['a','b']
    E231: foo(bar,baz)
    E231: [{'a':'b'}]
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="missing_whitespace_after_import_keyword" ID="missing_whitespace_after_import_keyword"></a>
<h2>missing_whitespace_after_import_keyword</h2>
<b>missing_whitespace_after_import_keyword</b>(<i>logical_line</i>)
<p>
Multiple imports in form from x import (a, b, c) should have space
    between import statement and parenthesised name list.
</p><p>
    Okay: from foo import (bar, baz)
    E275: from foo import(bar, baz)
    E275: from importable.module import(bar, baz)
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
<h2>missing_whitespace_around_operator</h2>
<b>missing_whitespace_around_operator</b>(<i>logical_line, tokens</i>)
<p>
Surround operators with a single space on either side.
</p><p>
    - Always surround these binary operators with a single space on
      either side: assignment (=), augmented assignment (+=, -= etc.),
      comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
      Booleans (and, or, not).
</p><p>
    - If operators with different priorities are used, consider adding
      whitespace around the operators with the lowest priorities.
</p><p>
    Okay: i = i + 1
    Okay: submitted += 1
    Okay: x = x * 2 - 1
    Okay: hypot2 = x * x + y * y
    Okay: c = (a + b) * (a - b)
    Okay: foo(bar, key='word', *args, **kwargs)
    Okay: alpha[:-i]
</p><p>
    E225: i=i+1
    E225: submitted +=1
    E225: x = x /2 - 1
    E225: z = x **y
    E226: c = (a+b) * (a-b)
    E226: hypot2 = x*x + y*y
    E227: c = a|b
    E228: msg = fmt%(errno, errmsg)
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="module_imports_on_top_of_file" ID="module_imports_on_top_of_file"></a>
<h2>module_imports_on_top_of_file</h2>
<b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>)
<p>
Place imports at the top of the file.
</p><p>
    Always put imports at the top of the file, just after any module comments
    and docstrings, and before module globals and constants.
</p><p>
    Okay: import os
    Okay: # this is a comment\nimport os
    Okay: '''this is a module docstring'''\nimport os
    Okay: r'''this is a module docstring'''\nimport os
    Okay:  
    try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
    Okay:  
    try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
</p><p>
    E402: a=1\nimport os
    E402: 'One string'\n"Two string"\nimport os
    E402: a=1\nfrom sys import x
</p><p>
    Okay: if x:\n    import os
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="mute_string" ID="mute_string"></a>
<h2>mute_string</h2>
<b>mute_string</b>(<i>text</i>)
<p>
Replace contents with 'xxx' to prevent syntax matching.
</p><p>
    >>> mute_string('"abc"')
    '"xxx"'
    >>> mute_string("'''abc'''")
    "'''xxx'''"
    >>> mute_string("r'abc'")
    "r'xxx'"
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="normalize_paths" ID="normalize_paths"></a>
<h2>normalize_paths</h2>
<b>normalize_paths</b>(<i>value, parent=os.curdir</i>)
<p>
Parse a comma-separated list of paths.
</p><p>
    Return a list of absolute paths.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="parse_udiff" ID="parse_udiff"></a>
<h2>parse_udiff</h2>
<b>parse_udiff</b>(<i>diff, patterns=None, parent='.'</i>)
<p>
Return a dictionary of matching lines.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="print_benchmark" ID="print_benchmark"></a>
<h2>print_benchmark</h2>
<b>print_benchmark</b>(<i>self</i>)
<p>
Print benchmark numbers.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="print_statistics" ID="print_statistics"></a>
<h2>print_statistics</h2>
<b>print_statistics</b>(<i>self, prefix=''</i>)
<p>
Print overall statistics (number of errors and warnings).
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="process_options" ID="process_options"></a>
<h2>process_options</h2>
<b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None</i>)
<p>
Process options passed either via arglist or via command line args.
</p><p>
    Passing in the ``config_file`` parameter allows other tools, such as flake8
    to specify their own options to be processed in pycodestyle.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="python_3000_async_await_keywords" ID="python_3000_async_await_keywords"></a>
<h2>python_3000_async_await_keywords</h2>
<b>python_3000_async_await_keywords</b>(<i>logical_line, tokens</i>)
<p>
'async' and 'await' are reserved keywords starting with Python 3.7
</p><p>
    W606: async = 42
    W606: await = 42
    Okay: async def read_data(db):\n    data = await db.fetch('SELECT ...')
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="python_3000_backticks" ID="python_3000_backticks"></a>
<h2>python_3000_backticks</h2>
<b>python_3000_backticks</b>(<i>logical_line</i>)
<p>
Use repr() instead of backticks in Python 3.
</p><p>
    Okay: val = repr(1 + 2)
    W604: val = `1 + 2`
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
<h2>python_3000_has_key</h2>
<b>python_3000_has_key</b>(<i>logical_line, noqa</i>)
<p>
The {}.has_key() method is removed in Python 3: use the 'in' operator.
</p><p>
    Okay: if "alph" in d:\n    print d["alph"]
    W601: assert d.has_key('alph')
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="python_3000_invalid_escape_sequence" ID="python_3000_invalid_escape_sequence"></a>
<h2>python_3000_invalid_escape_sequence</h2>
<b>python_3000_invalid_escape_sequence</b>(<i>logical_line, tokens</i>)
<p>
Invalid escape sequences are deprecated in Python 3.6.
</p><p>
    Okay: regex = r'\.png$'
    W605: regex = '\.png$'
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
<h2>python_3000_not_equal</h2>
<b>python_3000_not_equal</b>(<i>logical_line</i>)
<p>
New code should always use != instead of <>.
</p><p>
    The older syntax is removed in Python 3.
</p><p>
    Okay: if a != 'no':
    W603: if a <> 'no':
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="python_3000_raise_comma" ID="python_3000_raise_comma"></a>
<h2>python_3000_raise_comma</h2>
<b>python_3000_raise_comma</b>(<i>logical_line</i>)
<p>
When raising an exception, use "raise ValueError('message')".
</p><p>
    The older form is removed in Python 3.
</p><p>
    Okay: raise DummyError("Message")
    W602: raise DummyError, "Message"
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="read_config" ID="read_config"></a>
<h2>read_config</h2>
<b>read_config</b>(<i>options, args, arglist, parser</i>)
<p>
Read and parse configurations.
</p><p>
    If a config file is specified on the command line with the "--config"
    option, then only it is used for configuration.
</p><p>
    Otherwise, the user configuration (~/.config/pycodestyle) and any local
    configurations in the current directory or above will be merged together
    (in that order) using the read method of ConfigParser.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="readline" ID="readline"></a>
<h2>readline</h2>
<b>readline</b>(<i>self</i>)
<p>
Get the next line from the input buffer.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="readlines" ID="readlines"></a>
<h2>readlines</h2>
<b>readlines</b>(<i>filename</i>)
<p>
Read the source code.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="readlines_1" ID="readlines_1"></a>
<h2>readlines</h2>
<b>readlines</b>(<i>filename</i>)
<p>
Read the source code.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="register_check" ID="register_check"></a>
<h2>register_check</h2>
<b>register_check</b>(<i>check, codes=None</i>)
<p>
Register a new check object.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="report_invalid_syntax" ID="report_invalid_syntax"></a>
<h2>report_invalid_syntax</h2>
<b>report_invalid_syntax</b>(<i>self</i>)
<p>
Check if the syntax is valid.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="run_check" ID="run_check"></a>
<h2>run_check</h2>
<b>run_check</b>(<i>self, check, argument_names</i>)
<p>
Run a check plugin.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="start" ID="start"></a>
<h2>start</h2>
<b>start</b>(<i>self</i>)
<p>
Start the timer.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="stdin_get_value" ID="stdin_get_value"></a>
<h2>stdin_get_value</h2>
<b>stdin_get_value</b>(<i></i>)
<p>
Read the value from stdin.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="stop" ID="stop"></a>
<h2>stop</h2>
<b>stop</b>(<i>self</i>)
<p>
Stop the timer.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
<h2>tabs_obsolete</h2>
<b>tabs_obsolete</b>(<i>physical_line</i>)
<p>
For new projects, spaces-only are strongly recommended over tabs.
</p><p>
    Okay: if True:\n    return
    W191: if True:\n\treturn
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a>
<h2>tabs_or_spaces</h2>
<b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
<p>
Never mix tabs and spaces.
</p><p>
    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!
</p><p>
    Okay: if a == 0:\n        a = 1\n        b = 1
    E101: if a == 0:\n        a = 1\n\tb = 1
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
<h2>trailing_blank_lines</h2>
<b>trailing_blank_lines</b>(<i>physical_line, lines, line_number, total_lines</i>)
<p>
Trailing blank lines are superfluous.
</p><p>
    Okay: spam(1)
    W391: spam(1)\n
</p><p>
    However the last line should end with a new line (warning W292).
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="trailing_whitespace" ID="trailing_whitespace"></a>
<h2>trailing_whitespace</h2>
<b>trailing_whitespace</b>(<i>physical_line</i>)
<p>
Trailing whitespace is superfluous.
</p><p>
    The warning returned varies on whether the line itself is blank, for easier
    filtering for those who want to indent their blank lines.
</p><p>
    Okay: spam(1)\n#
    W291: spam(1) \n#
    W293: class Foo(object):\n    \n    bang = 12
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="update_counts" ID="update_counts"></a>
<h2>update_counts</h2>
<b>update_counts</b>(<i>s, counts</i>)
<p>
Adds one to the counts of each appearance of characters in s,
        for characters in counts
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="whitespace_around_comma" ID="whitespace_around_comma"></a>
<h2>whitespace_around_comma</h2>
<b>whitespace_around_comma</b>(<i>logical_line</i>)
<p>
Avoid extraneous whitespace after a comma or a colon.
</p><p>
    Note: these checks are disabled by default
</p><p>
    Okay: a = (1, 2)
    E241: a = (1,  2)
    E242: a = (1,\t2)
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a>
<h2>whitespace_around_keywords</h2>
<b>whitespace_around_keywords</b>(<i>logical_line</i>)
<p>
Avoid extraneous whitespace around keywords.
</p><p>
    Okay: True and False
    E271: True and  False
    E272: True  and False
    E273: True and\tFalse
    E274: True\tand False
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
<h2>whitespace_around_named_parameter_equals</h2>
<b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>)
<p>
Don't use spaces around the '=' sign in function arguments.
</p><p>
    Don't use spaces around the '=' sign when used to indicate a
    keyword argument or a default parameter value, except when using a type
    annotation.
</p><p>
    Okay: def complex(real, imag=0.0):
    Okay: return magic(r=real, i=imag)
    Okay: boolean(a == b)
    Okay: boolean(a != b)
    Okay: boolean(a <= b)
    Okay: boolean(a >= b)
    Okay: def foo(arg: int = 42):
    Okay: async def foo(arg: int = 42):
</p><p>
    E251: def complex(real, imag = 0.0):
    E251: return magic(r = real, i = imag)
    E252: def complex(real, image: float=0.0):
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="whitespace_around_operator" ID="whitespace_around_operator"></a>
<h2>whitespace_around_operator</h2>
<b>whitespace_around_operator</b>(<i>logical_line</i>)
<p>
Avoid extraneous whitespace around an operator.
</p><p>
    Okay: a = 12 + 3
    E221: a = 4  + 5
    E222: a = 4 +  5
    E223: a = 4\t+ 5
    E224: a = 4 +\t5
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="whitespace_before_comment" ID="whitespace_before_comment"></a>
<h2>whitespace_before_comment</h2>
<b>whitespace_before_comment</b>(<i>logical_line, tokens</i>)
<p>
Separate inline comments by at least two spaces.
</p><p>
    An inline comment is a comment on the same line as a statement.  Inline
    comments should be separated by at least two spaces from the statement.
    They should start with a # and a single space.
</p><p>
    Each line of a block comment starts with a # and a single space
    (unless it is indented text inside the comment).
</p><p>
    Okay: x = x + 1  # Increment x
    Okay: x = x + 1    # Increment x
    Okay: # Block comment
    E261: x = x + 1 # Increment x
    E262: x = x + 1  #Increment x
    E262: x = x + 1  #  Increment x
    E265: #Block comment
    E266: ### Block comment
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="whitespace_before_parameters" ID="whitespace_before_parameters"></a>
<h2>whitespace_before_parameters</h2>
<b>whitespace_before_parameters</b>(<i>logical_line, tokens</i>)
<p>
Avoid extraneous whitespace.
</p><p>
    Avoid extraneous whitespace in the following situations:
    - before the open parenthesis that starts the argument list of a
      function call.
    - before the open parenthesis that starts an indexing or slicing.
</p><p>
    Okay: spam(1)
    E211: spam (1)
</p><p>
    Okay: dict['key'] = list[index]
    E211: dict ['key'] = list[index]
    E211: dict['key'] = list [index]
</p>
<div align="right"><a href="#top">Up</a></div>
<hr />
</body></html>

eric ide

mercurial