src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle.html

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8752
3c1ea4dfb691
child 9377
b9c8dc3b7da1
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</title>
4 <meta charset="UTF-8">
5 <link rel="stylesheet" href="styles.css">
6 </head>
7 <body>
8 <a NAME="top" ID="top"></a>
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</h1>
10
11 <h3>Global Attributes</h3>
12
13 <table>
14 <tr><td>ARITHMETIC_OP</td></tr><tr><td>ASSIGNMENT_EXPRESSION_OP</td></tr><tr><td>BENCHMARK_KEYS</td></tr><tr><td>BLANK_EXCEPT_REGEX</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>INDENT_SIZE</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>_SYMBOLIC_OPS</td></tr><tr><td>__version__</td></tr><tr><td>_checks</td></tr><tr><td>noqa</td></tr>
15 </table>
16 <h3>Classes</h3>
17
18 <table>
19
20 <tr>
21 <td><a href="#BaseReport">BaseReport</a></td>
22 <td>Collect the results of the checks.</td>
23 </tr>
24 <tr>
25 <td><a href="#Checker">Checker</a></td>
26 <td>Load a Python source file, tokenize it, check coding style.</td>
27 </tr>
28 <tr>
29 <td><a href="#DiffReport">DiffReport</a></td>
30 <td>Collect and print the results for the changed lines only.</td>
31 </tr>
32 <tr>
33 <td><a href="#FileReport">FileReport</a></td>
34 <td>Collect the results of the checks and print the filenames.</td>
35 </tr>
36 <tr>
37 <td><a href="#StandardReport">StandardReport</a></td>
38 <td>Collect and print the results of the checks.</td>
39 </tr>
40 <tr>
41 <td><a href="#StyleGuide">StyleGuide</a></td>
42 <td>Initialize a PEP-8 instance with few options.</td>
43 </tr>
44 </table>
45 <h3>Functions</h3>
46
47 <table>
48
49 <tr>
50 <td><a href="#_add_check">_add_check</a></td>
51 <td></td>
52 </tr>
53 <tr>
54 <td><a href="#_break_around_binary_operators">_break_around_binary_operators</a></td>
55 <td>Private function to reduce duplication.</td>
56 </tr>
57 <tr>
58 <td><a href="#_get_parameters">_get_parameters</a></td>
59 <td></td>
60 </tr>
61 <tr>
62 <td><a href="#_is_binary_operator">_is_binary_operator</a></td>
63 <td></td>
64 </tr>
65 <tr>
66 <td><a href="#_is_eol_token">_is_eol_token</a></td>
67 <td></td>
68 </tr>
69 <tr>
70 <td><a href="#_is_one_liner">_is_one_liner</a></td>
71 <td></td>
72 </tr>
73 <tr>
74 <td><a href="#_main">_main</a></td>
75 <td>Parse options and run checks on Python source.</td>
76 </tr>
77 <tr>
78 <td><a href="#_parse_multi_options">_parse_multi_options</a></td>
79 <td>Split and strip and discard empties.</td>
80 </tr>
81 <tr>
82 <td><a href="#ambiguous_identifier">ambiguous_identifier</a></td>
83 <td>Never use the characters 'l', 'O', or 'I' as variable names.</td>
84 </tr>
85 <tr>
86 <td><a href="#bare_except">bare_except</a></td>
87 <td>When catching exceptions, mention specific exceptions when possible.</td>
88 </tr>
89 <tr>
90 <td><a href="#blank_lines">blank_lines</a></td>
91 <td>Separate top-level function and class definitions with two blank lines.</td>
92 </tr>
93 <tr>
94 <td><a href="#break_after_binary_operator">break_after_binary_operator</a></td>
95 <td>Avoid breaks after binary operators.</td>
96 </tr>
97 <tr>
98 <td><a href="#break_before_binary_operator">break_before_binary_operator</a></td>
99 <td>Avoid breaks before binary operators.</td>
100 </tr>
101 <tr>
102 <td><a href="#comparison_negative">comparison_negative</a></td>
103 <td>Negative comparison should be done using "not in" and "is not".</td>
104 </tr>
105 <tr>
106 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
107 <td>Comparison to singletons should use "is" or "is not".</td>
108 </tr>
109 <tr>
110 <td><a href="#comparison_type">comparison_type</a></td>
111 <td>Object type comparisons should always use isinstance().</td>
112 </tr>
113 <tr>
114 <td><a href="#compound_statements">compound_statements</a></td>
115 <td>Compound statements (on the same line) are generally discouraged.</td>
116 </tr>
117 <tr>
118 <td><a href="#continued_indentation">continued_indentation</a></td>
119 <td>Continuation lines indentation.</td>
120 </tr>
121 <tr>
122 <td><a href="#expand_indent">expand_indent</a></td>
123 <td>Return the amount of indentation.</td>
124 </tr>
125 <tr>
126 <td><a href="#explicit_line_join">explicit_line_join</a></td>
127 <td>Avoid explicit line join between brackets.</td>
128 </tr>
129 <tr>
130 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
131 <td>Avoid extraneous whitespace.</td>
132 </tr>
133 <tr>
134 <td><a href="#filename_match">filename_match</a></td>
135 <td>Check if patterns contains a pattern that matches filename.</td>
136 </tr>
137 <tr>
138 <td><a href="#get_parser">get_parser</a></td>
139 <td>Create the parser for the program.</td>
140 </tr>
141 <tr>
142 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
143 <td>Place imports on separate lines.</td>
144 </tr>
145 <tr>
146 <td><a href="#indentation">indentation</a></td>
147 <td>Use indent_size (PEP8 says 4) spaces per indentation level.</td>
148 </tr>
149 <tr>
150 <td><a href="#is_string_literal">is_string_literal</a></td>
151 <td></td>
152 </tr>
153 <tr>
154 <td><a href="#lru_cache">lru_cache</a></td>
155 <td></td>
156 </tr>
157 <tr>
158 <td><a href="#maximum_doc_length">maximum_doc_length</a></td>
159 <td>Limit all doc lines to a maximum of 72 characters.</td>
160 </tr>
161 <tr>
162 <td><a href="#maximum_line_length">maximum_line_length</a></td>
163 <td>Limit all lines to a maximum of 79 characters.</td>
164 </tr>
165 <tr>
166 <td><a href="#missing_whitespace">missing_whitespace</a></td>
167 <td>Each comma, semicolon or colon should be followed by whitespace.</td>
168 </tr>
169 <tr>
170 <td><a href="#missing_whitespace_after_import_keyword">missing_whitespace_after_import_keyword</a></td>
171 <td>Multiple imports in form from x import (a, b, c) should have space between import statement and parenthesised name list.</td>
172 </tr>
173 <tr>
174 <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td>
175 <td>Surround operators with a single space on either side.</td>
176 </tr>
177 <tr>
178 <td><a href="#module_imports_on_top_of_file">module_imports_on_top_of_file</a></td>
179 <td>Place imports at the top of the file.</td>
180 </tr>
181 <tr>
182 <td><a href="#mute_string">mute_string</a></td>
183 <td>Replace contents with 'xxx' to prevent syntax matching.</td>
184 </tr>
185 <tr>
186 <td><a href="#normalize_paths">normalize_paths</a></td>
187 <td>Parse a comma-separated list of paths.</td>
188 </tr>
189 <tr>
190 <td><a href="#parse_udiff">parse_udiff</a></td>
191 <td>Return a dictionary of matching lines.</td>
192 </tr>
193 <tr>
194 <td><a href="#process_options">process_options</a></td>
195 <td>Process options passed either via arglist or command line args.</td>
196 </tr>
197 <tr>
198 <td><a href="#python_3000_async_await_keywords">python_3000_async_await_keywords</a></td>
199 <td>'async' and 'await' are reserved keywords starting at Python 3.7.</td>
200 </tr>
201 <tr>
202 <td><a href="#python_3000_backticks">python_3000_backticks</a></td>
203 <td>Use repr() instead of backticks in Python 3.</td>
204 </tr>
205 <tr>
206 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
207 <td>The {}.has_key() method is removed in Python 3: use the 'in' operator.</td>
208 </tr>
209 <tr>
210 <td><a href="#python_3000_invalid_escape_sequence">python_3000_invalid_escape_sequence</a></td>
211 <td>Invalid escape sequences are deprecated in Python 3.6.</td>
212 </tr>
213 <tr>
214 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
215 <td>New code should always use != instead of <>.</td>
216 </tr>
217 <tr>
218 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td>
219 <td>When raising an exception, use "raise ValueError('message')".</td>
220 </tr>
221 <tr>
222 <td><a href="#read_config">read_config</a></td>
223 <td>Read and parse configurations.</td>
224 </tr>
225 <tr>
226 <td><a href="#readlines">readlines</a></td>
227 <td>Read the source code.</td>
228 </tr>
229 <tr>
230 <td><a href="#readlines_1">readlines</a></td>
231 <td>Read the source code.</td>
232 </tr>
233 <tr>
234 <td><a href="#register_check">register_check</a></td>
235 <td>Register a new check object.</td>
236 </tr>
237 <tr>
238 <td><a href="#stdin_get_value">stdin_get_value</a></td>
239 <td>Read the value from stdin.</td>
240 </tr>
241 <tr>
242 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
243 <td>On new projects, spaces-only are strongly recommended over tabs.</td>
244 </tr>
245 <tr>
246 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
247 <td>Never mix tabs and spaces.</td>
248 </tr>
249 <tr>
250 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
251 <td>Trailing blank lines are superfluous.</td>
252 </tr>
253 <tr>
254 <td><a href="#trailing_whitespace">trailing_whitespace</a></td>
255 <td>Trailing whitespace is superfluous.</td>
256 </tr>
257 <tr>
258 <td><a href="#update_counts">update_counts</a></td>
259 <td>Adds one to the counts of each appearance of characters in s, for characters in counts</td>
260 </tr>
261 <tr>
262 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
263 <td>Avoid extraneous whitespace after a comma or a colon.</td>
264 </tr>
265 <tr>
266 <td><a href="#whitespace_around_keywords">whitespace_around_keywords</a></td>
267 <td>Avoid extraneous whitespace around keywords.</td>
268 </tr>
269 <tr>
270 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
271 <td>Don't use spaces around the '=' sign in function arguments.</td>
272 </tr>
273 <tr>
274 <td><a href="#whitespace_around_operator">whitespace_around_operator</a></td>
275 <td>Avoid extraneous whitespace around an operator.</td>
276 </tr>
277 <tr>
278 <td><a href="#whitespace_before_comment">whitespace_before_comment</a></td>
279 <td>Separate inline comments by at least two spaces.</td>
280 </tr>
281 <tr>
282 <td><a href="#whitespace_before_parameters">whitespace_before_parameters</a></td>
283 <td>Avoid extraneous whitespace.</td>
284 </tr>
285 </table>
286 <hr />
287 <hr />
288 <a NAME="BaseReport" ID="BaseReport"></a>
289 <h2>BaseReport</h2>
290
291 <p>
292 Collect the results of the checks.
293 </p>
294 <h3>Derived from</h3>
295 object
296 <h3>Class Attributes</h3>
297
298 <table>
299 <tr><td>print_filename</td></tr>
300 </table>
301 <h3>Class Methods</h3>
302
303 <table>
304 <tr><td>None</td></tr>
305 </table>
306 <h3>Methods</h3>
307
308 <table>
309
310 <tr>
311 <td><a href="#BaseReport.__init__">BaseReport</a></td>
312 <td></td>
313 </tr>
314 <tr>
315 <td><a href="#BaseReport.error">error</a></td>
316 <td>Report an error, according to options.</td>
317 </tr>
318 <tr>
319 <td><a href="#BaseReport.error_args">error_args</a></td>
320 <td>Report an error, according to options.</td>
321 </tr>
322 <tr>
323 <td><a href="#BaseReport.get_count">get_count</a></td>
324 <td>Return the total count of errors and warnings.</td>
325 </tr>
326 <tr>
327 <td><a href="#BaseReport.get_file_results">get_file_results</a></td>
328 <td>Return the count of errors and warnings for this file.</td>
329 </tr>
330 <tr>
331 <td><a href="#BaseReport.get_statistics">get_statistics</a></td>
332 <td>Get statistics for message codes that start with the prefix.</td>
333 </tr>
334 <tr>
335 <td><a href="#BaseReport.increment_logical_line">increment_logical_line</a></td>
336 <td>Signal a new logical line.</td>
337 </tr>
338 <tr>
339 <td><a href="#BaseReport.init_file">init_file</a></td>
340 <td>Signal a new file.</td>
341 </tr>
342 <tr>
343 <td><a href="#BaseReport.print_benchmark">print_benchmark</a></td>
344 <td>Print benchmark numbers.</td>
345 </tr>
346 <tr>
347 <td><a href="#BaseReport.print_statistics">print_statistics</a></td>
348 <td>Print overall statistics (number of errors and warnings).</td>
349 </tr>
350 <tr>
351 <td><a href="#BaseReport.start">start</a></td>
352 <td>Start the timer.</td>
353 </tr>
354 <tr>
355 <td><a href="#BaseReport.stop">stop</a></td>
356 <td>Stop the timer.</td>
357 </tr>
358 </table>
359 <h3>Static Methods</h3>
360
361 <table>
362 <tr><td>None</td></tr>
363 </table>
364
365 <a NAME="BaseReport.__init__" ID="BaseReport.__init__"></a>
366 <h4>BaseReport (Constructor)</h4>
367 <b>BaseReport</b>(<i>options</i>)
368
369 <a NAME="BaseReport.error" ID="BaseReport.error"></a>
370 <h4>BaseReport.error</h4>
371 <b>error</b>(<i>line_number, offset, text, check</i>)
372
373 <p>
374 Report an error, according to options.
375 </p>
376 <a NAME="BaseReport.error_args" ID="BaseReport.error_args"></a>
377 <h4>BaseReport.error_args</h4>
378 <b>error_args</b>(<i>line_number, offset, text, check, *args</i>)
379
380 <p>
381 Report an error, according to options.
382 </p>
383 <a NAME="BaseReport.get_count" ID="BaseReport.get_count"></a>
384 <h4>BaseReport.get_count</h4>
385 <b>get_count</b>(<i>prefix=''</i>)
386
387 <p>
388 Return the total count of errors and warnings.
389 </p>
390 <a NAME="BaseReport.get_file_results" ID="BaseReport.get_file_results"></a>
391 <h4>BaseReport.get_file_results</h4>
392 <b>get_file_results</b>(<i></i>)
393
394 <p>
395 Return the count of errors and warnings for this file.
396 </p>
397 <a NAME="BaseReport.get_statistics" ID="BaseReport.get_statistics"></a>
398 <h4>BaseReport.get_statistics</h4>
399 <b>get_statistics</b>(<i>prefix=''</i>)
400
401 <p>
402 Get statistics for message codes that start with the prefix.
403 </p>
404 <p>
405 prefix='' matches all errors and warnings
406 prefix='E' matches all errors
407 prefix='W' matches all warnings
408 prefix='E4' matches all errors that have to do with imports
409 </p>
410 <a NAME="BaseReport.increment_logical_line" ID="BaseReport.increment_logical_line"></a>
411 <h4>BaseReport.increment_logical_line</h4>
412 <b>increment_logical_line</b>(<i></i>)
413
414 <p>
415 Signal a new logical line.
416 </p>
417 <a NAME="BaseReport.init_file" ID="BaseReport.init_file"></a>
418 <h4>BaseReport.init_file</h4>
419 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
420
421 <p>
422 Signal a new file.
423 </p>
424 <a NAME="BaseReport.print_benchmark" ID="BaseReport.print_benchmark"></a>
425 <h4>BaseReport.print_benchmark</h4>
426 <b>print_benchmark</b>(<i></i>)
427
428 <p>
429 Print benchmark numbers.
430 </p>
431 <a NAME="BaseReport.print_statistics" ID="BaseReport.print_statistics"></a>
432 <h4>BaseReport.print_statistics</h4>
433 <b>print_statistics</b>(<i>prefix=''</i>)
434
435 <p>
436 Print overall statistics (number of errors and warnings).
437 </p>
438 <a NAME="BaseReport.start" ID="BaseReport.start"></a>
439 <h4>BaseReport.start</h4>
440 <b>start</b>(<i></i>)
441
442 <p>
443 Start the timer.
444 </p>
445 <a NAME="BaseReport.stop" ID="BaseReport.stop"></a>
446 <h4>BaseReport.stop</h4>
447 <b>stop</b>(<i></i>)
448
449 <p>
450 Stop the timer.
451 </p>
452 <div align="right"><a href="#top">Up</a></div>
453 <hr />
454 <hr />
455 <a NAME="Checker" ID="Checker"></a>
456 <h2>Checker</h2>
457
458 <p>
459 Load a Python source file, tokenize it, check coding style.
460 </p>
461 <h3>Derived from</h3>
462 object
463 <h3>Class Attributes</h3>
464
465 <table>
466 <tr><td>None</td></tr>
467 </table>
468 <h3>Class Methods</h3>
469
470 <table>
471 <tr><td>None</td></tr>
472 </table>
473 <h3>Methods</h3>
474
475 <table>
476
477 <tr>
478 <td><a href="#Checker.__init__">Checker</a></td>
479 <td></td>
480 </tr>
481 <tr>
482 <td><a href="#Checker.build_tokens_line">build_tokens_line</a></td>
483 <td>Build a logical line from tokens.</td>
484 </tr>
485 <tr>
486 <td><a href="#Checker.check_all">check_all</a></td>
487 <td>Run all checks on the input file.</td>
488 </tr>
489 <tr>
490 <td><a href="#Checker.check_ast">check_ast</a></td>
491 <td>Build the file's AST and run all AST checks.</td>
492 </tr>
493 <tr>
494 <td><a href="#Checker.check_logical">check_logical</a></td>
495 <td>Build a line from tokens and run all logical checks on it.</td>
496 </tr>
497 <tr>
498 <td><a href="#Checker.check_physical">check_physical</a></td>
499 <td>Run all physical checks on a raw input line.</td>
500 </tr>
501 <tr>
502 <td><a href="#Checker.generate_tokens">generate_tokens</a></td>
503 <td>Tokenize file, run physical line checks and yield tokens.</td>
504 </tr>
505 <tr>
506 <td><a href="#Checker.init_checker_state">init_checker_state</a></td>
507 <td>Prepare custom state for the specific checker plugin.</td>
508 </tr>
509 <tr>
510 <td><a href="#Checker.maybe_check_physical">maybe_check_physical</a></td>
511 <td>If appropriate for token, check current physical line(s).</td>
512 </tr>
513 <tr>
514 <td><a href="#Checker.readline">readline</a></td>
515 <td>Get the next line from the input buffer.</td>
516 </tr>
517 <tr>
518 <td><a href="#Checker.report_invalid_syntax">report_invalid_syntax</a></td>
519 <td>Check if the syntax is valid.</td>
520 </tr>
521 <tr>
522 <td><a href="#Checker.run_check">run_check</a></td>
523 <td>Run a check plugin.</td>
524 </tr>
525 </table>
526 <h3>Static Methods</h3>
527
528 <table>
529 <tr><td>None</td></tr>
530 </table>
531
532 <a NAME="Checker.__init__" ID="Checker.__init__"></a>
533 <h4>Checker (Constructor)</h4>
534 <b>Checker</b>(<i>filename=None, lines=None, options=None, report=None, **kwargs</i>)
535
536 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a>
537 <h4>Checker.build_tokens_line</h4>
538 <b>build_tokens_line</b>(<i></i>)
539
540 <p>
541 Build a logical line from tokens.
542 </p>
543 <a NAME="Checker.check_all" ID="Checker.check_all"></a>
544 <h4>Checker.check_all</h4>
545 <b>check_all</b>(<i>expected=None, line_offset=0</i>)
546
547 <p>
548 Run all checks on the input file.
549 </p>
550 <a NAME="Checker.check_ast" ID="Checker.check_ast"></a>
551 <h4>Checker.check_ast</h4>
552 <b>check_ast</b>(<i></i>)
553
554 <p>
555 Build the file's AST and run all AST checks.
556 </p>
557 <a NAME="Checker.check_logical" ID="Checker.check_logical"></a>
558 <h4>Checker.check_logical</h4>
559 <b>check_logical</b>(<i></i>)
560
561 <p>
562 Build a line from tokens and run all logical checks on it.
563 </p>
564 <a NAME="Checker.check_physical" ID="Checker.check_physical"></a>
565 <h4>Checker.check_physical</h4>
566 <b>check_physical</b>(<i>line</i>)
567
568 <p>
569 Run all physical checks on a raw input line.
570 </p>
571 <a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a>
572 <h4>Checker.generate_tokens</h4>
573 <b>generate_tokens</b>(<i></i>)
574
575 <p>
576 Tokenize file, run physical line checks and yield tokens.
577 </p>
578 <a NAME="Checker.init_checker_state" ID="Checker.init_checker_state"></a>
579 <h4>Checker.init_checker_state</h4>
580 <b>init_checker_state</b>(<i>name, argument_names</i>)
581
582 <p>
583 Prepare custom state for the specific checker plugin.
584 </p>
585 <a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a>
586 <h4>Checker.maybe_check_physical</h4>
587 <b>maybe_check_physical</b>(<i>token, prev_physical</i>)
588
589 <p>
590 If appropriate for token, check current physical line(s).
591 </p>
592 <a NAME="Checker.readline" ID="Checker.readline"></a>
593 <h4>Checker.readline</h4>
594 <b>readline</b>(<i></i>)
595
596 <p>
597 Get the next line from the input buffer.
598 </p>
599 <a NAME="Checker.report_invalid_syntax" ID="Checker.report_invalid_syntax"></a>
600 <h4>Checker.report_invalid_syntax</h4>
601 <b>report_invalid_syntax</b>(<i></i>)
602
603 <p>
604 Check if the syntax is valid.
605 </p>
606 <a NAME="Checker.run_check" ID="Checker.run_check"></a>
607 <h4>Checker.run_check</h4>
608 <b>run_check</b>(<i>check, argument_names</i>)
609
610 <p>
611 Run a check plugin.
612 </p>
613 <div align="right"><a href="#top">Up</a></div>
614 <hr />
615 <hr />
616 <a NAME="DiffReport" ID="DiffReport"></a>
617 <h2>DiffReport</h2>
618
619 <p>
620 Collect and print the results for the changed lines only.
621 </p>
622 <h3>Derived from</h3>
623 StandardReport
624 <h3>Class Attributes</h3>
625
626 <table>
627 <tr><td>None</td></tr>
628 </table>
629 <h3>Class Methods</h3>
630
631 <table>
632 <tr><td>None</td></tr>
633 </table>
634 <h3>Methods</h3>
635
636 <table>
637
638 <tr>
639 <td><a href="#DiffReport.__init__">DiffReport</a></td>
640 <td></td>
641 </tr>
642 <tr>
643 <td><a href="#DiffReport.error">error</a></td>
644 <td></td>
645 </tr>
646 </table>
647 <h3>Static Methods</h3>
648
649 <table>
650 <tr><td>None</td></tr>
651 </table>
652
653 <a NAME="DiffReport.__init__" ID="DiffReport.__init__"></a>
654 <h4>DiffReport (Constructor)</h4>
655 <b>DiffReport</b>(<i>options</i>)
656
657 <a NAME="DiffReport.error" ID="DiffReport.error"></a>
658 <h4>DiffReport.error</h4>
659 <b>error</b>(<i>line_number, offset, text, check</i>)
660
661 <div align="right"><a href="#top">Up</a></div>
662 <hr />
663 <hr />
664 <a NAME="FileReport" ID="FileReport"></a>
665 <h2>FileReport</h2>
666
667 <p>
668 Collect the results of the checks and print the filenames.
669 </p>
670 <h3>Derived from</h3>
671 BaseReport
672 <h3>Class Attributes</h3>
673
674 <table>
675 <tr><td>print_filename</td></tr>
676 </table>
677 <h3>Class Methods</h3>
678
679 <table>
680 <tr><td>None</td></tr>
681 </table>
682 <h3>Methods</h3>
683
684 <table>
685 <tr><td>None</td></tr>
686 </table>
687 <h3>Static Methods</h3>
688
689 <table>
690 <tr><td>None</td></tr>
691 </table>
692
693 <div align="right"><a href="#top">Up</a></div>
694 <hr />
695 <hr />
696 <a NAME="StandardReport" ID="StandardReport"></a>
697 <h2>StandardReport</h2>
698
699 <p>
700 Collect and print the results of the checks.
701 </p>
702 <h3>Derived from</h3>
703 BaseReport
704 <h3>Class Attributes</h3>
705
706 <table>
707 <tr><td>None</td></tr>
708 </table>
709 <h3>Class Methods</h3>
710
711 <table>
712 <tr><td>None</td></tr>
713 </table>
714 <h3>Methods</h3>
715
716 <table>
717
718 <tr>
719 <td><a href="#StandardReport.__init__">StandardReport</a></td>
720 <td></td>
721 </tr>
722 <tr>
723 <td><a href="#StandardReport.error">error</a></td>
724 <td>Report an error, according to options.</td>
725 </tr>
726 <tr>
727 <td><a href="#StandardReport.error_args">error_args</a></td>
728 <td>Report an error, according to options.</td>
729 </tr>
730 <tr>
731 <td><a href="#StandardReport.get_file_results">get_file_results</a></td>
732 <td>Print results and return the overall count for this file.</td>
733 </tr>
734 <tr>
735 <td><a href="#StandardReport.init_file">init_file</a></td>
736 <td>Signal a new file.</td>
737 </tr>
738 </table>
739 <h3>Static Methods</h3>
740
741 <table>
742 <tr><td>None</td></tr>
743 </table>
744
745 <a NAME="StandardReport.__init__" ID="StandardReport.__init__"></a>
746 <h4>StandardReport (Constructor)</h4>
747 <b>StandardReport</b>(<i>options</i>)
748
749 <a NAME="StandardReport.error" ID="StandardReport.error"></a>
750 <h4>StandardReport.error</h4>
751 <b>error</b>(<i>line_number, offset, text, check</i>)
752
753 <p>
754 Report an error, according to options.
755 </p>
756 <a NAME="StandardReport.error_args" ID="StandardReport.error_args"></a>
757 <h4>StandardReport.error_args</h4>
758 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>)
759
760 <p>
761 Report an error, according to options.
762 </p>
763 <a NAME="StandardReport.get_file_results" ID="StandardReport.get_file_results"></a>
764 <h4>StandardReport.get_file_results</h4>
765 <b>get_file_results</b>(<i></i>)
766
767 <p>
768 Print results and return the overall count for this file.
769 </p>
770 <a NAME="StandardReport.init_file" ID="StandardReport.init_file"></a>
771 <h4>StandardReport.init_file</h4>
772 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
773
774 <p>
775 Signal a new file.
776 </p>
777 <div align="right"><a href="#top">Up</a></div>
778 <hr />
779 <hr />
780 <a NAME="StyleGuide" ID="StyleGuide"></a>
781 <h2>StyleGuide</h2>
782
783 <p>
784 Initialize a PEP-8 instance with few options.
785 </p>
786 <h3>Derived from</h3>
787 object
788 <h3>Class Attributes</h3>
789
790 <table>
791 <tr><td>None</td></tr>
792 </table>
793 <h3>Class Methods</h3>
794
795 <table>
796 <tr><td>None</td></tr>
797 </table>
798 <h3>Methods</h3>
799
800 <table>
801
802 <tr>
803 <td><a href="#StyleGuide.__init__">StyleGuide</a></td>
804 <td></td>
805 </tr>
806 <tr>
807 <td><a href="#StyleGuide.check_files">check_files</a></td>
808 <td>Run all checks on the paths.</td>
809 </tr>
810 <tr>
811 <td><a href="#StyleGuide.excluded">excluded</a></td>
812 <td>Check if the file should be excluded.</td>
813 </tr>
814 <tr>
815 <td><a href="#StyleGuide.get_checks">get_checks</a></td>
816 <td>Get all the checks for this category.</td>
817 </tr>
818 <tr>
819 <td><a href="#StyleGuide.ignore_code">ignore_code</a></td>
820 <td>Check if the error code should be ignored.</td>
821 </tr>
822 <tr>
823 <td><a href="#StyleGuide.init_report">init_report</a></td>
824 <td>Initialize the report instance.</td>
825 </tr>
826 <tr>
827 <td><a href="#StyleGuide.input_dir">input_dir</a></td>
828 <td>Check all files in this directory and all subdirectories.</td>
829 </tr>
830 <tr>
831 <td><a href="#StyleGuide.input_file">input_file</a></td>
832 <td>Run all checks on a Python source file.</td>
833 </tr>
834 </table>
835 <h3>Static Methods</h3>
836
837 <table>
838 <tr><td>None</td></tr>
839 </table>
840
841 <a NAME="StyleGuide.__init__" ID="StyleGuide.__init__"></a>
842 <h4>StyleGuide (Constructor)</h4>
843 <b>StyleGuide</b>(<i>*args, **kwargs</i>)
844
845 <a NAME="StyleGuide.check_files" ID="StyleGuide.check_files"></a>
846 <h4>StyleGuide.check_files</h4>
847 <b>check_files</b>(<i>paths=None</i>)
848
849 <p>
850 Run all checks on the paths.
851 </p>
852 <a NAME="StyleGuide.excluded" ID="StyleGuide.excluded"></a>
853 <h4>StyleGuide.excluded</h4>
854 <b>excluded</b>(<i>filename, parent=None</i>)
855
856 <p>
857 Check if the file should be excluded.
858 </p>
859 <p>
860 Check if 'options.exclude' contains a pattern matching filename.
861 </p>
862 <a NAME="StyleGuide.get_checks" ID="StyleGuide.get_checks"></a>
863 <h4>StyleGuide.get_checks</h4>
864 <b>get_checks</b>(<i>argument_name</i>)
865
866 <p>
867 Get all the checks for this category.
868 </p>
869 <p>
870 Find all globally visible functions where the first argument
871 name starts with argument_name and which contain selected tests.
872 </p>
873 <a NAME="StyleGuide.ignore_code" ID="StyleGuide.ignore_code"></a>
874 <h4>StyleGuide.ignore_code</h4>
875 <b>ignore_code</b>(<i>code</i>)
876
877 <p>
878 Check if the error code should be ignored.
879 </p>
880 <p>
881 If 'options.select' contains a prefix of the error code,
882 return False. Else, if 'options.ignore' contains a prefix of
883 the error code, return True.
884 </p>
885 <a NAME="StyleGuide.init_report" ID="StyleGuide.init_report"></a>
886 <h4>StyleGuide.init_report</h4>
887 <b>init_report</b>(<i>reporter=None</i>)
888
889 <p>
890 Initialize the report instance.
891 </p>
892 <a NAME="StyleGuide.input_dir" ID="StyleGuide.input_dir"></a>
893 <h4>StyleGuide.input_dir</h4>
894 <b>input_dir</b>(<i>dirname</i>)
895
896 <p>
897 Check all files in this directory and all subdirectories.
898 </p>
899 <a NAME="StyleGuide.input_file" ID="StyleGuide.input_file"></a>
900 <h4>StyleGuide.input_file</h4>
901 <b>input_file</b>(<i>filename, lines=None, expected=None, line_offset=0</i>)
902
903 <p>
904 Run all checks on a Python source file.
905 </p>
906 <div align="right"><a href="#top">Up</a></div>
907 <hr />
908 <hr />
909 <a NAME="_add_check" ID="_add_check"></a>
910 <h2>_add_check</h2>
911 <b>_add_check</b>(<i>check, kind, codes, args</i>)
912
913 <div align="right"><a href="#top">Up</a></div>
914 <hr />
915 <hr />
916 <a NAME="_break_around_binary_operators" ID="_break_around_binary_operators"></a>
917 <h2>_break_around_binary_operators</h2>
918 <b>_break_around_binary_operators</b>(<i>tokens</i>)
919
920 <p>
921 Private function to reduce duplication.
922 </p>
923 <p>
924 This factors out the shared details between
925 :func:`break_before_binary_operator` and
926 :func:`break_after_binary_operator`.
927 </p>
928 <div align="right"><a href="#top">Up</a></div>
929 <hr />
930 <hr />
931 <a NAME="_get_parameters" ID="_get_parameters"></a>
932 <h2>_get_parameters</h2>
933 <b>_get_parameters</b>(<i>function</i>)
934
935 <div align="right"><a href="#top">Up</a></div>
936 <hr />
937 <hr />
938 <a NAME="_is_binary_operator" ID="_is_binary_operator"></a>
939 <h2>_is_binary_operator</h2>
940 <b>_is_binary_operator</b>(<i>token_type, text</i>)
941
942 <div align="right"><a href="#top">Up</a></div>
943 <hr />
944 <hr />
945 <a NAME="_is_eol_token" ID="_is_eol_token"></a>
946 <h2>_is_eol_token</h2>
947 <b>_is_eol_token</b>(<i>token</i>)
948
949 <div align="right"><a href="#top">Up</a></div>
950 <hr />
951 <hr />
952 <a NAME="_is_one_liner" ID="_is_one_liner"></a>
953 <h2>_is_one_liner</h2>
954 <b>_is_one_liner</b>(<i>logical_line, indent_level, lines, line_number</i>)
955
956 <div align="right"><a href="#top">Up</a></div>
957 <hr />
958 <hr />
959 <a NAME="_main" ID="_main"></a>
960 <h2>_main</h2>
961 <b>_main</b>(<i></i>)
962
963 <p>
964 Parse options and run checks on Python source.
965 </p>
966 <div align="right"><a href="#top">Up</a></div>
967 <hr />
968 <hr />
969 <a NAME="_parse_multi_options" ID="_parse_multi_options"></a>
970 <h2>_parse_multi_options</h2>
971 <b>_parse_multi_options</b>(<i>options, split_token=', '</i>)
972
973 <p>
974 Split and strip and discard empties.
975 </p>
976 <p>
977 Turns the following:
978 </p>
979 <p>
980 A,
981 B,
982 </p>
983 <p>
984 into ["A", "B"]
985 </p>
986 <div align="right"><a href="#top">Up</a></div>
987 <hr />
988 <hr />
989 <a NAME="ambiguous_identifier" ID="ambiguous_identifier"></a>
990 <h2>ambiguous_identifier</h2>
991 <b>ambiguous_identifier</b>(<i>logical_line, tokens</i>)
992
993 <p>
994 Never use the characters 'l', 'O', or 'I' as variable names.
995 </p>
996 <p>
997 In some fonts, these characters are indistinguishable from the
998 numerals one and zero. When tempted to use 'l', use 'L' instead.
999 </p>
1000 <p>
1001 Okay: L = 0
1002 Okay: o = 123
1003 Okay: i = 42
1004 E741: l = 0
1005 E741: O = 123
1006 E741: I = 42
1007 </p>
1008 <p>
1009 Variables can be bound in several other contexts, including class
1010 and function definitions, 'global' and 'nonlocal' statements,
1011 exception handlers, and 'with' and 'for' statements.
1012 In addition, we have a special handling for function parameters.
1013 </p>
1014 <p>
1015 Okay: except AttributeError as o:
1016 Okay: with lock as L:
1017 Okay: foo(l=12)
1018 Okay: for a in foo(l=12):
1019 E741: except AttributeError as O:
1020 E741: with lock as l:
1021 E741: global I
1022 E741: nonlocal l
1023 E741: def foo(l):
1024 E741: def foo(l=12):
1025 E741: l = foo(l=12)
1026 E741: for l in range(10):
1027 E742: class I(object):
1028 E743: def l(x):
1029 </p>
1030 <div align="right"><a href="#top">Up</a></div>
1031 <hr />
1032 <hr />
1033 <a NAME="bare_except" ID="bare_except"></a>
1034 <h2>bare_except</h2>
1035 <b>bare_except</b>(<i>logical_line, noqa</i>)
1036
1037 <p>
1038 When catching exceptions, mention specific exceptions when
1039 possible.
1040 </p>
1041 <p>
1042 Okay: except Exception:
1043 Okay: except BaseException:
1044 E722: except:
1045 </p>
1046 <div align="right"><a href="#top">Up</a></div>
1047 <hr />
1048 <hr />
1049 <a NAME="blank_lines" ID="blank_lines"></a>
1050 <h2>blank_lines</h2>
1051 <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>)
1052
1053 <p>
1054 Separate top-level function and class definitions with two blank
1055 lines.
1056 </p>
1057 <p>
1058 Method definitions inside a class are separated by a single blank
1059 line.
1060 </p>
1061 <p>
1062 Extra blank lines may be used (sparingly) to separate groups of
1063 related functions. Blank lines may be omitted between a bunch of
1064 related one-liners (e.g. a set of dummy implementations).
1065 </p>
1066 <p>
1067 Use blank lines in functions, sparingly, to indicate logical
1068 sections.
1069 </p>
1070 <p>
1071 Okay: def a():\n pass\n\n\ndef b():\n pass
1072 Okay: def a():\n pass\n\n\nasync def b():\n pass
1073 Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass
1074 Okay: default = 1\nfoo = 1
1075 Okay: classify = 1\nfoo = 1
1076 </p>
1077 <p>
1078 E301: class Foo:\n b = 0\n def bar():\n pass
1079 E302: def a():\n pass\n\ndef b(n):\n pass
1080 E302: def a():\n pass\n\nasync def b(n):\n pass
1081 E303: def a():\n pass\n\n\n\ndef b(n):\n pass
1082 E303: def a():\n\n\n\n pass
1083 E304: @decorator\n\ndef a():\n pass
1084 E305: def a():\n pass\na()
1085 E306: def a():\n def b():\n pass\n def c():\n pass
1086 E307: def a():\n def b():\n pass\n\n\n def c():\n pass
1087 E308: def a():\n\n\n\n pass
1088 </p>
1089 <div align="right"><a href="#top">Up</a></div>
1090 <hr />
1091 <hr />
1092 <a NAME="break_after_binary_operator" ID="break_after_binary_operator"></a>
1093 <h2>break_after_binary_operator</h2>
1094 <b>break_after_binary_operator</b>(<i>logical_line, tokens</i>)
1095
1096 <p>
1097 Avoid breaks after binary operators.
1098 </p>
1099 <p>
1100 The preferred place to break around a binary operator is before the
1101 operator, not after it.
1102 </p>
1103 <p>
1104 W504: (width == 0 +\n height == 0)
1105 W504: (width == 0 and\n height == 0)
1106 W504: var = (1 &\n ~2)
1107 </p>
1108 <p>
1109 Okay: foo(\n -x)
1110 Okay: foo(x\n [])
1111 Okay: x = '''\n''' + ''
1112 Okay: x = '' + '''\n'''
1113 Okay: foo(x,\n -y)
1114 Okay: foo(x, # comment\n -y)
1115 </p>
1116 <p>
1117 The following should be W504 but unary_context is tricky with these
1118 Okay: var = (1 /\n -2)
1119 Okay: var = (1 +\n -1 +\n -2)
1120 </p>
1121 <div align="right"><a href="#top">Up</a></div>
1122 <hr />
1123 <hr />
1124 <a NAME="break_before_binary_operator" ID="break_before_binary_operator"></a>
1125 <h2>break_before_binary_operator</h2>
1126 <b>break_before_binary_operator</b>(<i>logical_line, tokens</i>)
1127
1128 <p>
1129 Avoid breaks before binary operators.
1130 </p>
1131 <p>
1132 The preferred place to break around a binary operator is after the
1133 operator, not before it.
1134 </p>
1135 <p>
1136 W503: (width == 0\n + height == 0)
1137 W503: (width == 0\n and height == 0)
1138 W503: var = (1\n & ~2)
1139 W503: var = (1\n / -2)
1140 W503: var = (1\n + -1\n + -2)
1141 </p>
1142 <p>
1143 Okay: foo(\n -x)
1144 Okay: foo(x\n [])
1145 Okay: x = '''\n''' + ''
1146 Okay: foo(x,\n -y)
1147 Okay: foo(x, # comment\n -y)
1148 </p>
1149 <div align="right"><a href="#top">Up</a></div>
1150 <hr />
1151 <hr />
1152 <a NAME="comparison_negative" ID="comparison_negative"></a>
1153 <h2>comparison_negative</h2>
1154 <b>comparison_negative</b>(<i>logical_line</i>)
1155
1156 <p>
1157 Negative comparison should be done using "not in" and "is not".
1158 </p>
1159 <p>
1160 Okay: if x not in y:\n pass
1161 Okay: assert (X in Y or X is Z)
1162 Okay: if not (X in Y):\n pass
1163 Okay: zz = x is not y
1164 E713: Z = not X in Y
1165 E713: if not X.B in Y:\n pass
1166 E714: if not X is Y:\n pass
1167 E714: Z = not X.B is Y
1168 </p>
1169 <div align="right"><a href="#top">Up</a></div>
1170 <hr />
1171 <hr />
1172 <a NAME="comparison_to_singleton" ID="comparison_to_singleton"></a>
1173 <h2>comparison_to_singleton</h2>
1174 <b>comparison_to_singleton</b>(<i>logical_line, noqa</i>)
1175
1176 <p>
1177 Comparison to singletons should use "is" or "is not".
1178 </p>
1179 <p>
1180 Comparisons to singletons like None should always be done
1181 with "is" or "is not", never the equality operators.
1182 </p>
1183 <p>
1184 Okay: if arg is not None:
1185 E711: if arg != None:
1186 E711: if None == arg:
1187 E712: if arg == True:
1188 E712: if False == arg:
1189 </p>
1190 <p>
1191 Also, beware of writing if x when you really mean if x is not None
1192 -- e.g. when testing whether a variable or argument that defaults to
1193 None was set to some other value. The other value might have a type
1194 (such as a container) that could be false in a boolean context!
1195 </p>
1196 <div align="right"><a href="#top">Up</a></div>
1197 <hr />
1198 <hr />
1199 <a NAME="comparison_type" ID="comparison_type"></a>
1200 <h2>comparison_type</h2>
1201 <b>comparison_type</b>(<i>logical_line, noqa</i>)
1202
1203 <p>
1204 Object type comparisons should always use isinstance().
1205 </p>
1206 <p>
1207 Do not compare types directly.
1208 </p>
1209 <p>
1210 Okay: if isinstance(obj, int):
1211 E721: if type(obj) is type(1):
1212 </p>
1213 <p>
1214 When checking if an object is a string, keep in mind that it might
1215 be a unicode string too! In Python 2.3, str and unicode have a
1216 common base class, basestring, so you can do:
1217 </p>
1218 <p>
1219 Okay: if isinstance(obj, basestring):
1220 Okay: if type(a1) is type(b1):
1221 </p>
1222 <div align="right"><a href="#top">Up</a></div>
1223 <hr />
1224 <hr />
1225 <a NAME="compound_statements" ID="compound_statements"></a>
1226 <h2>compound_statements</h2>
1227 <b>compound_statements</b>(<i>logical_line</i>)
1228
1229 <p>
1230 Compound statements (on the same line) are generally
1231 discouraged.
1232 </p>
1233 <p>
1234 While sometimes it's okay to put an if/for/while with a small body
1235 on the same line, never do this for multi-clause statements.
1236 Also avoid folding such long lines!
1237 </p>
1238 <p>
1239 Always use a def statement instead of an assignment statement that
1240 binds a lambda expression directly to a name.
1241 </p>
1242 <p>
1243 Okay: if foo == 'blah':\n do_blah_thing()
1244 Okay: do_one()
1245 Okay: do_two()
1246 Okay: do_three()
1247 </p>
1248 <p>
1249 E701: if foo == 'blah': do_blah_thing()
1250 E701: for x in lst: total += x
1251 E701: while t < 10: t = delay()
1252 E701: if foo == 'blah': do_blah_thing()
1253 E701: else: do_non_blah_thing()
1254 E701: try: something()
1255 E701: finally: cleanup()
1256 E701: if foo == 'blah': one(); two(); three()
1257 E702: do_one(); do_two(); do_three()
1258 E703: do_four(); # useless semicolon
1259 E704: def f(x): return 2*x
1260 E731: f = lambda x: 2*x
1261 </p>
1262 <div align="right"><a href="#top">Up</a></div>
1263 <hr />
1264 <hr />
1265 <a NAME="continued_indentation" ID="continued_indentation"></a>
1266 <h2>continued_indentation</h2>
1267 <b>continued_indentation</b>(<i>logical_line, tokens, indent_level, hang_closing, indent_char, indent_size, noqa, verbose</i>)
1268
1269 <p>
1270 Continuation lines indentation.
1271 </p>
1272 <p>
1273 Continuation lines should align wrapped elements either vertically
1274 using Python's implicit line joining inside parentheses, brackets
1275 and braces, or using a hanging indent.
1276 </p>
1277 <p>
1278 When using a hanging indent these considerations should be applied:
1279 - there should be no arguments on the first line, and
1280 - further indentation should be used to clearly distinguish itself
1281 as a continuation line.
1282 </p>
1283 <p>
1284 Okay: a = (\n)
1285 E123: a = (\n )
1286 </p>
1287 <p>
1288 Okay: a = (\n 42)
1289 E121: a = (\n 42)
1290 E122: a = (\n42)
1291 E123: a = (\n 42\n )
1292 E124: a = (24,\n 42\n)
1293 E125: if (\n b):\n pass
1294 E126: a = (\n 42)
1295 E127: a = (24,\n 42)
1296 E128: a = (24,\n 42)
1297 E129: if (a or\n b):\n pass
1298 E131: a = (\n 42\n 24)
1299 </p>
1300 <div align="right"><a href="#top">Up</a></div>
1301 <hr />
1302 <hr />
1303 <a NAME="expand_indent" ID="expand_indent"></a>
1304 <h2>expand_indent</h2>
1305 <b>expand_indent</b>(<i>line</i>)
1306
1307 <p>
1308 Return the amount of indentation.
1309 </p>
1310 <p>
1311 Tabs are expanded to the next multiple of 8.
1312 </p>
1313 <p>
1314 >>> expand_indent(' ')
1315 4
1316 >>> expand_indent('\t')
1317 8
1318 >>> expand_indent(' \t')
1319 8
1320 >>> expand_indent(' \t')
1321 16
1322 </p>
1323 <div align="right"><a href="#top">Up</a></div>
1324 <hr />
1325 <hr />
1326 <a NAME="explicit_line_join" ID="explicit_line_join"></a>
1327 <h2>explicit_line_join</h2>
1328 <b>explicit_line_join</b>(<i>logical_line, tokens</i>)
1329
1330 <p>
1331 Avoid explicit line join between brackets.
1332 </p>
1333 <p>
1334 The preferred way of wrapping long lines is by using Python's
1335 implied line continuation inside parentheses, brackets and braces.
1336 Long lines can be broken over multiple lines by wrapping expressions
1337 in parentheses. These should be used in preference to using a
1338 backslash for line continuation.
1339 </p>
1340 <p>
1341 E502: aaa = [123, \\n 123]
1342 E502: aaa = ("bbb " \\n "ccc")
1343 </p>
1344 <p>
1345 Okay: aaa = [123,\n 123]
1346 Okay: aaa = ("bbb "\n "ccc")
1347 Okay: aaa = "bbb " \\n "ccc"
1348 Okay: aaa = 123 # \\
1349 </p>
1350 <div align="right"><a href="#top">Up</a></div>
1351 <hr />
1352 <hr />
1353 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
1354 <h2>extraneous_whitespace</h2>
1355 <b>extraneous_whitespace</b>(<i>logical_line</i>)
1356
1357 <p>
1358 Avoid extraneous whitespace.
1359 </p>
1360 <p>
1361 Avoid extraneous whitespace in these situations:
1362 - Immediately inside parentheses, brackets or braces.
1363 - Immediately before a comma, semicolon, or colon.
1364 </p>
1365 <p>
1366 Okay: spam(ham[1], {eggs: 2})
1367 E201: spam( ham[1], {eggs: 2})
1368 E201: spam(ham[ 1], {eggs: 2})
1369 E201: spam(ham[1], { eggs: 2})
1370 E202: spam(ham[1], {eggs: 2} )
1371 E202: spam(ham[1 ], {eggs: 2})
1372 E202: spam(ham[1], {eggs: 2 })
1373 </p>
1374 <p>
1375 E203: if x == 4: print x, y; x, y = y , x
1376 E203: if x == 4: print x, y ; x, y = y, x
1377 E203: if x == 4 : print x, y; x, y = y, x
1378 </p>
1379 <div align="right"><a href="#top">Up</a></div>
1380 <hr />
1381 <hr />
1382 <a NAME="filename_match" ID="filename_match"></a>
1383 <h2>filename_match</h2>
1384 <b>filename_match</b>(<i>filename, patterns, default=True</i>)
1385
1386 <p>
1387 Check if patterns contains a pattern that matches filename.
1388 </p>
1389 <p>
1390 If patterns is unspecified, this always returns True.
1391 </p>
1392 <div align="right"><a href="#top">Up</a></div>
1393 <hr />
1394 <hr />
1395 <a NAME="get_parser" ID="get_parser"></a>
1396 <h2>get_parser</h2>
1397 <b>get_parser</b>(<i>prog='pycodestyle', version=__version__</i>)
1398
1399 <p>
1400 Create the parser for the program.
1401 </p>
1402 <div align="right"><a href="#top">Up</a></div>
1403 <hr />
1404 <hr />
1405 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
1406 <h2>imports_on_separate_lines</h2>
1407 <b>imports_on_separate_lines</b>(<i>logical_line</i>)
1408
1409 <p>
1410 Place imports on separate lines.
1411 </p>
1412 <p>
1413 Okay: import os\nimport sys
1414 E401: import sys, os
1415 </p>
1416 <p>
1417 Okay: from subprocess import Popen, PIPE
1418 Okay: from myclas import MyClass
1419 Okay: from foo.bar.yourclass import YourClass
1420 Okay: import myclass
1421 Okay: import foo.bar.yourclass
1422 </p>
1423 <div align="right"><a href="#top">Up</a></div>
1424 <hr />
1425 <hr />
1426 <a NAME="indentation" ID="indentation"></a>
1427 <h2>indentation</h2>
1428 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level, indent_size</i>)
1429
1430 <p>
1431 Use indent_size (PEP8 says 4) spaces per indentation level.
1432 </p>
1433 <p>
1434 For really old code that you don't want to mess up, you can continue
1435 to use 8-space tabs.
1436 </p>
1437 <p>
1438 Okay: a = 1
1439 Okay: if a == 0:\n a = 1
1440 E111: a = 1
1441 E114: # a = 1
1442 </p>
1443 <p>
1444 Okay: for item in items:\n pass
1445 E112: for item in items:\npass
1446 E115: for item in items:\n# Hi\n pass
1447 </p>
1448 <p>
1449 Okay: a = 1\nb = 2
1450 E113: a = 1\n b = 2
1451 E116: a = 1\n # b = 2
1452 </p>
1453 <div align="right"><a href="#top">Up</a></div>
1454 <hr />
1455 <hr />
1456 <a NAME="is_string_literal" ID="is_string_literal"></a>
1457 <h2>is_string_literal</h2>
1458 <b>is_string_literal</b>(<i>line</i>)
1459
1460 <div align="right"><a href="#top">Up</a></div>
1461 <hr />
1462 <hr />
1463 <a NAME="lru_cache" ID="lru_cache"></a>
1464 <h2>lru_cache</h2>
1465 <b>lru_cache</b>(<i>maxsize=128</i>)
1466
1467 <div align="right"><a href="#top">Up</a></div>
1468 <hr />
1469 <hr />
1470 <a NAME="maximum_doc_length" ID="maximum_doc_length"></a>
1471 <h2>maximum_doc_length</h2>
1472 <b>maximum_doc_length</b>(<i>logical_line, max_doc_length, noqa, tokens</i>)
1473
1474 <p>
1475 Limit all doc lines to a maximum of 72 characters.
1476 </p>
1477 <p>
1478 For flowing long blocks of text (docstrings or comments), limiting
1479 the length to 72 characters is recommended.
1480 </p>
1481 <p>
1482 Reports warning W505
1483 </p>
1484 <div align="right"><a href="#top">Up</a></div>
1485 <hr />
1486 <hr />
1487 <a NAME="maximum_line_length" ID="maximum_line_length"></a>
1488 <h2>maximum_line_length</h2>
1489 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline, line_number, noqa</i>)
1490
1491 <p>
1492 Limit all lines to a maximum of 79 characters.
1493 </p>
1494 <p>
1495 There are still many devices around that are limited to 80 character
1496 lines; plus, limiting windows to 80 characters makes it possible to
1497 have several windows side-by-side. The default wrapping on such
1498 devices looks ugly. Therefore, please limit all lines to a maximum
1499 of 79 characters. For flowing long blocks of text (docstrings or
1500 comments), limiting the length to 72 characters is recommended.
1501 </p>
1502 <p>
1503 Reports error E501.
1504 </p>
1505 <div align="right"><a href="#top">Up</a></div>
1506 <hr />
1507 <hr />
1508 <a NAME="missing_whitespace" ID="missing_whitespace"></a>
1509 <h2>missing_whitespace</h2>
1510 <b>missing_whitespace</b>(<i>logical_line</i>)
1511
1512 <p>
1513 Each comma, semicolon or colon should be followed by whitespace.
1514 </p>
1515 <p>
1516 Okay: [a, b]
1517 Okay: (3,)
1518 Okay: a[1:4]
1519 Okay: a[:4]
1520 Okay: a[1:]
1521 Okay: a[1:4:2]
1522 E231: ['a','b']
1523 E231: foo(bar,baz)
1524 E231: [{'a':'b'}]
1525 </p>
1526 <div align="right"><a href="#top">Up</a></div>
1527 <hr />
1528 <hr />
1529 <a NAME="missing_whitespace_after_import_keyword" ID="missing_whitespace_after_import_keyword"></a>
1530 <h2>missing_whitespace_after_import_keyword</h2>
1531 <b>missing_whitespace_after_import_keyword</b>(<i>logical_line</i>)
1532
1533 <p>
1534 Multiple imports in form from x import (a, b, c) should have
1535 space between import statement and parenthesised name list.
1536 </p>
1537 <p>
1538 Okay: from foo import (bar, baz)
1539 E275: from foo import(bar, baz)
1540 E275: from importable.module import(bar, baz)
1541 </p>
1542 <div align="right"><a href="#top">Up</a></div>
1543 <hr />
1544 <hr />
1545 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
1546 <h2>missing_whitespace_around_operator</h2>
1547 <b>missing_whitespace_around_operator</b>(<i>logical_line, tokens</i>)
1548
1549 <p>
1550 Surround operators with a single space on either side.
1551 </p>
1552 <p>
1553 - Always surround these binary operators with a single space on
1554 either side: assignment (=), augmented assignment (+=, -= etc.),
1555 comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
1556 Booleans (and, or, not).
1557 </p>
1558 <p>
1559 - If operators with different priorities are used, consider adding
1560 whitespace around the operators with the lowest priorities.
1561 </p>
1562 <p>
1563 Okay: i = i + 1
1564 Okay: submitted += 1
1565 Okay: x = x * 2 - 1
1566 Okay: hypot2 = x * x + y * y
1567 Okay: c = (a + b) * (a - b)
1568 Okay: foo(bar, key='word', *args, **kwargs)
1569 Okay: alpha[:-i]
1570 </p>
1571 <p>
1572 E225: i=i+1
1573 E225: submitted +=1
1574 E225: x = x /2 - 1
1575 E225: z = x **y
1576 E225: z = 1and 1
1577 E226: c = (a+b) * (a-b)
1578 E226: hypot2 = x*x + y*y
1579 E227: c = a|b
1580 E228: msg = fmt%(errno, errmsg)
1581 </p>
1582 <div align="right"><a href="#top">Up</a></div>
1583 <hr />
1584 <hr />
1585 <a NAME="module_imports_on_top_of_file" ID="module_imports_on_top_of_file"></a>
1586 <h2>module_imports_on_top_of_file</h2>
1587 <b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>)
1588
1589 <p>
1590 Place imports at the top of the file.
1591 </p>
1592 <p>
1593 Always put imports at the top of the file, just after any module
1594 comments and docstrings, and before module globals and constants.
1595 </p>
1596 <p>
1597 Okay: import os
1598 Okay: # this is a comment\nimport os
1599 Okay: '''this is a module docstring'''\nimport os
1600 Okay: r'''this is a module docstring'''\nimport os
1601 Okay:
1602 try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
1603 Okay:
1604 try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
1605 E402: a=1\nimport os
1606 E402: 'One string'\n"Two string"\nimport os
1607 E402: a=1\nfrom sys import x
1608 </p>
1609 <p>
1610 Okay: if x:\n import os
1611 </p>
1612 <div align="right"><a href="#top">Up</a></div>
1613 <hr />
1614 <hr />
1615 <a NAME="mute_string" ID="mute_string"></a>
1616 <h2>mute_string</h2>
1617 <b>mute_string</b>(<i>text</i>)
1618
1619 <p>
1620 Replace contents with 'xxx' to prevent syntax matching.
1621 </p>
1622 <p>
1623 >>> mute_string('"abc"')
1624 '"xxx"'
1625 >>> mute_string("'''abc'''")
1626 "'''xxx'''"
1627 >>> mute_string("r'abc'")
1628 "r'xxx'"
1629 </p>
1630 <div align="right"><a href="#top">Up</a></div>
1631 <hr />
1632 <hr />
1633 <a NAME="normalize_paths" ID="normalize_paths"></a>
1634 <h2>normalize_paths</h2>
1635 <b>normalize_paths</b>(<i>value, parent=os.curdir</i>)
1636
1637 <p>
1638 Parse a comma-separated list of paths.
1639 </p>
1640 <p>
1641 Return a list of absolute paths.
1642 </p>
1643 <div align="right"><a href="#top">Up</a></div>
1644 <hr />
1645 <hr />
1646 <a NAME="parse_udiff" ID="parse_udiff"></a>
1647 <h2>parse_udiff</h2>
1648 <b>parse_udiff</b>(<i>diff, patterns=None, parent='.'</i>)
1649
1650 <p>
1651 Return a dictionary of matching lines.
1652 </p>
1653 <div align="right"><a href="#top">Up</a></div>
1654 <hr />
1655 <hr />
1656 <a NAME="process_options" ID="process_options"></a>
1657 <h2>process_options</h2>
1658 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None</i>)
1659
1660 <p>
1661 Process options passed either via arglist or command line args.
1662 </p>
1663 <p>
1664 Passing in the ``config_file`` parameter allows other tools, such as
1665 flake8 to specify their own options to be processed in pycodestyle.
1666 </p>
1667 <div align="right"><a href="#top">Up</a></div>
1668 <hr />
1669 <hr />
1670 <a NAME="python_3000_async_await_keywords" ID="python_3000_async_await_keywords"></a>
1671 <h2>python_3000_async_await_keywords</h2>
1672 <b>python_3000_async_await_keywords</b>(<i>logical_line, tokens</i>)
1673
1674 <p>
1675 'async' and 'await' are reserved keywords starting at Python 3.7.
1676 </p>
1677 <p>
1678 W606: async = 42
1679 W606: await = 42
1680 Okay: async def read(db):\n data = await db.fetch('SELECT ...')
1681 </p>
1682 <div align="right"><a href="#top">Up</a></div>
1683 <hr />
1684 <hr />
1685 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a>
1686 <h2>python_3000_backticks</h2>
1687 <b>python_3000_backticks</b>(<i>logical_line</i>)
1688
1689 <p>
1690 Use repr() instead of backticks in Python 3.
1691 </p>
1692 <p>
1693 Okay: val = repr(1 + 2)
1694 W604: val = `1 + 2`
1695 </p>
1696 <div align="right"><a href="#top">Up</a></div>
1697 <hr />
1698 <hr />
1699 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
1700 <h2>python_3000_has_key</h2>
1701 <b>python_3000_has_key</b>(<i>logical_line, noqa</i>)
1702
1703 <p>
1704 The {}.has_key() method is removed in Python 3: use the 'in'
1705 operator.
1706 </p>
1707 <p>
1708 Okay: if "alph" in d:\n print d["alph"]
1709 W601: assert d.has_key('alph')
1710 </p>
1711 <div align="right"><a href="#top">Up</a></div>
1712 <hr />
1713 <hr />
1714 <a NAME="python_3000_invalid_escape_sequence" ID="python_3000_invalid_escape_sequence"></a>
1715 <h2>python_3000_invalid_escape_sequence</h2>
1716 <b>python_3000_invalid_escape_sequence</b>(<i>logical_line, tokens, noqa</i>)
1717
1718 <p>
1719 Invalid escape sequences are deprecated in Python 3.6.
1720 </p>
1721 <p>
1722 Okay: regex = r'\.png$'
1723 W605: regex = '\.png$'
1724 </p>
1725 <div align="right"><a href="#top">Up</a></div>
1726 <hr />
1727 <hr />
1728 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
1729 <h2>python_3000_not_equal</h2>
1730 <b>python_3000_not_equal</b>(<i>logical_line</i>)
1731
1732 <p>
1733 New code should always use != instead of <>.
1734 </p>
1735 <p>
1736 The older syntax is removed in Python 3.
1737 </p>
1738 <p>
1739 Okay: if a != 'no':
1740 W603: if a <> 'no':
1741 </p>
1742 <div align="right"><a href="#top">Up</a></div>
1743 <hr />
1744 <hr />
1745 <a NAME="python_3000_raise_comma" ID="python_3000_raise_comma"></a>
1746 <h2>python_3000_raise_comma</h2>
1747 <b>python_3000_raise_comma</b>(<i>logical_line</i>)
1748
1749 <p>
1750 When raising an exception, use "raise ValueError('message')".
1751 </p>
1752 <p>
1753 The older form is removed in Python 3.
1754 </p>
1755 <p>
1756 Okay: raise DummyError("Message")
1757 W602: raise DummyError, "Message"
1758 </p>
1759 <div align="right"><a href="#top">Up</a></div>
1760 <hr />
1761 <hr />
1762 <a NAME="read_config" ID="read_config"></a>
1763 <h2>read_config</h2>
1764 <b>read_config</b>(<i>options, args, arglist, parser</i>)
1765
1766 <p>
1767 Read and parse configurations.
1768 </p>
1769 <p>
1770 If a config file is specified on the command line with the
1771 "--config" option, then only it is used for configuration.
1772 </p>
1773 <p>
1774 Otherwise, the user configuration (~/.config/pycodestyle) and any
1775 local configurations in the current directory or above will be
1776 merged together (in that order) using the read method of
1777 ConfigParser.
1778 </p>
1779 <div align="right"><a href="#top">Up</a></div>
1780 <hr />
1781 <hr />
1782 <a NAME="readlines" ID="readlines"></a>
1783 <h2>readlines</h2>
1784 <b>readlines</b>(<i>filename</i>)
1785
1786 <p>
1787 Read the source code.
1788 </p>
1789 <div align="right"><a href="#top">Up</a></div>
1790 <hr />
1791 <hr />
1792 <a NAME="readlines_1" ID="readlines_1"></a>
1793 <h2>readlines</h2>
1794 <b>readlines</b>(<i>filename</i>)
1795
1796 <p>
1797 Read the source code.
1798 </p>
1799 <div align="right"><a href="#top">Up</a></div>
1800 <hr />
1801 <hr />
1802 <a NAME="register_check" ID="register_check"></a>
1803 <h2>register_check</h2>
1804 <b>register_check</b>(<i>check, codes=None</i>)
1805
1806 <p>
1807 Register a new check object.
1808 </p>
1809 <div align="right"><a href="#top">Up</a></div>
1810 <hr />
1811 <hr />
1812 <a NAME="stdin_get_value" ID="stdin_get_value"></a>
1813 <h2>stdin_get_value</h2>
1814 <b>stdin_get_value</b>(<i></i>)
1815
1816 <p>
1817 Read the value from stdin.
1818 </p>
1819 <div align="right"><a href="#top">Up</a></div>
1820 <hr />
1821 <hr />
1822 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
1823 <h2>tabs_obsolete</h2>
1824 <b>tabs_obsolete</b>(<i>physical_line</i>)
1825
1826 <p>
1827 On new projects, spaces-only are strongly recommended over tabs.
1828 </p>
1829 <p>
1830 Okay: if True:\n return
1831 W191: if True:\n\treturn
1832 </p>
1833 <div align="right"><a href="#top">Up</a></div>
1834 <hr />
1835 <hr />
1836 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a>
1837 <h2>tabs_or_spaces</h2>
1838 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
1839
1840 <p>
1841 Never mix tabs and spaces.
1842 </p>
1843 <p>
1844 The most popular way of indenting Python is with spaces only. The
1845 second-most popular way is with tabs only. Code indented with a
1846 mixture of tabs and spaces should be converted to using spaces
1847 exclusively. When invoking the Python command line interpreter with
1848 the -t option, it issues warnings about code that illegally mixes
1849 tabs and spaces. When using -tt these warnings become errors.
1850 These options are highly recommended!
1851 </p>
1852 <p>
1853 Okay: if a == 0:\n a = 1\n b = 1
1854 E101: if a == 0:\n a = 1\n\tb = 1
1855 </p>
1856 <div align="right"><a href="#top">Up</a></div>
1857 <hr />
1858 <hr />
1859 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
1860 <h2>trailing_blank_lines</h2>
1861 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number, total_lines</i>)
1862
1863 <p>
1864 Trailing blank lines are superfluous.
1865 </p>
1866 <p>
1867 Okay: spam(1)
1868 W391: spam(1)\n
1869 </p>
1870 <p>
1871 However the last line should end with a new line (warning W292).
1872 </p>
1873 <div align="right"><a href="#top">Up</a></div>
1874 <hr />
1875 <hr />
1876 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a>
1877 <h2>trailing_whitespace</h2>
1878 <b>trailing_whitespace</b>(<i>physical_line</i>)
1879
1880 <p>
1881 Trailing whitespace is superfluous.
1882 </p>
1883 <p>
1884 The warning returned varies on whether the line itself is blank,
1885 for easier filtering for those who want to indent their blank lines.
1886 </p>
1887 <p>
1888 Okay: spam(1)\n#
1889 W291: spam(1) \n#
1890 W293: class Foo(object):\n \n bang = 12
1891 </p>
1892 <div align="right"><a href="#top">Up</a></div>
1893 <hr />
1894 <hr />
1895 <a NAME="update_counts" ID="update_counts"></a>
1896 <h2>update_counts</h2>
1897 <b>update_counts</b>(<i>s, counts</i>)
1898
1899 <p>
1900 Adds one to the counts of each appearance of characters in s,
1901 for characters in counts
1902 </p>
1903 <div align="right"><a href="#top">Up</a></div>
1904 <hr />
1905 <hr />
1906 <a NAME="whitespace_around_comma" ID="whitespace_around_comma"></a>
1907 <h2>whitespace_around_comma</h2>
1908 <b>whitespace_around_comma</b>(<i>logical_line</i>)
1909
1910 <p>
1911 Avoid extraneous whitespace after a comma or a colon.
1912 </p>
1913 <p>
1914 Note: these checks are disabled by default
1915 </p>
1916 <p>
1917 Okay: a = (1, 2)
1918 E241: a = (1, 2)
1919 E242: a = (1,\t2)
1920 </p>
1921 <div align="right"><a href="#top">Up</a></div>
1922 <hr />
1923 <hr />
1924 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a>
1925 <h2>whitespace_around_keywords</h2>
1926 <b>whitespace_around_keywords</b>(<i>logical_line</i>)
1927
1928 <p>
1929 Avoid extraneous whitespace around keywords.
1930 </p>
1931 <p>
1932 Okay: True and False
1933 E271: True and False
1934 E272: True and False
1935 E273: True and\tFalse
1936 E274: True\tand False
1937 </p>
1938 <div align="right"><a href="#top">Up</a></div>
1939 <hr />
1940 <hr />
1941 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
1942 <h2>whitespace_around_named_parameter_equals</h2>
1943 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>)
1944
1945 <p>
1946 Don't use spaces around the '=' sign in function arguments.
1947 </p>
1948 <p>
1949 Don't use spaces around the '=' sign when used to indicate a
1950 keyword argument or a default parameter value, except when
1951 using a type annotation.
1952 </p>
1953 <p>
1954 Okay: def complex(real, imag=0.0):
1955 Okay: return magic(r=real, i=imag)
1956 Okay: boolean(a == b)
1957 Okay: boolean(a != b)
1958 Okay: boolean(a <= b)
1959 Okay: boolean(a >= b)
1960 Okay: def foo(arg: int = 42):
1961 Okay: async def foo(arg: int = 42):
1962 </p>
1963 <p>
1964 E251: def complex(real, imag = 0.0):
1965 E251: return magic(r = real, i = imag)
1966 E252: def complex(real, image: float=0.0):
1967 </p>
1968 <div align="right"><a href="#top">Up</a></div>
1969 <hr />
1970 <hr />
1971 <a NAME="whitespace_around_operator" ID="whitespace_around_operator"></a>
1972 <h2>whitespace_around_operator</h2>
1973 <b>whitespace_around_operator</b>(<i>logical_line</i>)
1974
1975 <p>
1976 Avoid extraneous whitespace around an operator.
1977 </p>
1978 <p>
1979 Okay: a = 12 + 3
1980 E221: a = 4 + 5
1981 E222: a = 4 + 5
1982 E223: a = 4\t+ 5
1983 E224: a = 4 +\t5
1984 </p>
1985 <div align="right"><a href="#top">Up</a></div>
1986 <hr />
1987 <hr />
1988 <a NAME="whitespace_before_comment" ID="whitespace_before_comment"></a>
1989 <h2>whitespace_before_comment</h2>
1990 <b>whitespace_before_comment</b>(<i>logical_line, tokens</i>)
1991
1992 <p>
1993 Separate inline comments by at least two spaces.
1994 </p>
1995 <p>
1996 An inline comment is a comment on the same line as a statement.
1997 Inline comments should be separated by at least two spaces from the
1998 statement. They should start with a # and a single space.
1999 </p>
2000 <p>
2001 Each line of a block comment starts with a # and a single space
2002 (unless it is indented text inside the comment).
2003 </p>
2004 <p>
2005 Okay: x = x + 1 # Increment x
2006 Okay: x = x + 1 # Increment x
2007 Okay: # Block comment
2008 E261: x = x + 1 # Increment x
2009 E262: x = x + 1 #Increment x
2010 E262: x = x + 1 # Increment x
2011 E265: #Block comment
2012 E266: ### Block comment
2013 </p>
2014 <div align="right"><a href="#top">Up</a></div>
2015 <hr />
2016 <hr />
2017 <a NAME="whitespace_before_parameters" ID="whitespace_before_parameters"></a>
2018 <h2>whitespace_before_parameters</h2>
2019 <b>whitespace_before_parameters</b>(<i>logical_line, tokens</i>)
2020
2021 <p>
2022 Avoid extraneous whitespace.
2023 </p>
2024 <p>
2025 Avoid extraneous whitespace in the following situations:
2026 - before the open parenthesis that starts the argument list of a
2027 function call.
2028 - before the open parenthesis that starts an indexing or slicing.
2029 </p>
2030 <p>
2031 Okay: spam(1)
2032 E211: spam (1)
2033 </p>
2034 <p>
2035 Okay: dict['key'] = list[index]
2036 E211: dict ['key'] = list[index]
2037 E211: dict['key'] = list [index]
2038 </p>
2039 <div align="right"><a href="#top">Up</a></div>
2040 <hr />
2041 </body></html>

eric ide

mercurial