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

changeset 6756
7556c951dce8
parent 6264
04a671fa4adb
equal deleted inserted replaced
6755:009812744917 6756:7556c951dce8
21 <body><a NAME="top" ID="top"></a> 21 <body><a NAME="top" ID="top"></a>
22 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</h1> 22 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</h1>
23 23
24 <h3>Global Attributes</h3> 24 <h3>Global Attributes</h3>
25 <table> 25 <table>
26 <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> 26 <tr><td>ARITHMETIC_OP</td></tr><tr><td>BENCHMARK_KEYS</td></tr><tr><td>BLANK_LINES_CONFIG</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>FUNCTION_RETURN_ANNOTATION_OP</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_DOC_LENGTH</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>
27 </table> 27 </table>
28 <h3>Classes</h3> 28 <h3>Classes</h3>
29 <table> 29 <table>
30 <tr> 30 <tr>
31 <td><a href="#BaseReport">BaseReport</a></td> 31 <td><a href="#BaseReport">BaseReport</a></td>
36 </tr><tr> 36 </tr><tr>
37 <td><a href="#DiffReport">DiffReport</a></td> 37 <td><a href="#DiffReport">DiffReport</a></td>
38 <td>Collect and print the results for the changed lines only.</td> 38 <td>Collect and print the results for the changed lines only.</td>
39 </tr><tr> 39 </tr><tr>
40 <td><a href="#FileReport">FileReport</a></td> 40 <td><a href="#FileReport">FileReport</a></td>
41 <td>Collect the results of the checks and print only the filenames.</td> 41 <td>Collect the results of the checks and print the filenames.</td>
42 </tr><tr> 42 </tr><tr>
43 <td><a href="#StandardReport">StandardReport</a></td> 43 <td><a href="#StandardReport">StandardReport</a></td>
44 <td>Collect and print the results of the checks.</td> 44 <td>Collect and print the results of the checks.</td>
45 </tr><tr> 45 </tr><tr>
46 <td><a href="#StyleGuide">StyleGuide</a></td> 46 <td><a href="#StyleGuide">StyleGuide</a></td>
48 </tr> 48 </tr>
49 </table> 49 </table>
50 <h3>Functions</h3> 50 <h3>Functions</h3>
51 <table> 51 <table>
52 <tr> 52 <tr>
53 <td><a href="#__init__">__init__</a></td>
54 <td></td>
55 </tr><tr>
56 <td><a href="#__init___1">__init__</a></td>
57 <td></td>
58 </tr><tr>
59 <td><a href="#__init___2">__init__</a></td>
60 <td></td>
61 </tr><tr>
62 <td><a href="#__init___3">__init__</a></td>
63 <td></td>
64 </tr><tr>
65 <td><a href="#__init___4">__init__</a></td>
66 <td></td>
67 </tr><tr>
68 <td><a href="#_add_check">_add_check</a></td> 53 <td><a href="#_add_check">_add_check</a></td>
69 <td></td> 54 <td></td>
70 </tr><tr> 55 </tr><tr>
71 <td><a href="#_break_around_binary_operators">_break_around_binary_operators</a></td> 56 <td><a href="#_break_around_binary_operators">_break_around_binary_operators</a></td>
72 <td>Private function to reduce duplication.</td> 57 <td>Private function to reduce duplication.</td>
78 <td></td> 63 <td></td>
79 </tr><tr> 64 </tr><tr>
80 <td><a href="#_is_eol_token">_is_eol_token</a></td> 65 <td><a href="#_is_eol_token">_is_eol_token</a></td>
81 <td></td> 66 <td></td>
82 </tr><tr> 67 </tr><tr>
83 <td><a href="#_is_eol_token_1">_is_eol_token</a></td>
84 <td></td>
85 </tr><tr>
86 <td><a href="#_main">_main</a></td> 68 <td><a href="#_main">_main</a></td>
87 <td>Parse options and run checks on Python source.</td> 69 <td>Parse options and run checks on Python source.</td>
88 </tr><tr> 70 </tr><tr>
89 <td><a href="#_parse_multi_options">_parse_multi_options</a></td> 71 <td><a href="#_parse_multi_options">_parse_multi_options</a></td>
90 <td>Split and strip and discard empties.</td> 72 <td>Split and strip and discard empties.</td>
102 <td>Avoid breaks after binary operators.</td> 84 <td>Avoid breaks after binary operators.</td>
103 </tr><tr> 85 </tr><tr>
104 <td><a href="#break_before_binary_operator">break_before_binary_operator</a></td> 86 <td><a href="#break_before_binary_operator">break_before_binary_operator</a></td>
105 <td>Avoid breaks before binary operators.</td> 87 <td>Avoid breaks before binary operators.</td>
106 </tr><tr> 88 </tr><tr>
107 <td><a href="#build_tokens_line">build_tokens_line</a></td>
108 <td>Build a logical line from tokens.</td>
109 </tr><tr>
110 <td><a href="#check_all">check_all</a></td>
111 <td>Run all checks on the input file.</td>
112 </tr><tr>
113 <td><a href="#check_ast">check_ast</a></td>
114 <td>Build the file's AST and run all AST checks.</td>
115 </tr><tr>
116 <td><a href="#check_files">check_files</a></td>
117 <td>Run all checks on the paths.</td>
118 </tr><tr>
119 <td><a href="#check_logical">check_logical</a></td>
120 <td>Build a line from tokens and run all logical checks on it.</td>
121 </tr><tr>
122 <td><a href="#check_physical">check_physical</a></td>
123 <td>Run all physical checks on a raw input line.</td>
124 </tr><tr>
125 <td><a href="#comparison_negative">comparison_negative</a></td> 89 <td><a href="#comparison_negative">comparison_negative</a></td>
126 <td>Negative comparison should be done using "not in" and "is not".</td> 90 <td>Negative comparison should be done using "not in" and "is not".</td>
127 </tr><tr> 91 </tr><tr>
128 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td> 92 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
129 <td>Comparison to singletons should use "is" or "is not".</td> 93 <td>Comparison to singletons should use "is" or "is not".</td>
135 <td>Compound statements (on the same line) are generally discouraged.</td> 99 <td>Compound statements (on the same line) are generally discouraged.</td>
136 </tr><tr> 100 </tr><tr>
137 <td><a href="#continued_indentation">continued_indentation</a></td> 101 <td><a href="#continued_indentation">continued_indentation</a></td>
138 <td>Continuation lines indentation.</td> 102 <td>Continuation lines indentation.</td>
139 </tr><tr> 103 </tr><tr>
140 <td><a href="#error">error</a></td>
141 <td>Report an error, according to options.</td>
142 </tr><tr>
143 <td><a href="#error_1">error</a></td>
144 <td>Report an error, according to options.</td>
145 </tr><tr>
146 <td><a href="#error_2">error</a></td>
147 <td></td>
148 </tr><tr>
149 <td><a href="#error_args">error_args</a></td>
150 <td>Report an error, according to options.</td>
151 </tr><tr>
152 <td><a href="#error_args_1">error_args</a></td>
153 <td>Report an error, according to options.</td>
154 </tr><tr>
155 <td><a href="#excluded">excluded</a></td>
156 <td>Check if the file should be excluded.</td>
157 </tr><tr>
158 <td><a href="#expand_indent">expand_indent</a></td> 104 <td><a href="#expand_indent">expand_indent</a></td>
159 <td>Return the amount of indentation.</td> 105 <td>Return the amount of indentation.</td>
160 </tr><tr> 106 </tr><tr>
161 <td><a href="#explicit_line_join">explicit_line_join</a></td> 107 <td><a href="#explicit_line_join">explicit_line_join</a></td>
162 <td>Avoid explicit line join between brackets.</td> 108 <td>Avoid explicit line join between brackets.</td>
165 <td>Avoid extraneous whitespace.</td> 111 <td>Avoid extraneous whitespace.</td>
166 </tr><tr> 112 </tr><tr>
167 <td><a href="#filename_match">filename_match</a></td> 113 <td><a href="#filename_match">filename_match</a></td>
168 <td>Check if patterns contains a pattern that matches filename.</td> 114 <td>Check if patterns contains a pattern that matches filename.</td>
169 </tr><tr> 115 </tr><tr>
170 <td><a href="#generate_tokens">generate_tokens</a></td>
171 <td>Tokenize the file, run physical line checks and yield tokens.</td>
172 </tr><tr>
173 <td><a href="#get_checks">get_checks</a></td>
174 <td>Get all the checks for this category.</td>
175 </tr><tr>
176 <td><a href="#get_count">get_count</a></td>
177 <td>Return the total count of errors and warnings.</td>
178 </tr><tr>
179 <td><a href="#get_file_results">get_file_results</a></td>
180 <td>Return the count of errors and warnings for this file.</td>
181 </tr><tr>
182 <td><a href="#get_file_results_1">get_file_results</a></td>
183 <td>Print the result and return the overall count for this file.</td>
184 </tr><tr>
185 <td><a href="#get_parser">get_parser</a></td> 116 <td><a href="#get_parser">get_parser</a></td>
186 <td>Create the parser for the program.</td> 117 <td>Create the parser for the program.</td>
187 </tr><tr> 118 </tr><tr>
188 <td><a href="#get_statistics">get_statistics</a></td>
189 <td>Get statistics for message codes that start with the prefix.</td>
190 </tr><tr>
191 <td><a href="#ignore_code">ignore_code</a></td>
192 <td>Check if the error code should be ignored.</td>
193 </tr><tr>
194 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td> 119 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
195 <td>Place imports on separate lines.</td> 120 <td>Place imports on separate lines.</td>
196 </tr><tr> 121 </tr><tr>
197 <td><a href="#increment_logical_line">increment_logical_line</a></td>
198 <td>Signal a new logical line.</td>
199 </tr><tr>
200 <td><a href="#indentation">indentation</a></td> 122 <td><a href="#indentation">indentation</a></td>
201 <td>Use 4 spaces per indentation level.</td> 123 <td>Use 4 spaces per indentation level.</td>
202 </tr><tr> 124 </tr><tr>
203 <td><a href="#init_checker_state">init_checker_state</a></td>
204 <td>Prepare custom state for the specific checker plugin.</td>
205 </tr><tr>
206 <td><a href="#init_file">init_file</a></td>
207 <td>Signal a new file.</td>
208 </tr><tr>
209 <td><a href="#init_file_1">init_file</a></td>
210 <td>Signal a new file.</td>
211 </tr><tr>
212 <td><a href="#init_report">init_report</a></td>
213 <td>Initialize the report instance.</td>
214 </tr><tr>
215 <td><a href="#input_dir">input_dir</a></td>
216 <td>Check all files in this directory and all subdirectories.</td>
217 </tr><tr>
218 <td><a href="#input_file">input_file</a></td>
219 <td>Run all checks on a Python source file.</td>
220 </tr><tr>
221 <td><a href="#is_string_literal">is_string_literal</a></td> 125 <td><a href="#is_string_literal">is_string_literal</a></td>
222 <td></td> 126 <td></td>
223 </tr><tr> 127 </tr><tr>
224 <td><a href="#lru_cache">lru_cache</a></td> 128 <td><a href="#lru_cache">lru_cache</a></td>
225 <td></td> 129 <td></td>
226 </tr><tr> 130 </tr><tr>
131 <td><a href="#maximum_doc_length">maximum_doc_length</a></td>
132 <td>Limit all doc lines to a maximum of 72 characters.</td>
133 </tr><tr>
227 <td><a href="#maximum_line_length">maximum_line_length</a></td> 134 <td><a href="#maximum_line_length">maximum_line_length</a></td>
228 <td>Limit all lines to a maximum of 79 characters.</td> 135 <td>Limit all lines to a maximum of 79 characters.</td>
229 </tr><tr> 136 </tr><tr>
230 <td><a href="#maybe_check_physical">maybe_check_physical</a></td>
231 <td>If appropriate (based on token), check current physical line(s).</td>
232 </tr><tr>
233 <td><a href="#missing_whitespace">missing_whitespace</a></td> 137 <td><a href="#missing_whitespace">missing_whitespace</a></td>
234 <td>Each comma, semicolon or colon should be followed by whitespace.</td> 138 <td>Each comma, semicolon or colon should be followed by whitespace.</td>
235 </tr><tr> 139 </tr><tr>
236 <td><a href="#missing_whitespace_after_import_keyword">missing_whitespace_after_import_keyword</a></td> 140 <td><a href="#missing_whitespace_after_import_keyword">missing_whitespace_after_import_keyword</a></td>
237 <td>Multiple imports in form from x import (a, b, c) should have space between import statement and parenthesised name list.</td> 141 <td>Multiple imports in form from x import (a, b, c) should have space between import statement and parenthesised name list.</td>
249 <td>Parse a comma-separated list of paths.</td> 153 <td>Parse a comma-separated list of paths.</td>
250 </tr><tr> 154 </tr><tr>
251 <td><a href="#parse_udiff">parse_udiff</a></td> 155 <td><a href="#parse_udiff">parse_udiff</a></td>
252 <td>Return a dictionary of matching lines.</td> 156 <td>Return a dictionary of matching lines.</td>
253 </tr><tr> 157 </tr><tr>
254 <td><a href="#print_benchmark">print_benchmark</a></td>
255 <td>Print benchmark numbers.</td>
256 </tr><tr>
257 <td><a href="#print_statistics">print_statistics</a></td>
258 <td>Print overall statistics (number of errors and warnings).</td>
259 </tr><tr>
260 <td><a href="#process_options">process_options</a></td> 158 <td><a href="#process_options">process_options</a></td>
261 <td>Process options passed either via arglist or via command line args.</td> 159 <td>Process options passed either via arglist or command line args.</td>
262 </tr><tr> 160 </tr><tr>
263 <td><a href="#python_3000_async_await_keywords">python_3000_async_await_keywords</a></td> 161 <td><a href="#python_3000_async_await_keywords">python_3000_async_await_keywords</a></td>
264 <td>'async' and 'await' are reserved keywords starting with Python 3.7</td> 162 <td>'async' and 'await' are reserved keywords starting at Python 3.7.</td>
265 </tr><tr> 163 </tr><tr>
266 <td><a href="#python_3000_backticks">python_3000_backticks</a></td> 164 <td><a href="#python_3000_backticks">python_3000_backticks</a></td>
267 <td>Use repr() instead of backticks in Python 3.</td> 165 <td>Use repr() instead of backticks in Python 3.</td>
268 </tr><tr> 166 </tr><tr>
269 <td><a href="#python_3000_has_key">python_3000_has_key</a></td> 167 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
279 <td>When raising an exception, use "raise ValueError('message')".</td> 177 <td>When raising an exception, use "raise ValueError('message')".</td>
280 </tr><tr> 178 </tr><tr>
281 <td><a href="#read_config">read_config</a></td> 179 <td><a href="#read_config">read_config</a></td>
282 <td>Read and parse configurations.</td> 180 <td>Read and parse configurations.</td>
283 </tr><tr> 181 </tr><tr>
284 <td><a href="#readline">readline</a></td>
285 <td>Get the next line from the input buffer.</td>
286 </tr><tr>
287 <td><a href="#readlines">readlines</a></td> 182 <td><a href="#readlines">readlines</a></td>
288 <td>Read the source code.</td> 183 <td>Read the source code.</td>
289 </tr><tr> 184 </tr><tr>
290 <td><a href="#readlines_1">readlines</a></td> 185 <td><a href="#readlines_1">readlines</a></td>
291 <td>Read the source code.</td> 186 <td>Read the source code.</td>
292 </tr><tr> 187 </tr><tr>
293 <td><a href="#register_check">register_check</a></td> 188 <td><a href="#register_check">register_check</a></td>
294 <td>Register a new check object.</td> 189 <td>Register a new check object.</td>
295 </tr><tr> 190 </tr><tr>
296 <td><a href="#report_invalid_syntax">report_invalid_syntax</a></td>
297 <td>Check if the syntax is valid.</td>
298 </tr><tr>
299 <td><a href="#run_check">run_check</a></td>
300 <td>Run a check plugin.</td>
301 </tr><tr>
302 <td><a href="#start">start</a></td>
303 <td>Start the timer.</td>
304 </tr><tr>
305 <td><a href="#stdin_get_value">stdin_get_value</a></td> 191 <td><a href="#stdin_get_value">stdin_get_value</a></td>
306 <td>Read the value from stdin.</td> 192 <td>Read the value from stdin.</td>
307 </tr><tr> 193 </tr><tr>
308 <td><a href="#stop">stop</a></td>
309 <td>Stop the timer.</td>
310 </tr><tr>
311 <td><a href="#tabs_obsolete">tabs_obsolete</a></td> 194 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
312 <td>For new projects, spaces-only are strongly recommended over tabs.</td> 195 <td>On new projects, spaces-only are strongly recommended over tabs.</td>
313 </tr><tr> 196 </tr><tr>
314 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td> 197 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
315 <td>Never mix tabs and spaces.</td> 198 <td>Never mix tabs and spaces.</td>
316 </tr><tr> 199 </tr><tr>
317 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td> 200 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
358 <table> 241 <table>
359 <tr><td>None</td></tr> 242 <tr><td>None</td></tr>
360 </table> 243 </table>
361 <h3>Methods</h3> 244 <h3>Methods</h3>
362 <table> 245 <table>
246 <tr>
247 <td><a href="#BaseReport.__init__">BaseReport</a></td>
248 <td></td>
249 </tr><tr>
250 <td><a href="#BaseReport.error">error</a></td>
251 <td>Report an error, according to options.</td>
252 </tr><tr>
253 <td><a href="#BaseReport.error_args">error_args</a></td>
254 <td>Report an error, according to options.</td>
255 </tr><tr>
256 <td><a href="#BaseReport.get_count">get_count</a></td>
257 <td>Return the total count of errors and warnings.</td>
258 </tr><tr>
259 <td><a href="#BaseReport.get_file_results">get_file_results</a></td>
260 <td>Return the count of errors and warnings for this file.</td>
261 </tr><tr>
262 <td><a href="#BaseReport.get_statistics">get_statistics</a></td>
263 <td>Get statistics for message codes that start with the prefix.</td>
264 </tr><tr>
265 <td><a href="#BaseReport.increment_logical_line">increment_logical_line</a></td>
266 <td>Signal a new logical line.</td>
267 </tr><tr>
268 <td><a href="#BaseReport.init_file">init_file</a></td>
269 <td>Signal a new file.</td>
270 </tr><tr>
271 <td><a href="#BaseReport.print_benchmark">print_benchmark</a></td>
272 <td>Print benchmark numbers.</td>
273 </tr><tr>
274 <td><a href="#BaseReport.print_statistics">print_statistics</a></td>
275 <td>Print overall statistics (number of errors and warnings).</td>
276 </tr><tr>
277 <td><a href="#BaseReport.start">start</a></td>
278 <td>Start the timer.</td>
279 </tr><tr>
280 <td><a href="#BaseReport.stop">stop</a></td>
281 <td>Stop the timer.</td>
282 </tr>
283 </table>
284 <h3>Static Methods</h3>
285 <table>
363 <tr><td>None</td></tr> 286 <tr><td>None</td></tr>
364 </table> 287 </table>
365 <h3>Static Methods</h3> 288 <a NAME="BaseReport.__init__" ID="BaseReport.__init__"></a>
366 <table> 289 <h4>BaseReport (Constructor)</h4>
367 <tr><td>None</td></tr> 290 <b>BaseReport</b>(<i>options</i>)
368 </table> 291 <a NAME="BaseReport.error" ID="BaseReport.error"></a>
369 292 <h4>BaseReport.error</h4>
293 <b>error</b>(<i>line_number, offset, text, check</i>)
294 <p>
295 Report an error, according to options.
296 </p><a NAME="BaseReport.error_args" ID="BaseReport.error_args"></a>
297 <h4>BaseReport.error_args</h4>
298 <b>error_args</b>(<i>line_number, offset, text, check, *args</i>)
299 <p>
300 Report an error, according to options.
301 </p><a NAME="BaseReport.get_count" ID="BaseReport.get_count"></a>
302 <h4>BaseReport.get_count</h4>
303 <b>get_count</b>(<i>prefix=''</i>)
304 <p>
305 Return the total count of errors and warnings.
306 </p><a NAME="BaseReport.get_file_results" ID="BaseReport.get_file_results"></a>
307 <h4>BaseReport.get_file_results</h4>
308 <b>get_file_results</b>(<i></i>)
309 <p>
310 Return the count of errors and warnings for this file.
311 </p><a NAME="BaseReport.get_statistics" ID="BaseReport.get_statistics"></a>
312 <h4>BaseReport.get_statistics</h4>
313 <b>get_statistics</b>(<i>prefix=''</i>)
314 <p>
315 Get statistics for message codes that start with the prefix.
316 </p><p>
317 prefix='' matches all errors and warnings
318 prefix='E' matches all errors
319 prefix='W' matches all warnings
320 prefix='E4' matches all errors that have to do with imports
321 </p><a NAME="BaseReport.increment_logical_line" ID="BaseReport.increment_logical_line"></a>
322 <h4>BaseReport.increment_logical_line</h4>
323 <b>increment_logical_line</b>(<i></i>)
324 <p>
325 Signal a new logical line.
326 </p><a NAME="BaseReport.init_file" ID="BaseReport.init_file"></a>
327 <h4>BaseReport.init_file</h4>
328 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
329 <p>
330 Signal a new file.
331 </p><a NAME="BaseReport.print_benchmark" ID="BaseReport.print_benchmark"></a>
332 <h4>BaseReport.print_benchmark</h4>
333 <b>print_benchmark</b>(<i></i>)
334 <p>
335 Print benchmark numbers.
336 </p><a NAME="BaseReport.print_statistics" ID="BaseReport.print_statistics"></a>
337 <h4>BaseReport.print_statistics</h4>
338 <b>print_statistics</b>(<i>prefix=''</i>)
339 <p>
340 Print overall statistics (number of errors and warnings).
341 </p><a NAME="BaseReport.start" ID="BaseReport.start"></a>
342 <h4>BaseReport.start</h4>
343 <b>start</b>(<i></i>)
344 <p>
345 Start the timer.
346 </p><a NAME="BaseReport.stop" ID="BaseReport.stop"></a>
347 <h4>BaseReport.stop</h4>
348 <b>stop</b>(<i></i>)
349 <p>
350 Stop the timer.
351 </p>
370 <div align="right"><a href="#top">Up</a></div> 352 <div align="right"><a href="#top">Up</a></div>
371 <hr /><hr /> 353 <hr /><hr />
372 <a NAME="Checker" ID="Checker"></a> 354 <a NAME="Checker" ID="Checker"></a>
373 <h2>Checker</h2> 355 <h2>Checker</h2>
374 <p> 356 <p>
384 <table> 366 <table>
385 <tr><td>None</td></tr> 367 <tr><td>None</td></tr>
386 </table> 368 </table>
387 <h3>Methods</h3> 369 <h3>Methods</h3>
388 <table> 370 <table>
371 <tr>
372 <td><a href="#Checker.__init__">Checker</a></td>
373 <td></td>
374 </tr><tr>
375 <td><a href="#Checker.build_tokens_line">build_tokens_line</a></td>
376 <td>Build a logical line from tokens.</td>
377 </tr><tr>
378 <td><a href="#Checker.check_all">check_all</a></td>
379 <td>Run all checks on the input file.</td>
380 </tr><tr>
381 <td><a href="#Checker.check_ast">check_ast</a></td>
382 <td>Build the file's AST and run all AST checks.</td>
383 </tr><tr>
384 <td><a href="#Checker.check_logical">check_logical</a></td>
385 <td>Build a line from tokens and run all logical checks on it.</td>
386 </tr><tr>
387 <td><a href="#Checker.check_physical">check_physical</a></td>
388 <td>Run all physical checks on a raw input line.</td>
389 </tr><tr>
390 <td><a href="#Checker.generate_tokens">generate_tokens</a></td>
391 <td>Tokenize file, run physical line checks and yield tokens.</td>
392 </tr><tr>
393 <td><a href="#Checker.init_checker_state">init_checker_state</a></td>
394 <td>Prepare custom state for the specific checker plugin.</td>
395 </tr><tr>
396 <td><a href="#Checker.maybe_check_physical">maybe_check_physical</a></td>
397 <td>If appropriate for token, check current physical line(s).</td>
398 </tr><tr>
399 <td><a href="#Checker.readline">readline</a></td>
400 <td>Get the next line from the input buffer.</td>
401 </tr><tr>
402 <td><a href="#Checker.report_invalid_syntax">report_invalid_syntax</a></td>
403 <td>Check if the syntax is valid.</td>
404 </tr><tr>
405 <td><a href="#Checker.run_check">run_check</a></td>
406 <td>Run a check plugin.</td>
407 </tr>
408 </table>
409 <h3>Static Methods</h3>
410 <table>
389 <tr><td>None</td></tr> 411 <tr><td>None</td></tr>
390 </table> 412 </table>
391 <h3>Static Methods</h3> 413 <a NAME="Checker.__init__" ID="Checker.__init__"></a>
392 <table> 414 <h4>Checker (Constructor)</h4>
393 <tr><td>None</td></tr> 415 <b>Checker</b>(<i>filename=None, lines=None, options=None, report=None, **kwargs</i>)
394 </table> 416 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a>
395 417 <h4>Checker.build_tokens_line</h4>
418 <b>build_tokens_line</b>(<i></i>)
419 <p>
420 Build a logical line from tokens.
421 </p><a NAME="Checker.check_all" ID="Checker.check_all"></a>
422 <h4>Checker.check_all</h4>
423 <b>check_all</b>(<i>expected=None, line_offset=0</i>)
424 <p>
425 Run all checks on the input file.
426 </p><a NAME="Checker.check_ast" ID="Checker.check_ast"></a>
427 <h4>Checker.check_ast</h4>
428 <b>check_ast</b>(<i></i>)
429 <p>
430 Build the file's AST and run all AST checks.
431 </p><a NAME="Checker.check_logical" ID="Checker.check_logical"></a>
432 <h4>Checker.check_logical</h4>
433 <b>check_logical</b>(<i></i>)
434 <p>
435 Build a line from tokens and run all logical checks on it.
436 </p><a NAME="Checker.check_physical" ID="Checker.check_physical"></a>
437 <h4>Checker.check_physical</h4>
438 <b>check_physical</b>(<i>line</i>)
439 <p>
440 Run all physical checks on a raw input line.
441 </p><a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a>
442 <h4>Checker.generate_tokens</h4>
443 <b>generate_tokens</b>(<i></i>)
444 <p>
445 Tokenize file, run physical line checks and yield tokens.
446 </p><a NAME="Checker.init_checker_state" ID="Checker.init_checker_state"></a>
447 <h4>Checker.init_checker_state</h4>
448 <b>init_checker_state</b>(<i>name, argument_names</i>)
449 <p>
450 Prepare custom state for the specific checker plugin.
451 </p><a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a>
452 <h4>Checker.maybe_check_physical</h4>
453 <b>maybe_check_physical</b>(<i>token</i>)
454 <p>
455 If appropriate for token, check current physical line(s).
456 </p><a NAME="Checker.readline" ID="Checker.readline"></a>
457 <h4>Checker.readline</h4>
458 <b>readline</b>(<i></i>)
459 <p>
460 Get the next line from the input buffer.
461 </p><a NAME="Checker.report_invalid_syntax" ID="Checker.report_invalid_syntax"></a>
462 <h4>Checker.report_invalid_syntax</h4>
463 <b>report_invalid_syntax</b>(<i></i>)
464 <p>
465 Check if the syntax is valid.
466 </p><a NAME="Checker.run_check" ID="Checker.run_check"></a>
467 <h4>Checker.run_check</h4>
468 <b>run_check</b>(<i>check, argument_names</i>)
469 <p>
470 Run a check plugin.
471 </p>
396 <div align="right"><a href="#top">Up</a></div> 472 <div align="right"><a href="#top">Up</a></div>
397 <hr /><hr /> 473 <hr /><hr />
398 <a NAME="DiffReport" ID="DiffReport"></a> 474 <a NAME="DiffReport" ID="DiffReport"></a>
399 <h2>DiffReport</h2> 475 <h2>DiffReport</h2>
400 <p> 476 <p>
410 <table> 486 <table>
411 <tr><td>None</td></tr> 487 <tr><td>None</td></tr>
412 </table> 488 </table>
413 <h3>Methods</h3> 489 <h3>Methods</h3>
414 <table> 490 <table>
491 <tr>
492 <td><a href="#DiffReport.__init__">DiffReport</a></td>
493 <td></td>
494 </tr><tr>
495 <td><a href="#DiffReport.error">error</a></td>
496 <td></td>
497 </tr>
498 </table>
499 <h3>Static Methods</h3>
500 <table>
415 <tr><td>None</td></tr> 501 <tr><td>None</td></tr>
416 </table> 502 </table>
417 <h3>Static Methods</h3> 503 <a NAME="DiffReport.__init__" ID="DiffReport.__init__"></a>
418 <table> 504 <h4>DiffReport (Constructor)</h4>
419 <tr><td>None</td></tr> 505 <b>DiffReport</b>(<i>options</i>)
420 </table> 506 <a NAME="DiffReport.error" ID="DiffReport.error"></a>
507 <h4>DiffReport.error</h4>
508 <b>error</b>(<i>line_number, offset, text, check</i>)
421 509
422 <div align="right"><a href="#top">Up</a></div> 510 <div align="right"><a href="#top">Up</a></div>
423 <hr /><hr /> 511 <hr /><hr />
424 <a NAME="FileReport" ID="FileReport"></a> 512 <a NAME="FileReport" ID="FileReport"></a>
425 <h2>FileReport</h2> 513 <h2>FileReport</h2>
426 <p> 514 <p>
427 Collect the results of the checks and print only the filenames. 515 Collect the results of the checks and print the filenames.
428 </p> 516 </p>
429 <h3>Derived from</h3> 517 <h3>Derived from</h3>
430 BaseReport 518 BaseReport
431 <h3>Class Attributes</h3> 519 <h3>Class Attributes</h3>
432 <table> 520 <table>
462 <table> 550 <table>
463 <tr><td>None</td></tr> 551 <tr><td>None</td></tr>
464 </table> 552 </table>
465 <h3>Methods</h3> 553 <h3>Methods</h3>
466 <table> 554 <table>
555 <tr>
556 <td><a href="#StandardReport.__init__">StandardReport</a></td>
557 <td></td>
558 </tr><tr>
559 <td><a href="#StandardReport.error">error</a></td>
560 <td>Report an error, according to options.</td>
561 </tr><tr>
562 <td><a href="#StandardReport.error_args">error_args</a></td>
563 <td>Report an error, according to options.</td>
564 </tr><tr>
565 <td><a href="#StandardReport.get_file_results">get_file_results</a></td>
566 <td>Print results and return the overall count for this file.</td>
567 </tr><tr>
568 <td><a href="#StandardReport.init_file">init_file</a></td>
569 <td>Signal a new file.</td>
570 </tr>
571 </table>
572 <h3>Static Methods</h3>
573 <table>
467 <tr><td>None</td></tr> 574 <tr><td>None</td></tr>
468 </table> 575 </table>
469 <h3>Static Methods</h3> 576 <a NAME="StandardReport.__init__" ID="StandardReport.__init__"></a>
470 <table> 577 <h4>StandardReport (Constructor)</h4>
471 <tr><td>None</td></tr> 578 <b>StandardReport</b>(<i>options</i>)
472 </table> 579 <a NAME="StandardReport.error" ID="StandardReport.error"></a>
473 580 <h4>StandardReport.error</h4>
581 <b>error</b>(<i>line_number, offset, text, check</i>)
582 <p>
583 Report an error, according to options.
584 </p><a NAME="StandardReport.error_args" ID="StandardReport.error_args"></a>
585 <h4>StandardReport.error_args</h4>
586 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>)
587 <p>
588 Report an error, according to options.
589 </p><a NAME="StandardReport.get_file_results" ID="StandardReport.get_file_results"></a>
590 <h4>StandardReport.get_file_results</h4>
591 <b>get_file_results</b>(<i></i>)
592 <p>
593 Print results and return the overall count for this file.
594 </p><a NAME="StandardReport.init_file" ID="StandardReport.init_file"></a>
595 <h4>StandardReport.init_file</h4>
596 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
597 <p>
598 Signal a new file.
599 </p>
474 <div align="right"><a href="#top">Up</a></div> 600 <div align="right"><a href="#top">Up</a></div>
475 <hr /><hr /> 601 <hr /><hr />
476 <a NAME="StyleGuide" ID="StyleGuide"></a> 602 <a NAME="StyleGuide" ID="StyleGuide"></a>
477 <h2>StyleGuide</h2> 603 <h2>StyleGuide</h2>
478 <p> 604 <p>
488 <table> 614 <table>
489 <tr><td>None</td></tr> 615 <tr><td>None</td></tr>
490 </table> 616 </table>
491 <h3>Methods</h3> 617 <h3>Methods</h3>
492 <table> 618 <table>
619 <tr>
620 <td><a href="#StyleGuide.__init__">StyleGuide</a></td>
621 <td></td>
622 </tr><tr>
623 <td><a href="#StyleGuide.check_files">check_files</a></td>
624 <td>Run all checks on the paths.</td>
625 </tr><tr>
626 <td><a href="#StyleGuide.excluded">excluded</a></td>
627 <td>Check if the file should be excluded.</td>
628 </tr><tr>
629 <td><a href="#StyleGuide.get_checks">get_checks</a></td>
630 <td>Get all the checks for this category.</td>
631 </tr><tr>
632 <td><a href="#StyleGuide.ignore_code">ignore_code</a></td>
633 <td>Check if the error code should be ignored.</td>
634 </tr><tr>
635 <td><a href="#StyleGuide.init_report">init_report</a></td>
636 <td>Initialize the report instance.</td>
637 </tr><tr>
638 <td><a href="#StyleGuide.input_dir">input_dir</a></td>
639 <td>Check all files in this directory and all subdirectories.</td>
640 </tr><tr>
641 <td><a href="#StyleGuide.input_file">input_file</a></td>
642 <td>Run all checks on a Python source file.</td>
643 </tr>
644 </table>
645 <h3>Static Methods</h3>
646 <table>
493 <tr><td>None</td></tr> 647 <tr><td>None</td></tr>
494 </table> 648 </table>
495 <h3>Static Methods</h3> 649 <a NAME="StyleGuide.__init__" ID="StyleGuide.__init__"></a>
496 <table> 650 <h4>StyleGuide (Constructor)</h4>
497 <tr><td>None</td></tr> 651 <b>StyleGuide</b>(<i>*args, **kwargs</i>)
498 </table> 652 <a NAME="StyleGuide.check_files" ID="StyleGuide.check_files"></a>
499 653 <h4>StyleGuide.check_files</h4>
500 <div align="right"><a href="#top">Up</a></div> 654 <b>check_files</b>(<i>paths=None</i>)
501 <hr /><hr /> 655 <p>
502 <a NAME="__init__" ID="__init__"></a> 656 Run all checks on the paths.
503 <h2>__init__</h2> 657 </p><a NAME="StyleGuide.excluded" ID="StyleGuide.excluded"></a>
504 <b>__init__</b>(<i>self, filename=None, lines=None, options=None, report=None, **kwargs</i>) 658 <h4>StyleGuide.excluded</h4>
505 659 <b>excluded</b>(<i>filename, parent=None</i>)
506 <div align="right"><a href="#top">Up</a></div> 660 <p>
507 <hr /><hr /> 661 Check if the file should be excluded.
508 <a NAME="__init___1" ID="__init___1"></a> 662 </p><p>
509 <h2>__init__</h2> 663 Check if 'options.exclude' contains a pattern matching filename.
510 <b>__init__</b>(<i>self, options</i>) 664 </p><a NAME="StyleGuide.get_checks" ID="StyleGuide.get_checks"></a>
511 665 <h4>StyleGuide.get_checks</h4>
512 <div align="right"><a href="#top">Up</a></div> 666 <b>get_checks</b>(<i>argument_name</i>)
513 <hr /><hr /> 667 <p>
514 <a NAME="__init___2" ID="__init___2"></a> 668 Get all the checks for this category.
515 <h2>__init__</h2> 669 </p><p>
516 <b>__init__</b>(<i>self, options</i>) 670 Find all globally visible functions where the first argument
517 671 name starts with argument_name and which contain selected tests.
518 <div align="right"><a href="#top">Up</a></div> 672 </p><a NAME="StyleGuide.ignore_code" ID="StyleGuide.ignore_code"></a>
519 <hr /><hr /> 673 <h4>StyleGuide.ignore_code</h4>
520 <a NAME="__init___3" ID="__init___3"></a> 674 <b>ignore_code</b>(<i>code</i>)
521 <h2>__init__</h2> 675 <p>
522 <b>__init__</b>(<i>self, options</i>) 676 Check if the error code should be ignored.
523 677 </p><p>
524 <div align="right"><a href="#top">Up</a></div> 678 If 'options.select' contains a prefix of the error code,
525 <hr /><hr /> 679 return False. Else, if 'options.ignore' contains a prefix of
526 <a NAME="__init___4" ID="__init___4"></a> 680 the error code, return True.
527 <h2>__init__</h2> 681 </p><a NAME="StyleGuide.init_report" ID="StyleGuide.init_report"></a>
528 <b>__init__</b>(<i>self, *args, **kwargs</i>) 682 <h4>StyleGuide.init_report</h4>
529 683 <b>init_report</b>(<i>reporter=None</i>)
684 <p>
685 Initialize the report instance.
686 </p><a NAME="StyleGuide.input_dir" ID="StyleGuide.input_dir"></a>
687 <h4>StyleGuide.input_dir</h4>
688 <b>input_dir</b>(<i>dirname</i>)
689 <p>
690 Check all files in this directory and all subdirectories.
691 </p><a NAME="StyleGuide.input_file" ID="StyleGuide.input_file"></a>
692 <h4>StyleGuide.input_file</h4>
693 <b>input_file</b>(<i>filename, lines=None, expected=None, line_offset=0</i>)
694 <p>
695 Run all checks on a Python source file.
696 </p>
530 <div align="right"><a href="#top">Up</a></div> 697 <div align="right"><a href="#top">Up</a></div>
531 <hr /><hr /> 698 <hr /><hr />
532 <a NAME="_add_check" ID="_add_check"></a> 699 <a NAME="_add_check" ID="_add_check"></a>
533 <h2>_add_check</h2> 700 <h2>_add_check</h2>
534 <b>_add_check</b>(<i>check, kind, codes, args</i>) 701 <b>_add_check</b>(<i>check, kind, codes, args</i>)
563 <h2>_is_eol_token</h2> 730 <h2>_is_eol_token</h2>
564 <b>_is_eol_token</b>(<i>token</i>) 731 <b>_is_eol_token</b>(<i>token</i>)
565 732
566 <div align="right"><a href="#top">Up</a></div> 733 <div align="right"><a href="#top">Up</a></div>
567 <hr /><hr /> 734 <hr /><hr />
568 <a NAME="_is_eol_token_1" ID="_is_eol_token_1"></a>
569 <h2>_is_eol_token</h2>
570 <b>_is_eol_token</b>(<i>token, _eol_token=_is_eol_token</i>)
571
572 <div align="right"><a href="#top">Up</a></div>
573 <hr /><hr />
574 <a NAME="_main" ID="_main"></a> 735 <a NAME="_main" ID="_main"></a>
575 <h2>_main</h2> 736 <h2>_main</h2>
576 <b>_main</b>(<i></i>) 737 <b>_main</b>(<i></i>)
577 <p> 738 <p>
578 Parse options and run checks on Python source. 739 Parse options and run checks on Python source.
598 <h2>ambiguous_identifier</h2> 759 <h2>ambiguous_identifier</h2>
599 <b>ambiguous_identifier</b>(<i>logical_line, tokens</i>) 760 <b>ambiguous_identifier</b>(<i>logical_line, tokens</i>)
600 <p> 761 <p>
601 Never use the characters 'l', 'O', or 'I' as variable names. 762 Never use the characters 'l', 'O', or 'I' as variable names.
602 </p><p> 763 </p><p>
603 In some fonts, these characters are indistinguishable from the numerals 764 In some fonts, these characters are indistinguishable from the
604 one and zero. When tempted to use 'l', use 'L' instead. 765 numerals one and zero. When tempted to use 'l', use 'L' instead.
605 </p><p> 766 </p><p>
606 Okay: L = 0 767 Okay: L = 0
607 Okay: o = 123 768 Okay: o = 123
608 Okay: i = 42 769 Okay: i = 42
609 E741: l = 0 770 E741: l = 0
610 E741: O = 123 771 E741: O = 123
611 E741: I = 42 772 E741: I = 42
612 </p><p> 773 </p><p>
613 Variables can be bound in several other contexts, including class and 774 Variables can be bound in several other contexts, including class
614 function definitions, 'global' and 'nonlocal' statements, exception 775 and function definitions, 'global' and 'nonlocal' statements,
615 handlers, and 'with' statements. 776 exception handlers, and 'with' statements.
616 </p><p> 777 </p><p>
617 Okay: except AttributeError as o: 778 Okay: except AttributeError as o:
618 Okay: with lock as L: 779 Okay: with lock as L:
619 E741: except AttributeError as O: 780 E741: except AttributeError as O:
620 E741: with lock as l: 781 E741: with lock as l:
627 <hr /><hr /> 788 <hr /><hr />
628 <a NAME="bare_except" ID="bare_except"></a> 789 <a NAME="bare_except" ID="bare_except"></a>
629 <h2>bare_except</h2> 790 <h2>bare_except</h2>
630 <b>bare_except</b>(<i>logical_line, noqa</i>) 791 <b>bare_except</b>(<i>logical_line, noqa</i>)
631 <p> 792 <p>
632 When catching exceptions, mention specific exceptions when possible. 793 When catching exceptions, mention specific exceptions when
794 possible.
633 </p><p> 795 </p><p>
634 Okay: except Exception: 796 Okay: except Exception:
635 Okay: except BaseException: 797 Okay: except BaseException:
636 E722: except: 798 E722: except:
637 </p> 799 </p>
639 <hr /><hr /> 801 <hr /><hr />
640 <a NAME="blank_lines" ID="blank_lines"></a> 802 <a NAME="blank_lines" ID="blank_lines"></a>
641 <h2>blank_lines</h2> 803 <h2>blank_lines</h2>
642 <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>) 804 <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>)
643 <p> 805 <p>
644 Separate top-level function and class definitions with two blank lines. 806 Separate top-level function and class definitions with two blank
645 </p><p> 807 lines.
646 Method definitions inside a class are separated by a single blank line. 808 </p><p>
647 </p><p> 809 Method definitions inside a class are separated by a single blank
648 Extra blank lines may be used (sparingly) to separate groups of related 810 line.
649 functions. Blank lines may be omitted between a bunch of related 811 </p><p>
650 one-liners (e.g. a set of dummy implementations). 812 Extra blank lines may be used (sparingly) to separate groups of
651 </p><p> 813 related functions. Blank lines may be omitted between a bunch of
652 Use blank lines in functions, sparingly, to indicate logical sections. 814 related one-liners (e.g. a set of dummy implementations).
815 </p><p>
816 Use blank lines in functions, sparingly, to indicate logical
817 sections.
653 </p><p> 818 </p><p>
654 Okay: def a():\n pass\n\n\ndef b():\n pass 819 Okay: def a():\n pass\n\n\ndef b():\n pass
655 Okay: def a():\n pass\n\n\nasync def b():\n pass 820 Okay: def a():\n pass\n\n\nasync def b():\n pass
656 Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass 821 Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass
657 Okay: default = 1\nfoo = 1 822 Okay: default = 1\nfoo = 1
716 Okay: foo(x,\n -y) 881 Okay: foo(x,\n -y)
717 Okay: foo(x, # comment\n -y) 882 Okay: foo(x, # comment\n -y)
718 </p> 883 </p>
719 <div align="right"><a href="#top">Up</a></div> 884 <div align="right"><a href="#top">Up</a></div>
720 <hr /><hr /> 885 <hr /><hr />
721 <a NAME="build_tokens_line" ID="build_tokens_line"></a>
722 <h2>build_tokens_line</h2>
723 <b>build_tokens_line</b>(<i>self</i>)
724 <p>
725 Build a logical line from tokens.
726 </p>
727 <div align="right"><a href="#top">Up</a></div>
728 <hr /><hr />
729 <a NAME="check_all" ID="check_all"></a>
730 <h2>check_all</h2>
731 <b>check_all</b>(<i>self, expected=None, line_offset=0</i>)
732 <p>
733 Run all checks on the input file.
734 </p>
735 <div align="right"><a href="#top">Up</a></div>
736 <hr /><hr />
737 <a NAME="check_ast" ID="check_ast"></a>
738 <h2>check_ast</h2>
739 <b>check_ast</b>(<i>self</i>)
740 <p>
741 Build the file's AST and run all AST checks.
742 </p>
743 <div align="right"><a href="#top">Up</a></div>
744 <hr /><hr />
745 <a NAME="check_files" ID="check_files"></a>
746 <h2>check_files</h2>
747 <b>check_files</b>(<i>self, paths=None</i>)
748 <p>
749 Run all checks on the paths.
750 </p>
751 <div align="right"><a href="#top">Up</a></div>
752 <hr /><hr />
753 <a NAME="check_logical" ID="check_logical"></a>
754 <h2>check_logical</h2>
755 <b>check_logical</b>(<i>self</i>)
756 <p>
757 Build a line from tokens and run all logical checks on it.
758 </p>
759 <div align="right"><a href="#top">Up</a></div>
760 <hr /><hr />
761 <a NAME="check_physical" ID="check_physical"></a>
762 <h2>check_physical</h2>
763 <b>check_physical</b>(<i>self, line</i>)
764 <p>
765 Run all physical checks on a raw input line.
766 </p>
767 <div align="right"><a href="#top">Up</a></div>
768 <hr /><hr />
769 <a NAME="comparison_negative" ID="comparison_negative"></a> 886 <a NAME="comparison_negative" ID="comparison_negative"></a>
770 <h2>comparison_negative</h2> 887 <h2>comparison_negative</h2>
771 <b>comparison_negative</b>(<i>logical_line</i>) 888 <b>comparison_negative</b>(<i>logical_line</i>)
772 <p> 889 <p>
773 Negative comparison should be done using "not in" and "is not". 890 Negative comparison should be done using "not in" and "is not".
796 E711: if arg != None: 913 E711: if arg != None:
797 E711: if None == arg: 914 E711: if None == arg:
798 E712: if arg == True: 915 E712: if arg == True:
799 E712: if False == arg: 916 E712: if False == arg:
800 </p><p> 917 </p><p>
801 Also, beware of writing if x when you really mean if x is not None -- 918 Also, beware of writing if x when you really mean if x is not None
802 e.g. when testing whether a variable or argument that defaults to None was 919 -- e.g. when testing whether a variable or argument that defaults to
803 set to some other value. The other value might have a type (such as a 920 None was set to some other value. The other value might have a type
804 container) that could be false in a boolean context! 921 (such as a container) that could be false in a boolean context!
805 </p> 922 </p>
806 <div align="right"><a href="#top">Up</a></div> 923 <div align="right"><a href="#top">Up</a></div>
807 <hr /><hr /> 924 <hr /><hr />
808 <a NAME="comparison_type" ID="comparison_type"></a> 925 <a NAME="comparison_type" ID="comparison_type"></a>
809 <h2>comparison_type</h2> 926 <h2>comparison_type</h2>
814 Do not compare types directly. 931 Do not compare types directly.
815 </p><p> 932 </p><p>
816 Okay: if isinstance(obj, int): 933 Okay: if isinstance(obj, int):
817 E721: if type(obj) is type(1): 934 E721: if type(obj) is type(1):
818 </p><p> 935 </p><p>
819 When checking if an object is a string, keep in mind that it might be a 936 When checking if an object is a string, keep in mind that it might
820 unicode string too! In Python 2.3, str and unicode have a common base 937 be a unicode string too! In Python 2.3, str and unicode have a
821 class, basestring, so you can do: 938 common base class, basestring, so you can do:
822 </p><p> 939 </p><p>
823 Okay: if isinstance(obj, basestring): 940 Okay: if isinstance(obj, basestring):
824 Okay: if type(a1) is type(b1): 941 Okay: if type(a1) is type(b1):
825 </p> 942 </p>
826 <div align="right"><a href="#top">Up</a></div> 943 <div align="right"><a href="#top">Up</a></div>
827 <hr /><hr /> 944 <hr /><hr />
828 <a NAME="compound_statements" ID="compound_statements"></a> 945 <a NAME="compound_statements" ID="compound_statements"></a>
829 <h2>compound_statements</h2> 946 <h2>compound_statements</h2>
830 <b>compound_statements</b>(<i>logical_line</i>) 947 <b>compound_statements</b>(<i>logical_line</i>)
831 <p> 948 <p>
832 Compound statements (on the same line) are generally discouraged. 949 Compound statements (on the same line) are generally
950 discouraged.
833 </p><p> 951 </p><p>
834 While sometimes it's okay to put an if/for/while with a small body 952 While sometimes it's okay to put an if/for/while with a small body
835 on the same line, never do this for multi-clause statements. 953 on the same line, never do this for multi-clause statements.
836 Also avoid folding such long lines! 954 Also avoid folding such long lines!
837 </p><p> 955 </p><p>
868 using Python's implicit line joining inside parentheses, brackets 986 using Python's implicit line joining inside parentheses, brackets
869 and braces, or using a hanging indent. 987 and braces, or using a hanging indent.
870 </p><p> 988 </p><p>
871 When using a hanging indent these considerations should be applied: 989 When using a hanging indent these considerations should be applied:
872 - there should be no arguments on the first line, and 990 - there should be no arguments on the first line, and
873 - further indentation should be used to clearly distinguish itself as a 991 - further indentation should be used to clearly distinguish itself
874 continuation line. 992 as a continuation line.
875 </p><p> 993 </p><p>
876 Okay: a = (\n) 994 Okay: a = (\n)
877 E123: a = (\n ) 995 E123: a = (\n )
878 </p><p> 996 </p><p>
879 Okay: a = (\n 42) 997 Okay: a = (\n 42)
888 E129: if (a or\n b):\n pass 1006 E129: if (a or\n b):\n pass
889 E131: a = (\n 42\n 24) 1007 E131: a = (\n 42\n 24)
890 </p> 1008 </p>
891 <div align="right"><a href="#top">Up</a></div> 1009 <div align="right"><a href="#top">Up</a></div>
892 <hr /><hr /> 1010 <hr /><hr />
893 <a NAME="error" ID="error"></a>
894 <h2>error</h2>
895 <b>error</b>(<i>self, line_number, offset, text, check</i>)
896 <p>
897 Report an error, according to options.
898 </p>
899 <div align="right"><a href="#top">Up</a></div>
900 <hr /><hr />
901 <a NAME="error_1" ID="error_1"></a>
902 <h2>error</h2>
903 <b>error</b>(<i>self, line_number, offset, text, check</i>)
904 <p>
905 Report an error, according to options.
906 </p>
907 <div align="right"><a href="#top">Up</a></div>
908 <hr /><hr />
909 <a NAME="error_2" ID="error_2"></a>
910 <h2>error</h2>
911 <b>error</b>(<i>self, line_number, offset, text, check</i>)
912
913 <div align="right"><a href="#top">Up</a></div>
914 <hr /><hr />
915 <a NAME="error_args" ID="error_args"></a>
916 <h2>error_args</h2>
917 <b>error_args</b>(<i>self, line_number, offset, text, check, *args</i>)
918 <p>
919 Report an error, according to options.
920 </p>
921 <div align="right"><a href="#top">Up</a></div>
922 <hr /><hr />
923 <a NAME="error_args_1" ID="error_args_1"></a>
924 <h2>error_args</h2>
925 <b>error_args</b>(<i>self, line_number, offset, code, check, *args</i>)
926 <p>
927 Report an error, according to options.
928 </p>
929 <div align="right"><a href="#top">Up</a></div>
930 <hr /><hr />
931 <a NAME="excluded" ID="excluded"></a>
932 <h2>excluded</h2>
933 <b>excluded</b>(<i>self, filename, parent=None</i>)
934 <p>
935 Check if the file should be excluded.
936 </p><p>
937 Check if 'options.exclude' contains a pattern that matches filename.
938 </p>
939 <div align="right"><a href="#top">Up</a></div>
940 <hr /><hr />
941 <a NAME="expand_indent" ID="expand_indent"></a> 1011 <a NAME="expand_indent" ID="expand_indent"></a>
942 <h2>expand_indent</h2> 1012 <h2>expand_indent</h2>
943 <b>expand_indent</b>(<i>line</i>) 1013 <b>expand_indent</b>(<i>line</i>)
944 <p> 1014 <p>
945 Return the amount of indentation. 1015 Return the amount of indentation.
961 <h2>explicit_line_join</h2> 1031 <h2>explicit_line_join</h2>
962 <b>explicit_line_join</b>(<i>logical_line, tokens</i>) 1032 <b>explicit_line_join</b>(<i>logical_line, tokens</i>)
963 <p> 1033 <p>
964 Avoid explicit line join between brackets. 1034 Avoid explicit line join between brackets.
965 </p><p> 1035 </p><p>
966 The preferred way of wrapping long lines is by using Python's implied line 1036 The preferred way of wrapping long lines is by using Python's
967 continuation inside parentheses, brackets and braces. Long lines can be 1037 implied line continuation inside parentheses, brackets and braces.
968 broken over multiple lines by wrapping expressions in parentheses. These 1038 Long lines can be broken over multiple lines by wrapping expressions
969 should be used in preference to using a backslash for line continuation. 1039 in parentheses. These should be used in preference to using a
1040 backslash for line continuation.
970 </p><p> 1041 </p><p>
971 E502: aaa = [123, \\n 123] 1042 E502: aaa = [123, \\n 123]
972 E502: aaa = ("bbb " \\n "ccc") 1043 E502: aaa = ("bbb " \\n "ccc")
973 </p><p> 1044 </p><p>
974 Okay: aaa = [123,\n 123] 1045 Okay: aaa = [123,\n 123]
1010 </p><p> 1081 </p><p>
1011 If patterns is unspecified, this always returns True. 1082 If patterns is unspecified, this always returns True.
1012 </p> 1083 </p>
1013 <div align="right"><a href="#top">Up</a></div> 1084 <div align="right"><a href="#top">Up</a></div>
1014 <hr /><hr /> 1085 <hr /><hr />
1015 <a NAME="generate_tokens" ID="generate_tokens"></a>
1016 <h2>generate_tokens</h2>
1017 <b>generate_tokens</b>(<i>self</i>)
1018 <p>
1019 Tokenize the file, run physical line checks and yield tokens.
1020 </p>
1021 <div align="right"><a href="#top">Up</a></div>
1022 <hr /><hr />
1023 <a NAME="get_checks" ID="get_checks"></a>
1024 <h2>get_checks</h2>
1025 <b>get_checks</b>(<i>self, argument_name</i>)
1026 <p>
1027 Get all the checks for this category.
1028 </p><p>
1029 Find all globally visible functions where the first argument name
1030 starts with argument_name and which contain selected tests.
1031 </p>
1032 <div align="right"><a href="#top">Up</a></div>
1033 <hr /><hr />
1034 <a NAME="get_count" ID="get_count"></a>
1035 <h2>get_count</h2>
1036 <b>get_count</b>(<i>self, prefix=''</i>)
1037 <p>
1038 Return the total count of errors and warnings.
1039 </p>
1040 <div align="right"><a href="#top">Up</a></div>
1041 <hr /><hr />
1042 <a NAME="get_file_results" ID="get_file_results"></a>
1043 <h2>get_file_results</h2>
1044 <b>get_file_results</b>(<i>self</i>)
1045 <p>
1046 Return the count of errors and warnings for this file.
1047 </p>
1048 <div align="right"><a href="#top">Up</a></div>
1049 <hr /><hr />
1050 <a NAME="get_file_results_1" ID="get_file_results_1"></a>
1051 <h2>get_file_results</h2>
1052 <b>get_file_results</b>(<i>self</i>)
1053 <p>
1054 Print the result and return the overall count for this file.
1055 </p>
1056 <div align="right"><a href="#top">Up</a></div>
1057 <hr /><hr />
1058 <a NAME="get_parser" ID="get_parser"></a> 1086 <a NAME="get_parser" ID="get_parser"></a>
1059 <h2>get_parser</h2> 1087 <h2>get_parser</h2>
1060 <b>get_parser</b>(<i>prog='pycodestyle', version=__version__</i>) 1088 <b>get_parser</b>(<i>prog='pycodestyle', version=__version__</i>)
1061 <p> 1089 <p>
1062 Create the parser for the program. 1090 Create the parser for the program.
1063 </p>
1064 <div align="right"><a href="#top">Up</a></div>
1065 <hr /><hr />
1066 <a NAME="get_statistics" ID="get_statistics"></a>
1067 <h2>get_statistics</h2>
1068 <b>get_statistics</b>(<i>self, prefix=''</i>)
1069 <p>
1070 Get statistics for message codes that start with the prefix.
1071 </p><p>
1072 prefix='' matches all errors and warnings
1073 prefix='E' matches all errors
1074 prefix='W' matches all warnings
1075 prefix='E4' matches all errors that have to do with imports
1076 </p>
1077 <div align="right"><a href="#top">Up</a></div>
1078 <hr /><hr />
1079 <a NAME="ignore_code" ID="ignore_code"></a>
1080 <h2>ignore_code</h2>
1081 <b>ignore_code</b>(<i>self, code</i>)
1082 <p>
1083 Check if the error code should be ignored.
1084 </p><p>
1085 If 'options.select' contains a prefix of the error code,
1086 return False. Else, if 'options.ignore' contains a prefix of
1087 the error code, return True.
1088 </p> 1091 </p>
1089 <div align="right"><a href="#top">Up</a></div> 1092 <div align="right"><a href="#top">Up</a></div>
1090 <hr /><hr /> 1093 <hr /><hr />
1091 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a> 1094 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
1092 <h2>imports_on_separate_lines</h2> 1095 <h2>imports_on_separate_lines</h2>
1103 Okay: import myclass 1106 Okay: import myclass
1104 Okay: import foo.bar.yourclass 1107 Okay: import foo.bar.yourclass
1105 </p> 1108 </p>
1106 <div align="right"><a href="#top">Up</a></div> 1109 <div align="right"><a href="#top">Up</a></div>
1107 <hr /><hr /> 1110 <hr /><hr />
1108 <a NAME="increment_logical_line" ID="increment_logical_line"></a>
1109 <h2>increment_logical_line</h2>
1110 <b>increment_logical_line</b>(<i>self</i>)
1111 <p>
1112 Signal a new logical line.
1113 </p>
1114 <div align="right"><a href="#top">Up</a></div>
1115 <hr /><hr />
1116 <a NAME="indentation" ID="indentation"></a> 1111 <a NAME="indentation" ID="indentation"></a>
1117 <h2>indentation</h2> 1112 <h2>indentation</h2>
1118 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>) 1113 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
1119 <p> 1114 <p>
1120 Use 4 spaces per indentation level. 1115 Use 4 spaces per indentation level.
1121 </p><p> 1116 </p><p>
1122 For really old code that you don't want to mess up, you can continue to 1117 For really old code that you don't want to mess up, you can continue
1123 use 8-space tabs. 1118 to use 8-space tabs.
1124 </p><p> 1119 </p><p>
1125 Okay: a = 1 1120 Okay: a = 1
1126 Okay: if a == 0:\n a = 1 1121 Okay: if a == 0:\n a = 1
1127 E111: a = 1 1122 E111: a = 1
1128 E114: # a = 1 1123 E114: # a = 1
1135 E113: a = 1\n b = 2 1130 E113: a = 1\n b = 2
1136 E116: a = 1\n # b = 2 1131 E116: a = 1\n # b = 2
1137 </p> 1132 </p>
1138 <div align="right"><a href="#top">Up</a></div> 1133 <div align="right"><a href="#top">Up</a></div>
1139 <hr /><hr /> 1134 <hr /><hr />
1140 <a NAME="init_checker_state" ID="init_checker_state"></a>
1141 <h2>init_checker_state</h2>
1142 <b>init_checker_state</b>(<i>self, name, argument_names</i>)
1143 <p>
1144 Prepare custom state for the specific checker plugin.
1145 </p>
1146 <div align="right"><a href="#top">Up</a></div>
1147 <hr /><hr />
1148 <a NAME="init_file" ID="init_file"></a>
1149 <h2>init_file</h2>
1150 <b>init_file</b>(<i>self, filename, lines, expected, line_offset</i>)
1151 <p>
1152 Signal a new file.
1153 </p>
1154 <div align="right"><a href="#top">Up</a></div>
1155 <hr /><hr />
1156 <a NAME="init_file_1" ID="init_file_1"></a>
1157 <h2>init_file</h2>
1158 <b>init_file</b>(<i>self, filename, lines, expected, line_offset</i>)
1159 <p>
1160 Signal a new file.
1161 </p>
1162 <div align="right"><a href="#top">Up</a></div>
1163 <hr /><hr />
1164 <a NAME="init_report" ID="init_report"></a>
1165 <h2>init_report</h2>
1166 <b>init_report</b>(<i>self, reporter=None</i>)
1167 <p>
1168 Initialize the report instance.
1169 </p>
1170 <div align="right"><a href="#top">Up</a></div>
1171 <hr /><hr />
1172 <a NAME="input_dir" ID="input_dir"></a>
1173 <h2>input_dir</h2>
1174 <b>input_dir</b>(<i>self, dirname</i>)
1175 <p>
1176 Check all files in this directory and all subdirectories.
1177 </p>
1178 <div align="right"><a href="#top">Up</a></div>
1179 <hr /><hr />
1180 <a NAME="input_file" ID="input_file"></a>
1181 <h2>input_file</h2>
1182 <b>input_file</b>(<i>self, filename, lines=None, expected=None, line_offset=0</i>)
1183 <p>
1184 Run all checks on a Python source file.
1185 </p>
1186 <div align="right"><a href="#top">Up</a></div>
1187 <hr /><hr />
1188 <a NAME="is_string_literal" ID="is_string_literal"></a> 1135 <a NAME="is_string_literal" ID="is_string_literal"></a>
1189 <h2>is_string_literal</h2> 1136 <h2>is_string_literal</h2>
1190 <b>is_string_literal</b>(<i>line</i>) 1137 <b>is_string_literal</b>(<i>line</i>)
1191 1138
1192 <div align="right"><a href="#top">Up</a></div> 1139 <div align="right"><a href="#top">Up</a></div>
1195 <h2>lru_cache</h2> 1142 <h2>lru_cache</h2>
1196 <b>lru_cache</b>(<i>maxsize=128</i>) 1143 <b>lru_cache</b>(<i>maxsize=128</i>)
1197 1144
1198 <div align="right"><a href="#top">Up</a></div> 1145 <div align="right"><a href="#top">Up</a></div>
1199 <hr /><hr /> 1146 <hr /><hr />
1147 <a NAME="maximum_doc_length" ID="maximum_doc_length"></a>
1148 <h2>maximum_doc_length</h2>
1149 <b>maximum_doc_length</b>(<i>logical_line, max_doc_length, noqa, tokens</i>)
1150 <p>
1151 Limit all doc lines to a maximum of 72 characters.
1152 </p><p>
1153 For flowing long blocks of text (docstrings or comments), limiting
1154 the length to 72 characters is recommended.
1155 </p><p>
1156 Reports warning W505
1157 </p>
1158 <div align="right"><a href="#top">Up</a></div>
1159 <hr /><hr />
1200 <a NAME="maximum_line_length" ID="maximum_line_length"></a> 1160 <a NAME="maximum_line_length" ID="maximum_line_length"></a>
1201 <h2>maximum_line_length</h2> 1161 <h2>maximum_line_length</h2>
1202 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline, line_number, noqa</i>) 1162 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline, line_number, noqa</i>)
1203 <p> 1163 <p>
1204 Limit all lines to a maximum of 79 characters. 1164 Limit all lines to a maximum of 79 characters.
1205 </p><p> 1165 </p><p>
1206 There are still many devices around that are limited to 80 character 1166 There are still many devices around that are limited to 80 character
1207 lines; plus, limiting windows to 80 characters makes it possible to have 1167 lines; plus, limiting windows to 80 characters makes it possible to
1208 several windows side-by-side. The default wrapping on such devices looks 1168 have several windows side-by-side. The default wrapping on such
1209 ugly. Therefore, please limit all lines to a maximum of 79 characters. 1169 devices looks ugly. Therefore, please limit all lines to a maximum
1210 For flowing long blocks of text (docstrings or comments), limiting the 1170 of 79 characters. For flowing long blocks of text (docstrings or
1211 length to 72 characters is recommended. 1171 comments), limiting the length to 72 characters is recommended.
1212 </p><p> 1172 </p><p>
1213 Reports error E501. 1173 Reports error E501.
1214 </p>
1215 <div align="right"><a href="#top">Up</a></div>
1216 <hr /><hr />
1217 <a NAME="maybe_check_physical" ID="maybe_check_physical"></a>
1218 <h2>maybe_check_physical</h2>
1219 <b>maybe_check_physical</b>(<i>self, token</i>)
1220 <p>
1221 If appropriate (based on token), check current physical line(s).
1222 </p> 1174 </p>
1223 <div align="right"><a href="#top">Up</a></div> 1175 <div align="right"><a href="#top">Up</a></div>
1224 <hr /><hr /> 1176 <hr /><hr />
1225 <a NAME="missing_whitespace" ID="missing_whitespace"></a> 1177 <a NAME="missing_whitespace" ID="missing_whitespace"></a>
1226 <h2>missing_whitespace</h2> 1178 <h2>missing_whitespace</h2>
1242 <hr /><hr /> 1194 <hr /><hr />
1243 <a NAME="missing_whitespace_after_import_keyword" ID="missing_whitespace_after_import_keyword"></a> 1195 <a NAME="missing_whitespace_after_import_keyword" ID="missing_whitespace_after_import_keyword"></a>
1244 <h2>missing_whitespace_after_import_keyword</h2> 1196 <h2>missing_whitespace_after_import_keyword</h2>
1245 <b>missing_whitespace_after_import_keyword</b>(<i>logical_line</i>) 1197 <b>missing_whitespace_after_import_keyword</b>(<i>logical_line</i>)
1246 <p> 1198 <p>
1247 Multiple imports in form from x import (a, b, c) should have space 1199 Multiple imports in form from x import (a, b, c) should have
1248 between import statement and parenthesised name list. 1200 space between import statement and parenthesised name list.
1249 </p><p> 1201 </p><p>
1250 Okay: from foo import (bar, baz) 1202 Okay: from foo import (bar, baz)
1251 E275: from foo import(bar, baz) 1203 E275: from foo import(bar, baz)
1252 E275: from importable.module import(bar, baz) 1204 E275: from importable.module import(bar, baz)
1253 </p> 1205 </p>
1290 <h2>module_imports_on_top_of_file</h2> 1242 <h2>module_imports_on_top_of_file</h2>
1291 <b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>) 1243 <b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>)
1292 <p> 1244 <p>
1293 Place imports at the top of the file. 1245 Place imports at the top of the file.
1294 </p><p> 1246 </p><p>
1295 Always put imports at the top of the file, just after any module comments 1247 Always put imports at the top of the file, just after any module
1296 and docstrings, and before module globals and constants. 1248 comments and docstrings, and before module globals and constants.
1297 </p><p> 1249 </p><p>
1298 Okay: import os 1250 Okay: import os
1299 Okay: # this is a comment\nimport os 1251 Okay: # this is a comment\nimport os
1300 Okay: '''this is a module docstring'''\nimport os 1252 Okay: '''this is a module docstring'''\nimport os
1301 Okay: r'''this is a module docstring'''\nimport os 1253 Okay: r'''this is a module docstring'''\nimport os
1343 <p> 1295 <p>
1344 Return a dictionary of matching lines. 1296 Return a dictionary of matching lines.
1345 </p> 1297 </p>
1346 <div align="right"><a href="#top">Up</a></div> 1298 <div align="right"><a href="#top">Up</a></div>
1347 <hr /><hr /> 1299 <hr /><hr />
1348 <a NAME="print_benchmark" ID="print_benchmark"></a>
1349 <h2>print_benchmark</h2>
1350 <b>print_benchmark</b>(<i>self</i>)
1351 <p>
1352 Print benchmark numbers.
1353 </p>
1354 <div align="right"><a href="#top">Up</a></div>
1355 <hr /><hr />
1356 <a NAME="print_statistics" ID="print_statistics"></a>
1357 <h2>print_statistics</h2>
1358 <b>print_statistics</b>(<i>self, prefix=''</i>)
1359 <p>
1360 Print overall statistics (number of errors and warnings).
1361 </p>
1362 <div align="right"><a href="#top">Up</a></div>
1363 <hr /><hr />
1364 <a NAME="process_options" ID="process_options"></a> 1300 <a NAME="process_options" ID="process_options"></a>
1365 <h2>process_options</h2> 1301 <h2>process_options</h2>
1366 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None</i>) 1302 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None</i>)
1367 <p> 1303 <p>
1368 Process options passed either via arglist or via command line args. 1304 Process options passed either via arglist or command line args.
1369 </p><p> 1305 </p><p>
1370 Passing in the ``config_file`` parameter allows other tools, such as flake8 1306 Passing in the ``config_file`` parameter allows other tools, such as
1371 to specify their own options to be processed in pycodestyle. 1307 flake8 to specify their own options to be processed in pycodestyle.
1372 </p> 1308 </p>
1373 <div align="right"><a href="#top">Up</a></div> 1309 <div align="right"><a href="#top">Up</a></div>
1374 <hr /><hr /> 1310 <hr /><hr />
1375 <a NAME="python_3000_async_await_keywords" ID="python_3000_async_await_keywords"></a> 1311 <a NAME="python_3000_async_await_keywords" ID="python_3000_async_await_keywords"></a>
1376 <h2>python_3000_async_await_keywords</h2> 1312 <h2>python_3000_async_await_keywords</h2>
1377 <b>python_3000_async_await_keywords</b>(<i>logical_line, tokens</i>) 1313 <b>python_3000_async_await_keywords</b>(<i>logical_line, tokens</i>)
1378 <p> 1314 <p>
1379 'async' and 'await' are reserved keywords starting with Python 3.7 1315 'async' and 'await' are reserved keywords starting at Python 3.7.
1380 </p><p> 1316 </p><p>
1381 W606: async = 42 1317 W606: async = 42
1382 W606: await = 42 1318 W606: await = 42
1383 Okay: async def read_data(db):\n data = await db.fetch('SELECT ...') 1319 Okay: async def read(db):\n data = await db.fetch('SELECT ...')
1384 </p> 1320 </p>
1385 <div align="right"><a href="#top">Up</a></div> 1321 <div align="right"><a href="#top">Up</a></div>
1386 <hr /><hr /> 1322 <hr /><hr />
1387 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a> 1323 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a>
1388 <h2>python_3000_backticks</h2> 1324 <h2>python_3000_backticks</h2>
1397 <hr /><hr /> 1333 <hr /><hr />
1398 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a> 1334 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
1399 <h2>python_3000_has_key</h2> 1335 <h2>python_3000_has_key</h2>
1400 <b>python_3000_has_key</b>(<i>logical_line, noqa</i>) 1336 <b>python_3000_has_key</b>(<i>logical_line, noqa</i>)
1401 <p> 1337 <p>
1402 The {}.has_key() method is removed in Python 3: use the 'in' operator. 1338 The {}.has_key() method is removed in Python 3: use the 'in'
1339 operator.
1403 </p><p> 1340 </p><p>
1404 Okay: if "alph" in d:\n print d["alph"] 1341 Okay: if "alph" in d:\n print d["alph"]
1405 W601: assert d.has_key('alph') 1342 W601: assert d.has_key('alph')
1406 </p> 1343 </p>
1407 <div align="right"><a href="#top">Up</a></div> 1344 <div align="right"><a href="#top">Up</a></div>
1408 <hr /><hr /> 1345 <hr /><hr />
1409 <a NAME="python_3000_invalid_escape_sequence" ID="python_3000_invalid_escape_sequence"></a> 1346 <a NAME="python_3000_invalid_escape_sequence" ID="python_3000_invalid_escape_sequence"></a>
1410 <h2>python_3000_invalid_escape_sequence</h2> 1347 <h2>python_3000_invalid_escape_sequence</h2>
1411 <b>python_3000_invalid_escape_sequence</b>(<i>logical_line, tokens</i>) 1348 <b>python_3000_invalid_escape_sequence</b>(<i>logical_line, tokens, noqa</i>)
1412 <p> 1349 <p>
1413 Invalid escape sequences are deprecated in Python 3.6. 1350 Invalid escape sequences are deprecated in Python 3.6.
1414 </p><p> 1351 </p><p>
1415 Okay: regex = r'\.png$' 1352 Okay: regex = r'\.png$'
1416 W605: regex = '\.png$' 1353 W605: regex = '\.png$'
1447 <h2>read_config</h2> 1384 <h2>read_config</h2>
1448 <b>read_config</b>(<i>options, args, arglist, parser</i>) 1385 <b>read_config</b>(<i>options, args, arglist, parser</i>)
1449 <p> 1386 <p>
1450 Read and parse configurations. 1387 Read and parse configurations.
1451 </p><p> 1388 </p><p>
1452 If a config file is specified on the command line with the "--config" 1389 If a config file is specified on the command line with the
1453 option, then only it is used for configuration. 1390 "--config" option, then only it is used for configuration.
1454 </p><p> 1391 </p><p>
1455 Otherwise, the user configuration (~/.config/pycodestyle) and any local 1392 Otherwise, the user configuration (~/.config/pycodestyle) and any
1456 configurations in the current directory or above will be merged together 1393 local configurations in the current directory or above will be
1457 (in that order) using the read method of ConfigParser. 1394 merged together (in that order) using the read method of
1458 </p> 1395 ConfigParser.
1459 <div align="right"><a href="#top">Up</a></div>
1460 <hr /><hr />
1461 <a NAME="readline" ID="readline"></a>
1462 <h2>readline</h2>
1463 <b>readline</b>(<i>self</i>)
1464 <p>
1465 Get the next line from the input buffer.
1466 </p> 1396 </p>
1467 <div align="right"><a href="#top">Up</a></div> 1397 <div align="right"><a href="#top">Up</a></div>
1468 <hr /><hr /> 1398 <hr /><hr />
1469 <a NAME="readlines" ID="readlines"></a> 1399 <a NAME="readlines" ID="readlines"></a>
1470 <h2>readlines</h2> 1400 <h2>readlines</h2>
1488 <p> 1418 <p>
1489 Register a new check object. 1419 Register a new check object.
1490 </p> 1420 </p>
1491 <div align="right"><a href="#top">Up</a></div> 1421 <div align="right"><a href="#top">Up</a></div>
1492 <hr /><hr /> 1422 <hr /><hr />
1493 <a NAME="report_invalid_syntax" ID="report_invalid_syntax"></a>
1494 <h2>report_invalid_syntax</h2>
1495 <b>report_invalid_syntax</b>(<i>self</i>)
1496 <p>
1497 Check if the syntax is valid.
1498 </p>
1499 <div align="right"><a href="#top">Up</a></div>
1500 <hr /><hr />
1501 <a NAME="run_check" ID="run_check"></a>
1502 <h2>run_check</h2>
1503 <b>run_check</b>(<i>self, check, argument_names</i>)
1504 <p>
1505 Run a check plugin.
1506 </p>
1507 <div align="right"><a href="#top">Up</a></div>
1508 <hr /><hr />
1509 <a NAME="start" ID="start"></a>
1510 <h2>start</h2>
1511 <b>start</b>(<i>self</i>)
1512 <p>
1513 Start the timer.
1514 </p>
1515 <div align="right"><a href="#top">Up</a></div>
1516 <hr /><hr />
1517 <a NAME="stdin_get_value" ID="stdin_get_value"></a> 1423 <a NAME="stdin_get_value" ID="stdin_get_value"></a>
1518 <h2>stdin_get_value</h2> 1424 <h2>stdin_get_value</h2>
1519 <b>stdin_get_value</b>(<i></i>) 1425 <b>stdin_get_value</b>(<i></i>)
1520 <p> 1426 <p>
1521 Read the value from stdin. 1427 Read the value from stdin.
1522 </p> 1428 </p>
1523 <div align="right"><a href="#top">Up</a></div> 1429 <div align="right"><a href="#top">Up</a></div>
1524 <hr /><hr /> 1430 <hr /><hr />
1525 <a NAME="stop" ID="stop"></a>
1526 <h2>stop</h2>
1527 <b>stop</b>(<i>self</i>)
1528 <p>
1529 Stop the timer.
1530 </p>
1531 <div align="right"><a href="#top">Up</a></div>
1532 <hr /><hr />
1533 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a> 1431 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
1534 <h2>tabs_obsolete</h2> 1432 <h2>tabs_obsolete</h2>
1535 <b>tabs_obsolete</b>(<i>physical_line</i>) 1433 <b>tabs_obsolete</b>(<i>physical_line</i>)
1536 <p> 1434 <p>
1537 For new projects, spaces-only are strongly recommended over tabs. 1435 On new projects, spaces-only are strongly recommended over tabs.
1538 </p><p> 1436 </p><p>
1539 Okay: if True:\n return 1437 Okay: if True:\n return
1540 W191: if True:\n\treturn 1438 W191: if True:\n\treturn
1541 </p> 1439 </p>
1542 <div align="right"><a href="#top">Up</a></div> 1440 <div align="right"><a href="#top">Up</a></div>
1546 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>) 1444 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
1547 <p> 1445 <p>
1548 Never mix tabs and spaces. 1446 Never mix tabs and spaces.
1549 </p><p> 1447 </p><p>
1550 The most popular way of indenting Python is with spaces only. The 1448 The most popular way of indenting Python is with spaces only. The
1551 second-most popular way is with tabs only. Code indented with a mixture 1449 second-most popular way is with tabs only. Code indented with a
1552 of tabs and spaces should be converted to using spaces exclusively. When 1450 mixture of tabs and spaces should be converted to using spaces
1553 invoking the Python command line interpreter with the -t option, it issues 1451 exclusively. When invoking the Python command line interpreter with
1554 warnings about code that illegally mixes tabs and spaces. When using -tt 1452 the -t option, it issues warnings about code that illegally mixes
1555 these warnings become errors. These options are highly recommended! 1453 tabs and spaces. When using -tt these warnings become errors.
1556 </p><p> 1454 These options are highly recommended!
1557 Okay: if a == 0:\n a = 1\n b = 1 1455 </p><p>
1456 Okay: if a == 0:\n a = 1\n b = 1
1558 E101: if a == 0:\n a = 1\n\tb = 1 1457 E101: if a == 0:\n a = 1\n\tb = 1
1559 </p> 1458 </p>
1560 <div align="right"><a href="#top">Up</a></div> 1459 <div align="right"><a href="#top">Up</a></div>
1561 <hr /><hr /> 1460 <hr /><hr />
1562 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a> 1461 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
1576 <h2>trailing_whitespace</h2> 1475 <h2>trailing_whitespace</h2>
1577 <b>trailing_whitespace</b>(<i>physical_line</i>) 1476 <b>trailing_whitespace</b>(<i>physical_line</i>)
1578 <p> 1477 <p>
1579 Trailing whitespace is superfluous. 1478 Trailing whitespace is superfluous.
1580 </p><p> 1479 </p><p>
1581 The warning returned varies on whether the line itself is blank, for easier 1480 The warning returned varies on whether the line itself is blank,
1582 filtering for those who want to indent their blank lines. 1481 for easier filtering for those who want to indent their blank lines.
1583 </p><p> 1482 </p><p>
1584 Okay: spam(1)\n# 1483 Okay: spam(1)\n#
1585 W291: spam(1) \n# 1484 W291: spam(1) \n#
1586 W293: class Foo(object):\n \n bang = 12 1485 W293: class Foo(object):\n \n bang = 12
1587 </p> 1486 </p>
1629 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>) 1528 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>)
1630 <p> 1529 <p>
1631 Don't use spaces around the '=' sign in function arguments. 1530 Don't use spaces around the '=' sign in function arguments.
1632 </p><p> 1531 </p><p>
1633 Don't use spaces around the '=' sign when used to indicate a 1532 Don't use spaces around the '=' sign when used to indicate a
1634 keyword argument or a default parameter value, except when using a type 1533 keyword argument or a default parameter value, except when
1635 annotation. 1534 using a type annotation.
1636 </p><p> 1535 </p><p>
1637 Okay: def complex(real, imag=0.0): 1536 Okay: def complex(real, imag=0.0):
1638 Okay: return magic(r=real, i=imag) 1537 Okay: return magic(r=real, i=imag)
1639 Okay: boolean(a == b) 1538 Okay: boolean(a == b)
1640 Okay: boolean(a != b) 1539 Okay: boolean(a != b)
1667 <h2>whitespace_before_comment</h2> 1566 <h2>whitespace_before_comment</h2>
1668 <b>whitespace_before_comment</b>(<i>logical_line, tokens</i>) 1567 <b>whitespace_before_comment</b>(<i>logical_line, tokens</i>)
1669 <p> 1568 <p>
1670 Separate inline comments by at least two spaces. 1569 Separate inline comments by at least two spaces.
1671 </p><p> 1570 </p><p>
1672 An inline comment is a comment on the same line as a statement. Inline 1571 An inline comment is a comment on the same line as a statement.
1673 comments should be separated by at least two spaces from the statement. 1572 Inline comments should be separated by at least two spaces from the
1674 They should start with a # and a single space. 1573 statement. They should start with a # and a single space.
1675 </p><p> 1574 </p><p>
1676 Each line of a block comment starts with a # and a single space 1575 Each line of a block comment starts with a # and a single space
1677 (unless it is indented text inside the comment). 1576 (unless it is indented text inside the comment).
1678 </p><p> 1577 </p><p>
1679 Okay: x = x + 1 # Increment x 1578 Okay: x = x + 1 # Increment x

eric ide

mercurial