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

changeset 3673
e26d7d0c1088
child 4837
57d8b7abde6c
equal deleted inserted replaced
3670:f0cb7579c0b4 3673:e26d7d0c1088
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.pep8</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body><a NAME="top" ID="top"></a>
22 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.pep8</h1>
23
24 <h3>Global Attributes</h3>
25 <table>
26 <tr><td>ARITHMETIC_OP</td></tr><tr><td>BENCHMARK_KEYS</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>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>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>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>
28 <h3>Classes</h3>
29 <table>
30 <tr>
31 <td><a href="#BaseReport">BaseReport</a></td>
32 <td>Collect the results of the checks.</td>
33 </tr><tr>
34 <td><a href="#Checker">Checker</a></td>
35 <td>Load a Python source file, tokenize it, check coding style.</td>
36 </tr><tr>
37 <td><a href="#DiffReport">DiffReport</a></td>
38 <td>Collect and print the results for the changed lines only.</td>
39 </tr><tr>
40 <td><a href="#FileReport">FileReport</a></td>
41 <td>Collect the results of the checks and print only the filenames.</td>
42 </tr><tr>
43 <td><a href="#StandardReport">StandardReport</a></td>
44 <td>Collect and print the results of the checks.</td>
45 </tr><tr>
46 <td><a href="#StyleGuide">StyleGuide</a></td>
47 <td>Initialize a PEP-8 instance with few options.</td>
48 </tr>
49 </table>
50 <h3>Functions</h3>
51 <table>
52 <tr>
53 <td><a href="#_add_check">_add_check</a></td>
54 <td></td>
55 </tr><tr>
56 <td><a href="#_is_eol_token">_is_eol_token</a></td>
57 <td></td>
58 </tr><tr>
59 <td><a href="#_is_eol_token_1">_is_eol_token</a></td>
60 <td></td>
61 </tr><tr>
62 <td><a href="#_main">_main</a></td>
63 <td>Parse options and run checks on Python source.</td>
64 </tr><tr>
65 <td><a href="#blank_lines">blank_lines</a></td>
66 <td>Separate top-level function and class definitions with two blank lines.</td>
67 </tr><tr>
68 <td><a href="#comparison_negative">comparison_negative</a></td>
69 <td>Negative comparison should be done using "not in" and "is not".</td>
70 </tr><tr>
71 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
72 <td>Comparison to singletons should use "is" or "is not".</td>
73 </tr><tr>
74 <td><a href="#comparison_type">comparison_type</a></td>
75 <td>Object type comparisons should always use isinstance().</td>
76 </tr><tr>
77 <td><a href="#compound_statements">compound_statements</a></td>
78 <td>Compound statements (on the same line) are generally discouraged.</td>
79 </tr><tr>
80 <td><a href="#continued_indentation">continued_indentation</a></td>
81 <td>Continuation lines indentation.</td>
82 </tr><tr>
83 <td><a href="#expand_indent">expand_indent</a></td>
84 <td>Return the amount of indentation.</td>
85 </tr><tr>
86 <td><a href="#explicit_line_join">explicit_line_join</a></td>
87 <td>Avoid explicit line join between brackets.</td>
88 </tr><tr>
89 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
90 <td>Avoid extraneous whitespace.</td>
91 </tr><tr>
92 <td><a href="#filename_match">filename_match</a></td>
93 <td>Check if patterns contains a pattern that matches filename.</td>
94 </tr><tr>
95 <td><a href="#get_parser">get_parser</a></td>
96 <td></td>
97 </tr><tr>
98 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
99 <td>Imports should usually be on separate lines.</td>
100 </tr><tr>
101 <td><a href="#indentation">indentation</a></td>
102 <td>Use 4 spaces per indentation level.</td>
103 </tr><tr>
104 <td><a href="#init_checks_registry">init_checks_registry</a></td>
105 <td>Register all globally visible functions.</td>
106 </tr><tr>
107 <td><a href="#maximum_line_length">maximum_line_length</a></td>
108 <td>Limit all lines to a maximum of 79 characters.</td>
109 </tr><tr>
110 <td><a href="#missing_whitespace">missing_whitespace</a></td>
111 <td>Each comma, semicolon or colon should be followed by whitespace.</td>
112 </tr><tr>
113 <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td>
114 <td>Surround operators with a single space on either side.</td>
115 </tr><tr>
116 <td><a href="#mute_string">mute_string</a></td>
117 <td>Replace contents with 'xxx' to prevent syntax matching.</td>
118 </tr><tr>
119 <td><a href="#normalize_paths">normalize_paths</a></td>
120 <td>Parse a comma-separated list of paths.</td>
121 </tr><tr>
122 <td><a href="#parse_udiff">parse_udiff</a></td>
123 <td>Return a dictionary of matching lines.</td>
124 </tr><tr>
125 <td><a href="#process_options">process_options</a></td>
126 <td>Process options passed either via arglist or via command line args.</td>
127 </tr><tr>
128 <td><a href="#python_3000_backticks">python_3000_backticks</a></td>
129 <td>Backticks are removed in Python 3: use repr() instead.</td>
130 </tr><tr>
131 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
132 <td>The {}.has_key() method is removed in Python 3: use the 'in' operator.</td>
133 </tr><tr>
134 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
135 <td>New code should always use != instead of <>.</td>
136 </tr><tr>
137 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td>
138 <td>When raising an exception, use "raise ValueError('message')".</td>
139 </tr><tr>
140 <td><a href="#read_config">read_config</a></td>
141 <td>Read both user configuration and local configuration.</td>
142 </tr><tr>
143 <td><a href="#readlines">readlines</a></td>
144 <td>Read the source code.</td>
145 </tr><tr>
146 <td><a href="#readlines_1">readlines</a></td>
147 <td>Read the source code.</td>
148 </tr><tr>
149 <td><a href="#register_check">register_check</a></td>
150 <td>Register a new check object.</td>
151 </tr><tr>
152 <td><a href="#stdin_get_value">stdin_get_value</a></td>
153 <td></td>
154 </tr><tr>
155 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
156 <td>For new projects, spaces-only are strongly recommended over tabs.</td>
157 </tr><tr>
158 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
159 <td>Never mix tabs and spaces.</td>
160 </tr><tr>
161 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
162 <td>Trailing blank lines are superfluous.</td>
163 </tr><tr>
164 <td><a href="#trailing_whitespace">trailing_whitespace</a></td>
165 <td>Trailing whitespace is superfluous.</td>
166 </tr><tr>
167 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
168 <td>Avoid extraneous whitespace after a comma or a colon.</td>
169 </tr><tr>
170 <td><a href="#whitespace_around_keywords">whitespace_around_keywords</a></td>
171 <td>Avoid extraneous whitespace around keywords.</td>
172 </tr><tr>
173 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
174 <td>Don't use spaces around the '=' sign in function arguments.</td>
175 </tr><tr>
176 <td><a href="#whitespace_around_operator">whitespace_around_operator</a></td>
177 <td>Avoid extraneous whitespace around an operator.</td>
178 </tr><tr>
179 <td><a href="#whitespace_before_comment">whitespace_before_comment</a></td>
180 <td>Separate inline comments by at least two spaces.</td>
181 </tr><tr>
182 <td><a href="#whitespace_before_parameters">whitespace_before_parameters</a></td>
183 <td>Avoid extraneous whitespace.</td>
184 </tr>
185 </table>
186 <hr /><hr />
187 <a NAME="BaseReport" ID="BaseReport"></a>
188 <h2>BaseReport</h2>
189 <p>
190 Collect the results of the checks.
191 </p>
192 <h3>Derived from</h3>
193 object
194 <h3>Class Attributes</h3>
195 <table>
196 <tr><td>print_filename</td></tr>
197 </table>
198 <h3>Class Methods</h3>
199 <table>
200 <tr><td>None</td></tr>
201 </table>
202 <h3>Methods</h3>
203 <table>
204 <tr>
205 <td><a href="#BaseReport.__init__">BaseReport</a></td>
206 <td></td>
207 </tr><tr>
208 <td><a href="#BaseReport.error">error</a></td>
209 <td>Report an error, according to options.</td>
210 </tr><tr>
211 <td><a href="#BaseReport.error_args">error_args</a></td>
212 <td>Report an error, according to options.</td>
213 </tr><tr>
214 <td><a href="#BaseReport.get_count">get_count</a></td>
215 <td>Return the total count of errors and warnings.</td>
216 </tr><tr>
217 <td><a href="#BaseReport.get_file_results">get_file_results</a></td>
218 <td>Return the count of errors and warnings for this file.</td>
219 </tr><tr>
220 <td><a href="#BaseReport.get_statistics">get_statistics</a></td>
221 <td>Get statistics for message codes that start with the prefix.</td>
222 </tr><tr>
223 <td><a href="#BaseReport.increment_logical_line">increment_logical_line</a></td>
224 <td>Signal a new logical line.</td>
225 </tr><tr>
226 <td><a href="#BaseReport.init_file">init_file</a></td>
227 <td>Signal a new file.</td>
228 </tr><tr>
229 <td><a href="#BaseReport.print_benchmark">print_benchmark</a></td>
230 <td>Print benchmark numbers.</td>
231 </tr><tr>
232 <td><a href="#BaseReport.print_statistics">print_statistics</a></td>
233 <td>Print overall statistics (number of errors and warnings).</td>
234 </tr><tr>
235 <td><a href="#BaseReport.start">start</a></td>
236 <td>Start the timer.</td>
237 </tr><tr>
238 <td><a href="#BaseReport.stop">stop</a></td>
239 <td>Stop the timer.</td>
240 </tr>
241 </table>
242 <h3>Static Methods</h3>
243 <table>
244 <tr><td>None</td></tr>
245 </table>
246 <a NAME="BaseReport.__init__" ID="BaseReport.__init__"></a>
247 <h4>BaseReport (Constructor)</h4>
248 <b>BaseReport</b>(<i>options</i>)
249 <a NAME="BaseReport.error" ID="BaseReport.error"></a>
250 <h4>BaseReport.error</h4>
251 <b>error</b>(<i>line_number, offset, text, check</i>)
252 <p>
253 Report an error, according to options.
254 </p><a NAME="BaseReport.error_args" ID="BaseReport.error_args"></a>
255 <h4>BaseReport.error_args</h4>
256 <b>error_args</b>(<i>line_number, offset, text, check, *args</i>)
257 <p>
258 Report an error, according to options.
259 </p><a NAME="BaseReport.get_count" ID="BaseReport.get_count"></a>
260 <h4>BaseReport.get_count</h4>
261 <b>get_count</b>(<i>prefix=''</i>)
262 <p>
263 Return the total count of errors and warnings.
264 </p><a NAME="BaseReport.get_file_results" ID="BaseReport.get_file_results"></a>
265 <h4>BaseReport.get_file_results</h4>
266 <b>get_file_results</b>(<i></i>)
267 <p>
268 Return the count of errors and warnings for this file.
269 </p><a NAME="BaseReport.get_statistics" ID="BaseReport.get_statistics"></a>
270 <h4>BaseReport.get_statistics</h4>
271 <b>get_statistics</b>(<i>prefix=''</i>)
272 <p>
273 Get statistics for message codes that start with the prefix.
274 </p><p>
275 prefix='' matches all errors and warnings
276 prefix='E' matches all errors
277 prefix='W' matches all warnings
278 prefix='E4' matches all errors that have to do with imports
279 </p><a NAME="BaseReport.increment_logical_line" ID="BaseReport.increment_logical_line"></a>
280 <h4>BaseReport.increment_logical_line</h4>
281 <b>increment_logical_line</b>(<i></i>)
282 <p>
283 Signal a new logical line.
284 </p><a NAME="BaseReport.init_file" ID="BaseReport.init_file"></a>
285 <h4>BaseReport.init_file</h4>
286 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
287 <p>
288 Signal a new file.
289 </p><a NAME="BaseReport.print_benchmark" ID="BaseReport.print_benchmark"></a>
290 <h4>BaseReport.print_benchmark</h4>
291 <b>print_benchmark</b>(<i></i>)
292 <p>
293 Print benchmark numbers.
294 </p><a NAME="BaseReport.print_statistics" ID="BaseReport.print_statistics"></a>
295 <h4>BaseReport.print_statistics</h4>
296 <b>print_statistics</b>(<i>prefix=''</i>)
297 <p>
298 Print overall statistics (number of errors and warnings).
299 </p><a NAME="BaseReport.start" ID="BaseReport.start"></a>
300 <h4>BaseReport.start</h4>
301 <b>start</b>(<i></i>)
302 <p>
303 Start the timer.
304 </p><a NAME="BaseReport.stop" ID="BaseReport.stop"></a>
305 <h4>BaseReport.stop</h4>
306 <b>stop</b>(<i></i>)
307 <p>
308 Stop the timer.
309 </p>
310 <div align="right"><a href="#top">Up</a></div>
311 <hr /><hr />
312 <a NAME="Checker" ID="Checker"></a>
313 <h2>Checker</h2>
314 <p>
315 Load a Python source file, tokenize it, check coding style.
316 </p>
317 <h3>Derived from</h3>
318 object
319 <h3>Class Attributes</h3>
320 <table>
321 <tr><td>None</td></tr>
322 </table>
323 <h3>Class Methods</h3>
324 <table>
325 <tr><td>None</td></tr>
326 </table>
327 <h3>Methods</h3>
328 <table>
329 <tr>
330 <td><a href="#Checker.__init__">Checker</a></td>
331 <td></td>
332 </tr><tr>
333 <td><a href="#Checker.build_tokens_line">build_tokens_line</a></td>
334 <td>Build a logical line from tokens.</td>
335 </tr><tr>
336 <td><a href="#Checker.check_all">check_all</a></td>
337 <td>Run all checks on the input file.</td>
338 </tr><tr>
339 <td><a href="#Checker.check_ast">check_ast</a></td>
340 <td>Build the file's AST and run all AST checks.</td>
341 </tr><tr>
342 <td><a href="#Checker.check_logical">check_logical</a></td>
343 <td>Build a line from tokens and run all logical checks on it.</td>
344 </tr><tr>
345 <td><a href="#Checker.check_physical">check_physical</a></td>
346 <td>Run all physical checks on a raw input line.</td>
347 </tr><tr>
348 <td><a href="#Checker.generate_tokens">generate_tokens</a></td>
349 <td>Tokenize the file, run physical line checks and yield tokens.</td>
350 </tr><tr>
351 <td><a href="#Checker.maybe_check_physical">maybe_check_physical</a></td>
352 <td>If appropriate (based on token), check current physical line(s).</td>
353 </tr><tr>
354 <td><a href="#Checker.readline">readline</a></td>
355 <td>Get the next line from the input buffer.</td>
356 </tr><tr>
357 <td><a href="#Checker.report_invalid_syntax">report_invalid_syntax</a></td>
358 <td>Check if the syntax is valid.</td>
359 </tr><tr>
360 <td><a href="#Checker.run_check">run_check</a></td>
361 <td>Run a check plugin.</td>
362 </tr>
363 </table>
364 <h3>Static Methods</h3>
365 <table>
366 <tr><td>None</td></tr>
367 </table>
368 <a NAME="Checker.__init__" ID="Checker.__init__"></a>
369 <h4>Checker (Constructor)</h4>
370 <b>Checker</b>(<i>filename=None, lines=None, options=None, report=None, **kwargs</i>)
371 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a>
372 <h4>Checker.build_tokens_line</h4>
373 <b>build_tokens_line</b>(<i></i>)
374 <p>
375 Build a logical line from tokens.
376 </p><a NAME="Checker.check_all" ID="Checker.check_all"></a>
377 <h4>Checker.check_all</h4>
378 <b>check_all</b>(<i>expected=None, line_offset=0</i>)
379 <p>
380 Run all checks on the input file.
381 </p><a NAME="Checker.check_ast" ID="Checker.check_ast"></a>
382 <h4>Checker.check_ast</h4>
383 <b>check_ast</b>(<i></i>)
384 <p>
385 Build the file's AST and run all AST checks.
386 </p><a NAME="Checker.check_logical" ID="Checker.check_logical"></a>
387 <h4>Checker.check_logical</h4>
388 <b>check_logical</b>(<i></i>)
389 <p>
390 Build a line from tokens and run all logical checks on it.
391 </p><a NAME="Checker.check_physical" ID="Checker.check_physical"></a>
392 <h4>Checker.check_physical</h4>
393 <b>check_physical</b>(<i>line</i>)
394 <p>
395 Run all physical checks on a raw input line.
396 </p><a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a>
397 <h4>Checker.generate_tokens</h4>
398 <b>generate_tokens</b>(<i></i>)
399 <p>
400 Tokenize the file, run physical line checks and yield tokens.
401 </p><a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a>
402 <h4>Checker.maybe_check_physical</h4>
403 <b>maybe_check_physical</b>(<i>token</i>)
404 <p>
405 If appropriate (based on token), check current physical line(s).
406 </p><a NAME="Checker.readline" ID="Checker.readline"></a>
407 <h4>Checker.readline</h4>
408 <b>readline</b>(<i></i>)
409 <p>
410 Get the next line from the input buffer.
411 </p><a NAME="Checker.report_invalid_syntax" ID="Checker.report_invalid_syntax"></a>
412 <h4>Checker.report_invalid_syntax</h4>
413 <b>report_invalid_syntax</b>(<i></i>)
414 <p>
415 Check if the syntax is valid.
416 </p><a NAME="Checker.run_check" ID="Checker.run_check"></a>
417 <h4>Checker.run_check</h4>
418 <b>run_check</b>(<i>check, argument_names</i>)
419 <p>
420 Run a check plugin.
421 </p>
422 <div align="right"><a href="#top">Up</a></div>
423 <hr /><hr />
424 <a NAME="DiffReport" ID="DiffReport"></a>
425 <h2>DiffReport</h2>
426 <p>
427 Collect and print the results for the changed lines only.
428 </p>
429 <h3>Derived from</h3>
430 StandardReport
431 <h3>Class Attributes</h3>
432 <table>
433 <tr><td>None</td></tr>
434 </table>
435 <h3>Class Methods</h3>
436 <table>
437 <tr><td>None</td></tr>
438 </table>
439 <h3>Methods</h3>
440 <table>
441 <tr>
442 <td><a href="#DiffReport.__init__">DiffReport</a></td>
443 <td></td>
444 </tr><tr>
445 <td><a href="#DiffReport.error">error</a></td>
446 <td></td>
447 </tr>
448 </table>
449 <h3>Static Methods</h3>
450 <table>
451 <tr><td>None</td></tr>
452 </table>
453 <a NAME="DiffReport.__init__" ID="DiffReport.__init__"></a>
454 <h4>DiffReport (Constructor)</h4>
455 <b>DiffReport</b>(<i>options</i>)
456 <a NAME="DiffReport.error" ID="DiffReport.error"></a>
457 <h4>DiffReport.error</h4>
458 <b>error</b>(<i>line_number, offset, text, check</i>)
459
460 <div align="right"><a href="#top">Up</a></div>
461 <hr /><hr />
462 <a NAME="FileReport" ID="FileReport"></a>
463 <h2>FileReport</h2>
464 <p>
465 Collect the results of the checks and print only the filenames.
466 </p>
467 <h3>Derived from</h3>
468 BaseReport
469 <h3>Class Attributes</h3>
470 <table>
471 <tr><td>print_filename</td></tr>
472 </table>
473 <h3>Class Methods</h3>
474 <table>
475 <tr><td>None</td></tr>
476 </table>
477 <h3>Methods</h3>
478 <table>
479 <tr><td>None</td></tr>
480 </table>
481 <h3>Static Methods</h3>
482 <table>
483 <tr><td>None</td></tr>
484 </table>
485
486 <div align="right"><a href="#top">Up</a></div>
487 <hr /><hr />
488 <a NAME="StandardReport" ID="StandardReport"></a>
489 <h2>StandardReport</h2>
490 <p>
491 Collect and print the results of the checks.
492 </p>
493 <h3>Derived from</h3>
494 BaseReport
495 <h3>Class Attributes</h3>
496 <table>
497 <tr><td>None</td></tr>
498 </table>
499 <h3>Class Methods</h3>
500 <table>
501 <tr><td>None</td></tr>
502 </table>
503 <h3>Methods</h3>
504 <table>
505 <tr>
506 <td><a href="#StandardReport.__init__">StandardReport</a></td>
507 <td></td>
508 </tr><tr>
509 <td><a href="#StandardReport.error">error</a></td>
510 <td>Report an error, according to options.</td>
511 </tr><tr>
512 <td><a href="#StandardReport.error_args">error_args</a></td>
513 <td>Report an error, according to options.</td>
514 </tr><tr>
515 <td><a href="#StandardReport.get_file_results">get_file_results</a></td>
516 <td>Print the result and return the overall count for this file.</td>
517 </tr><tr>
518 <td><a href="#StandardReport.init_file">init_file</a></td>
519 <td>Signal a new file.</td>
520 </tr>
521 </table>
522 <h3>Static Methods</h3>
523 <table>
524 <tr><td>None</td></tr>
525 </table>
526 <a NAME="StandardReport.__init__" ID="StandardReport.__init__"></a>
527 <h4>StandardReport (Constructor)</h4>
528 <b>StandardReport</b>(<i>options</i>)
529 <a NAME="StandardReport.error" ID="StandardReport.error"></a>
530 <h4>StandardReport.error</h4>
531 <b>error</b>(<i>line_number, offset, text, check</i>)
532 <p>
533 Report an error, according to options.
534 </p><a NAME="StandardReport.error_args" ID="StandardReport.error_args"></a>
535 <h4>StandardReport.error_args</h4>
536 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>)
537 <p>
538 Report an error, according to options.
539 </p><a NAME="StandardReport.get_file_results" ID="StandardReport.get_file_results"></a>
540 <h4>StandardReport.get_file_results</h4>
541 <b>get_file_results</b>(<i></i>)
542 <p>
543 Print the result and return the overall count for this file.
544 </p><a NAME="StandardReport.init_file" ID="StandardReport.init_file"></a>
545 <h4>StandardReport.init_file</h4>
546 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
547 <p>
548 Signal a new file.
549 </p>
550 <div align="right"><a href="#top">Up</a></div>
551 <hr /><hr />
552 <a NAME="StyleGuide" ID="StyleGuide"></a>
553 <h2>StyleGuide</h2>
554 <p>
555 Initialize a PEP-8 instance with few options.
556 </p>
557 <h3>Derived from</h3>
558 object
559 <h3>Class Attributes</h3>
560 <table>
561 <tr><td>None</td></tr>
562 </table>
563 <h3>Class Methods</h3>
564 <table>
565 <tr><td>None</td></tr>
566 </table>
567 <h3>Methods</h3>
568 <table>
569 <tr>
570 <td><a href="#StyleGuide.__init__">StyleGuide</a></td>
571 <td></td>
572 </tr><tr>
573 <td><a href="#StyleGuide.check_files">check_files</a></td>
574 <td>Run all checks on the paths.</td>
575 </tr><tr>
576 <td><a href="#StyleGuide.excluded">excluded</a></td>
577 <td>Check if the file should be excluded.</td>
578 </tr><tr>
579 <td><a href="#StyleGuide.get_checks">get_checks</a></td>
580 <td>Get all the checks for this category.</td>
581 </tr><tr>
582 <td><a href="#StyleGuide.ignore_code">ignore_code</a></td>
583 <td>Check if the error code should be ignored.</td>
584 </tr><tr>
585 <td><a href="#StyleGuide.init_report">init_report</a></td>
586 <td>Initialize the report instance.</td>
587 </tr><tr>
588 <td><a href="#StyleGuide.input_dir">input_dir</a></td>
589 <td>Check all files in this directory and all subdirectories.</td>
590 </tr><tr>
591 <td><a href="#StyleGuide.input_file">input_file</a></td>
592 <td>Run all checks on a Python source file.</td>
593 </tr>
594 </table>
595 <h3>Static Methods</h3>
596 <table>
597 <tr><td>None</td></tr>
598 </table>
599 <a NAME="StyleGuide.__init__" ID="StyleGuide.__init__"></a>
600 <h4>StyleGuide (Constructor)</h4>
601 <b>StyleGuide</b>(<i>*args, **kwargs</i>)
602 <a NAME="StyleGuide.check_files" ID="StyleGuide.check_files"></a>
603 <h4>StyleGuide.check_files</h4>
604 <b>check_files</b>(<i>paths=None</i>)
605 <p>
606 Run all checks on the paths.
607 </p><a NAME="StyleGuide.excluded" ID="StyleGuide.excluded"></a>
608 <h4>StyleGuide.excluded</h4>
609 <b>excluded</b>(<i>filename, parent=None</i>)
610 <p>
611 Check if the file should be excluded.
612 </p><p>
613 Check if 'options.exclude' contains a pattern that matches filename.
614 </p><a NAME="StyleGuide.get_checks" ID="StyleGuide.get_checks"></a>
615 <h4>StyleGuide.get_checks</h4>
616 <b>get_checks</b>(<i>argument_name</i>)
617 <p>
618 Get all the checks for this category.
619 </p><p>
620 Find all globally visible functions where the first argument name
621 starts with argument_name and which contain selected tests.
622 </p><a NAME="StyleGuide.ignore_code" ID="StyleGuide.ignore_code"></a>
623 <h4>StyleGuide.ignore_code</h4>
624 <b>ignore_code</b>(<i>code</i>)
625 <p>
626 Check if the error code should be ignored.
627 </p><p>
628 If 'options.select' contains a prefix of the error code,
629 return False. Else, if 'options.ignore' contains a prefix of
630 the error code, return True.
631 </p><a NAME="StyleGuide.init_report" ID="StyleGuide.init_report"></a>
632 <h4>StyleGuide.init_report</h4>
633 <b>init_report</b>(<i>reporter=None</i>)
634 <p>
635 Initialize the report instance.
636 </p><a NAME="StyleGuide.input_dir" ID="StyleGuide.input_dir"></a>
637 <h4>StyleGuide.input_dir</h4>
638 <b>input_dir</b>(<i>dirname</i>)
639 <p>
640 Check all files in this directory and all subdirectories.
641 </p><a NAME="StyleGuide.input_file" ID="StyleGuide.input_file"></a>
642 <h4>StyleGuide.input_file</h4>
643 <b>input_file</b>(<i>filename, lines=None, expected=None, line_offset=0</i>)
644 <p>
645 Run all checks on a Python source file.
646 </p>
647 <div align="right"><a href="#top">Up</a></div>
648 <hr /><hr />
649 <a NAME="_add_check" ID="_add_check"></a>
650 <h2>_add_check</h2>
651 <b>_add_check</b>(<i>check, kind, codes, args</i>)
652
653 <div align="right"><a href="#top">Up</a></div>
654 <hr /><hr />
655 <a NAME="_is_eol_token" ID="_is_eol_token"></a>
656 <h2>_is_eol_token</h2>
657 <b>_is_eol_token</b>(<i>token</i>)
658
659 <div align="right"><a href="#top">Up</a></div>
660 <hr /><hr />
661 <a NAME="_is_eol_token_1" ID="_is_eol_token_1"></a>
662 <h2>_is_eol_token</h2>
663 <b>_is_eol_token</b>(<i>token</i>)
664
665 <div align="right"><a href="#top">Up</a></div>
666 <hr /><hr />
667 <a NAME="_main" ID="_main"></a>
668 <h2>_main</h2>
669 <b>_main</b>(<i></i>)
670 <p>
671 Parse options and run checks on Python source.
672 </p>
673 <div align="right"><a href="#top">Up</a></div>
674 <hr /><hr />
675 <a NAME="blank_lines" ID="blank_lines"></a>
676 <h2>blank_lines</h2>
677 <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, blank_before, previous_logical, previous_indent_level</i>)
678 <p>
679 Separate top-level function and class definitions with two blank lines.
680 </p><p>
681 Method definitions inside a class are separated by a single blank line.
682 </p><p>
683 Extra blank lines may be used (sparingly) to separate groups of related
684 functions. Blank lines may be omitted between a bunch of related
685 one-liners (e.g. a set of dummy implementations).
686 </p><p>
687 Use blank lines in functions, sparingly, to indicate logical sections.
688 </p><p>
689 Okay: def a():\n pass\n\n\ndef b():\n pass
690 Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass
691 </p><p>
692 E301: class Foo:\n b = 0\n def bar():\n pass
693 E302: def a():\n pass\n\ndef b(n):\n pass
694 E303: def a():\n pass\n\n\n\ndef b(n):\n pass
695 E303: def a():\n\n\n\n pass
696 E304: @decorator\n\ndef a():\n pass
697 </p>
698 <div align="right"><a href="#top">Up</a></div>
699 <hr /><hr />
700 <a NAME="comparison_negative" ID="comparison_negative"></a>
701 <h2>comparison_negative</h2>
702 <b>comparison_negative</b>(<i>logical_line</i>)
703 <p>
704 Negative comparison should be done using "not in" and "is not".
705 </p><p>
706 Okay: if x not in y:\n pass
707 Okay: assert (X in Y or X is Z)
708 Okay: if not (X in Y):\n pass
709 Okay: zz = x is not y
710 E713: Z = not X in Y
711 E713: if not X.B in Y:\n pass
712 E714: if not X is Y:\n pass
713 E714: Z = not X.B is Y
714 </p>
715 <div align="right"><a href="#top">Up</a></div>
716 <hr /><hr />
717 <a NAME="comparison_to_singleton" ID="comparison_to_singleton"></a>
718 <h2>comparison_to_singleton</h2>
719 <b>comparison_to_singleton</b>(<i>logical_line, noqa</i>)
720 <p>
721 Comparison to singletons should use "is" or "is not".
722 </p><p>
723 Comparisons to singletons like None should always be done
724 with "is" or "is not", never the equality operators.
725 </p><p>
726 Okay: if arg is not None:
727 E711: if arg != None:
728 E712: if arg == True:
729 </p><p>
730 Also, beware of writing if x when you really mean if x is not None --
731 e.g. when testing whether a variable or argument that defaults to None was
732 set to some other value. The other value might have a type (such as a
733 container) that could be false in a boolean context!
734 </p>
735 <div align="right"><a href="#top">Up</a></div>
736 <hr /><hr />
737 <a NAME="comparison_type" ID="comparison_type"></a>
738 <h2>comparison_type</h2>
739 <b>comparison_type</b>(<i>logical_line</i>)
740 <p>
741 Object type comparisons should always use isinstance().
742 </p><p>
743 Do not compare types directly.
744 </p><p>
745 Okay: if isinstance(obj, int):
746 E721: if type(obj) is type(1):
747 </p><p>
748 When checking if an object is a string, keep in mind that it might be a
749 unicode string too! In Python 2.3, str and unicode have a common base
750 class, basestring, so you can do:
751 </p><p>
752 Okay: if isinstance(obj, basestring):
753 Okay: if type(a1) is type(b1):
754 </p>
755 <div align="right"><a href="#top">Up</a></div>
756 <hr /><hr />
757 <a NAME="compound_statements" ID="compound_statements"></a>
758 <h2>compound_statements</h2>
759 <b>compound_statements</b>(<i>logical_line</i>)
760 <p>
761 Compound statements (on the same line) are generally discouraged.
762 </p><p>
763 While sometimes it's okay to put an if/for/while with a small body
764 on the same line, never do this for multi-clause statements.
765 Also avoid folding such long lines!
766 </p><p>
767 Okay: if foo == 'blah':\n do_blah_thing()
768 Okay: do_one()
769 Okay: do_two()
770 Okay: do_three()
771 </p><p>
772 E701: if foo == 'blah': do_blah_thing()
773 E701: for x in lst: total += x
774 E701: while t < 10: t = delay()
775 E701: if foo == 'blah': do_blah_thing()
776 E701: else: do_non_blah_thing()
777 E701: try: something()
778 E701: finally: cleanup()
779 E701: if foo == 'blah': one(); two(); three()
780 </p><p>
781 E702: do_one(); do_two(); do_three()
782 E703: do_four(); # useless semicolon
783 </p>
784 <div align="right"><a href="#top">Up</a></div>
785 <hr /><hr />
786 <a NAME="continued_indentation" ID="continued_indentation"></a>
787 <h2>continued_indentation</h2>
788 <b>continued_indentation</b>(<i>logical_line, tokens, indent_level, hang_closing, indent_char, noqa, verbose</i>)
789 <p>
790 Continuation lines indentation.
791 </p><p>
792 Continuation lines should align wrapped elements either vertically
793 using Python's implicit line joining inside parentheses, brackets
794 and braces, or using a hanging indent.
795 </p><p>
796 When using a hanging indent these considerations should be applied:
797 - there should be no arguments on the first line, and
798 - further indentation should be used to clearly distinguish itself as a
799 continuation line.
800 </p><p>
801 Okay: a = (\n)
802 E123: a = (\n )
803 </p><p>
804 Okay: a = (\n 42)
805 E121: a = (\n 42)
806 E122: a = (\n42)
807 E123: a = (\n 42\n )
808 E124: a = (24,\n 42\n)
809 E125: if (\n b):\n pass
810 E126: a = (\n 42)
811 E127: a = (24,\n 42)
812 E128: a = (24,\n 42)
813 E129: if (a or\n b):\n pass
814 E131: a = (\n 42\n 24)
815 </p>
816 <div align="right"><a href="#top">Up</a></div>
817 <hr /><hr />
818 <a NAME="expand_indent" ID="expand_indent"></a>
819 <h2>expand_indent</h2>
820 <b>expand_indent</b>(<i>line</i>)
821 <p>
822 Return the amount of indentation.
823 </p><p>
824 Tabs are expanded to the next multiple of 8.
825 </p><p>
826 >>> expand_indent(' ')
827 4
828 >>> expand_indent('\t')
829 8
830 >>> expand_indent(' \t')
831 8
832 >>> expand_indent(' \t')
833 16
834 </p>
835 <div align="right"><a href="#top">Up</a></div>
836 <hr /><hr />
837 <a NAME="explicit_line_join" ID="explicit_line_join"></a>
838 <h2>explicit_line_join</h2>
839 <b>explicit_line_join</b>(<i>logical_line, tokens</i>)
840 <p>
841 Avoid explicit line join between brackets.
842 </p><p>
843 The preferred way of wrapping long lines is by using Python's implied line
844 continuation inside parentheses, brackets and braces. Long lines can be
845 broken over multiple lines by wrapping expressions in parentheses. These
846 should be used in preference to using a backslash for line continuation.
847 </p><p>
848 E502: aaa = [123, \\n 123]
849 E502: aaa = ("bbb " \\n "ccc")
850 </p><p>
851 Okay: aaa = [123,\n 123]
852 Okay: aaa = ("bbb "\n "ccc")
853 Okay: aaa = "bbb " \\n "ccc"
854 </p>
855 <div align="right"><a href="#top">Up</a></div>
856 <hr /><hr />
857 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
858 <h2>extraneous_whitespace</h2>
859 <b>extraneous_whitespace</b>(<i>logical_line</i>)
860 <p>
861 Avoid extraneous whitespace.
862 </p><p>
863 Avoid extraneous whitespace in these situations:
864 - Immediately inside parentheses, brackets or braces.
865 - Immediately before a comma, semicolon, or colon.
866 </p><p>
867 Okay: spam(ham[1], {eggs: 2})
868 E201: spam( ham[1], {eggs: 2})
869 E201: spam(ham[ 1], {eggs: 2})
870 E201: spam(ham[1], { eggs: 2})
871 E202: spam(ham[1], {eggs: 2} )
872 E202: spam(ham[1 ], {eggs: 2})
873 E202: spam(ham[1], {eggs: 2 })
874 </p><p>
875 E203: if x == 4: print x, y; x, y = y , x
876 E203: if x == 4: print x, y ; x, y = y, x
877 E203: if x == 4 : print x, y; x, y = y, x
878 </p>
879 <div align="right"><a href="#top">Up</a></div>
880 <hr /><hr />
881 <a NAME="filename_match" ID="filename_match"></a>
882 <h2>filename_match</h2>
883 <b>filename_match</b>(<i>filename, patterns, default=True</i>)
884 <p>
885 Check if patterns contains a pattern that matches filename.
886 </p><p>
887 If patterns is unspecified, this always returns True.
888 </p>
889 <div align="right"><a href="#top">Up</a></div>
890 <hr /><hr />
891 <a NAME="get_parser" ID="get_parser"></a>
892 <h2>get_parser</h2>
893 <b>get_parser</b>(<i>prog='pep8', version=__version__</i>)
894
895 <div align="right"><a href="#top">Up</a></div>
896 <hr /><hr />
897 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
898 <h2>imports_on_separate_lines</h2>
899 <b>imports_on_separate_lines</b>(<i>logical_line</i>)
900 <p>
901 Imports should usually be on separate lines.
902 </p><p>
903 Okay: import os\nimport sys
904 E401: import sys, os
905 </p><p>
906 Okay: from subprocess import Popen, PIPE
907 Okay: from myclas import MyClass
908 Okay: from foo.bar.yourclass import YourClass
909 Okay: import myclass
910 Okay: import foo.bar.yourclass
911 </p>
912 <div align="right"><a href="#top">Up</a></div>
913 <hr /><hr />
914 <a NAME="indentation" ID="indentation"></a>
915 <h2>indentation</h2>
916 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
917 <p>
918 Use 4 spaces per indentation level.
919 </p><p>
920 For really old code that you don't want to mess up, you can continue to
921 use 8-space tabs.
922 </p><p>
923 Okay: a = 1
924 Okay: if a == 0:\n a = 1
925 E111: a = 1
926 </p><p>
927 Okay: for item in items:\n pass
928 E112: for item in items:\npass
929 </p><p>
930 Okay: a = 1\nb = 2
931 E113: a = 1\n b = 2
932 </p>
933 <div align="right"><a href="#top">Up</a></div>
934 <hr /><hr />
935 <a NAME="init_checks_registry" ID="init_checks_registry"></a>
936 <h2>init_checks_registry</h2>
937 <b>init_checks_registry</b>(<i></i>)
938 <p>
939 Register all globally visible functions.
940 </p><p>
941 The first argument name is either 'physical_line' or 'logical_line'.
942 </p>
943 <div align="right"><a href="#top">Up</a></div>
944 <hr /><hr />
945 <a NAME="maximum_line_length" ID="maximum_line_length"></a>
946 <h2>maximum_line_length</h2>
947 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline</i>)
948 <p>
949 Limit all lines to a maximum of 79 characters.
950 </p><p>
951 There are still many devices around that are limited to 80 character
952 lines; plus, limiting windows to 80 characters makes it possible to have
953 several windows side-by-side. The default wrapping on such devices looks
954 ugly. Therefore, please limit all lines to a maximum of 79 characters.
955 For flowing long blocks of text (docstrings or comments), limiting the
956 length to 72 characters is recommended.
957 </p><p>
958 Reports error E501.
959 </p>
960 <div align="right"><a href="#top">Up</a></div>
961 <hr /><hr />
962 <a NAME="missing_whitespace" ID="missing_whitespace"></a>
963 <h2>missing_whitespace</h2>
964 <b>missing_whitespace</b>(<i>logical_line</i>)
965 <p>
966 Each comma, semicolon or colon should be followed by whitespace.
967 </p><p>
968 Okay: [a, b]
969 Okay: (3,)
970 Okay: a[1:4]
971 Okay: a[:4]
972 Okay: a[1:]
973 Okay: a[1:4:2]
974 E231: ['a','b']
975 E231: foo(bar,baz)
976 E231: [{'a':'b'}]
977 </p>
978 <div align="right"><a href="#top">Up</a></div>
979 <hr /><hr />
980 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
981 <h2>missing_whitespace_around_operator</h2>
982 <b>missing_whitespace_around_operator</b>(<i>logical_line, tokens</i>)
983 <p>
984 Surround operators with a single space on either side.
985 </p><p>
986 - Always surround these binary operators with a single space on
987 either side: assignment (=), augmented assignment (+=, -= etc.),
988 comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
989 Booleans (and, or, not).
990 </p><p>
991 - If operators with different priorities are used, consider adding
992 whitespace around the operators with the lowest priorities.
993 </p><p>
994 Okay: i = i + 1
995 Okay: submitted += 1
996 Okay: x = x * 2 - 1
997 Okay: hypot2 = x * x + y * y
998 Okay: c = (a + b) * (a - b)
999 Okay: foo(bar, key='word', *args, **kwargs)
1000 Okay: alpha[:-i]
1001 </p><p>
1002 E225: i=i+1
1003 E225: submitted +=1
1004 E225: x = x /2 - 1
1005 E225: z = x **y
1006 E226: c = (a+b) * (a-b)
1007 E226: hypot2 = x*x + y*y
1008 E227: c = a|b
1009 E228: msg = fmt%(errno, errmsg)
1010 </p>
1011 <div align="right"><a href="#top">Up</a></div>
1012 <hr /><hr />
1013 <a NAME="mute_string" ID="mute_string"></a>
1014 <h2>mute_string</h2>
1015 <b>mute_string</b>(<i>text</i>)
1016 <p>
1017 Replace contents with 'xxx' to prevent syntax matching.
1018 </p><p>
1019 >>> mute_string('"abc"')
1020 '"xxx"'
1021 >>> mute_string("'''abc'''")
1022 "'''xxx'''"
1023 >>> mute_string("r'abc'")
1024 "r'xxx'"
1025 </p>
1026 <div align="right"><a href="#top">Up</a></div>
1027 <hr /><hr />
1028 <a NAME="normalize_paths" ID="normalize_paths"></a>
1029 <h2>normalize_paths</h2>
1030 <b>normalize_paths</b>(<i>value, parent=os.curdir</i>)
1031 <p>
1032 Parse a comma-separated list of paths.
1033 </p><p>
1034 Return a list of absolute paths.
1035 </p>
1036 <div align="right"><a href="#top">Up</a></div>
1037 <hr /><hr />
1038 <a NAME="parse_udiff" ID="parse_udiff"></a>
1039 <h2>parse_udiff</h2>
1040 <b>parse_udiff</b>(<i>diff, patterns=None, parent='.'</i>)
1041 <p>
1042 Return a dictionary of matching lines.
1043 </p>
1044 <div align="right"><a href="#top">Up</a></div>
1045 <hr /><hr />
1046 <a NAME="process_options" ID="process_options"></a>
1047 <h2>process_options</h2>
1048 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None</i>)
1049 <p>
1050 Process options passed either via arglist or via command line args.
1051 </p>
1052 <div align="right"><a href="#top">Up</a></div>
1053 <hr /><hr />
1054 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a>
1055 <h2>python_3000_backticks</h2>
1056 <b>python_3000_backticks</b>(<i>logical_line</i>)
1057 <p>
1058 Backticks are removed in Python 3: use repr() instead.
1059 </p><p>
1060 Okay: val = repr(1 + 2)
1061 W604: val = `1 + 2`
1062 </p>
1063 <div align="right"><a href="#top">Up</a></div>
1064 <hr /><hr />
1065 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
1066 <h2>python_3000_has_key</h2>
1067 <b>python_3000_has_key</b>(<i>logical_line, noqa</i>)
1068 <p>
1069 The {}.has_key() method is removed in Python 3: use the 'in' operator.
1070 </p><p>
1071 Okay: if "alph" in d:\n print d["alph"]
1072 W601: assert d.has_key('alph')
1073 </p>
1074 <div align="right"><a href="#top">Up</a></div>
1075 <hr /><hr />
1076 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
1077 <h2>python_3000_not_equal</h2>
1078 <b>python_3000_not_equal</b>(<i>logical_line</i>)
1079 <p>
1080 New code should always use != instead of <>.
1081 </p><p>
1082 The older syntax is removed in Python 3.
1083 </p><p>
1084 Okay: if a != 'no':
1085 W603: if a <> 'no':
1086 </p>
1087 <div align="right"><a href="#top">Up</a></div>
1088 <hr /><hr />
1089 <a NAME="python_3000_raise_comma" ID="python_3000_raise_comma"></a>
1090 <h2>python_3000_raise_comma</h2>
1091 <b>python_3000_raise_comma</b>(<i>logical_line</i>)
1092 <p>
1093 When raising an exception, use "raise ValueError('message')".
1094 </p><p>
1095 The older form is removed in Python 3.
1096 </p><p>
1097 Okay: raise DummyError("Message")
1098 W602: raise DummyError, "Message"
1099 </p>
1100 <div align="right"><a href="#top">Up</a></div>
1101 <hr /><hr />
1102 <a NAME="read_config" ID="read_config"></a>
1103 <h2>read_config</h2>
1104 <b>read_config</b>(<i>options, args, arglist, parser</i>)
1105 <p>
1106 Read both user configuration and local configuration.
1107 </p>
1108 <div align="right"><a href="#top">Up</a></div>
1109 <hr /><hr />
1110 <a NAME="readlines" ID="readlines"></a>
1111 <h2>readlines</h2>
1112 <b>readlines</b>(<i>filename</i>)
1113 <p>
1114 Read the source code.
1115 </p>
1116 <div align="right"><a href="#top">Up</a></div>
1117 <hr /><hr />
1118 <a NAME="readlines_1" ID="readlines_1"></a>
1119 <h2>readlines</h2>
1120 <b>readlines</b>(<i>filename</i>)
1121 <p>
1122 Read the source code.
1123 </p>
1124 <div align="right"><a href="#top">Up</a></div>
1125 <hr /><hr />
1126 <a NAME="register_check" ID="register_check"></a>
1127 <h2>register_check</h2>
1128 <b>register_check</b>(<i>check, codes=None</i>)
1129 <p>
1130 Register a new check object.
1131 </p>
1132 <div align="right"><a href="#top">Up</a></div>
1133 <hr /><hr />
1134 <a NAME="stdin_get_value" ID="stdin_get_value"></a>
1135 <h2>stdin_get_value</h2>
1136 <b>stdin_get_value</b>(<i></i>)
1137
1138 <div align="right"><a href="#top">Up</a></div>
1139 <hr /><hr />
1140 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
1141 <h2>tabs_obsolete</h2>
1142 <b>tabs_obsolete</b>(<i>physical_line</i>)
1143 <p>
1144 For new projects, spaces-only are strongly recommended over tabs.
1145 </p><p>
1146 Okay: if True:\n return
1147 W191: if True:\n\treturn
1148 </p>
1149 <div align="right"><a href="#top">Up</a></div>
1150 <hr /><hr />
1151 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a>
1152 <h2>tabs_or_spaces</h2>
1153 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
1154 <p>
1155 Never mix tabs and spaces.
1156 </p><p>
1157 The most popular way of indenting Python is with spaces only. The
1158 second-most popular way is with tabs only. Code indented with a mixture
1159 of tabs and spaces should be converted to using spaces exclusively. When
1160 invoking the Python command line interpreter with the -t option, it issues
1161 warnings about code that illegally mixes tabs and spaces. When using -tt
1162 these warnings become errors. These options are highly recommended!
1163 </p><p>
1164 Okay: if a == 0:\n a = 1\n b = 1
1165 E101: if a == 0:\n a = 1\n\tb = 1
1166 </p>
1167 <div align="right"><a href="#top">Up</a></div>
1168 <hr /><hr />
1169 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
1170 <h2>trailing_blank_lines</h2>
1171 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number, total_lines</i>)
1172 <p>
1173 Trailing blank lines are superfluous.
1174 </p><p>
1175 Okay: spam(1)
1176 W391: spam(1)\n
1177 </p><p>
1178 However the last line should end with a new line (warning W292).
1179 </p>
1180 <div align="right"><a href="#top">Up</a></div>
1181 <hr /><hr />
1182 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a>
1183 <h2>trailing_whitespace</h2>
1184 <b>trailing_whitespace</b>(<i>physical_line</i>)
1185 <p>
1186 Trailing whitespace is superfluous.
1187 </p><p>
1188 The warning returned varies on whether the line itself is blank, for easier
1189 filtering for those who want to indent their blank lines.
1190 </p><p>
1191 Okay: spam(1)\n#
1192 W291: spam(1) \n#
1193 W293: class Foo(object):\n \n bang = 12
1194 </p>
1195 <div align="right"><a href="#top">Up</a></div>
1196 <hr /><hr />
1197 <a NAME="whitespace_around_comma" ID="whitespace_around_comma"></a>
1198 <h2>whitespace_around_comma</h2>
1199 <b>whitespace_around_comma</b>(<i>logical_line</i>)
1200 <p>
1201 Avoid extraneous whitespace after a comma or a colon.
1202 </p><p>
1203 Note: these checks are disabled by default
1204 </p><p>
1205 Okay: a = (1, 2)
1206 E241: a = (1, 2)
1207 E242: a = (1,\t2)
1208 </p>
1209 <div align="right"><a href="#top">Up</a></div>
1210 <hr /><hr />
1211 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a>
1212 <h2>whitespace_around_keywords</h2>
1213 <b>whitespace_around_keywords</b>(<i>logical_line</i>)
1214 <p>
1215 Avoid extraneous whitespace around keywords.
1216 </p><p>
1217 Okay: True and False
1218 E271: True and False
1219 E272: True and False
1220 E273: True and\tFalse
1221 E274: True\tand False
1222 </p>
1223 <div align="right"><a href="#top">Up</a></div>
1224 <hr /><hr />
1225 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
1226 <h2>whitespace_around_named_parameter_equals</h2>
1227 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>)
1228 <p>
1229 Don't use spaces around the '=' sign in function arguments.
1230 </p><p>
1231 Don't use spaces around the '=' sign when used to indicate a
1232 keyword argument or a default parameter value.
1233 </p><p>
1234 Okay: def complex(real, imag=0.0):
1235 Okay: return magic(r=real, i=imag)
1236 Okay: boolean(a == b)
1237 Okay: boolean(a != b)
1238 Okay: boolean(a <= b)
1239 Okay: boolean(a >= b)
1240 </p><p>
1241 E251: def complex(real, imag = 0.0):
1242 E251: return magic(r = real, i = imag)
1243 </p>
1244 <div align="right"><a href="#top">Up</a></div>
1245 <hr /><hr />
1246 <a NAME="whitespace_around_operator" ID="whitespace_around_operator"></a>
1247 <h2>whitespace_around_operator</h2>
1248 <b>whitespace_around_operator</b>(<i>logical_line</i>)
1249 <p>
1250 Avoid extraneous whitespace around an operator.
1251 </p><p>
1252 Okay: a = 12 + 3
1253 E221: a = 4 + 5
1254 E222: a = 4 + 5
1255 E223: a = 4\t+ 5
1256 E224: a = 4 +\t5
1257 </p>
1258 <div align="right"><a href="#top">Up</a></div>
1259 <hr /><hr />
1260 <a NAME="whitespace_before_comment" ID="whitespace_before_comment"></a>
1261 <h2>whitespace_before_comment</h2>
1262 <b>whitespace_before_comment</b>(<i>logical_line, tokens</i>)
1263 <p>
1264 Separate inline comments by at least two spaces.
1265 </p><p>
1266 An inline comment is a comment on the same line as a statement. Inline
1267 comments should be separated by at least two spaces from the statement.
1268 They should start with a # and a single space.
1269 </p><p>
1270 Each line of a block comment starts with a # and a single space
1271 (unless it is indented text inside the comment).
1272 </p><p>
1273 Okay: x = x + 1 # Increment x
1274 Okay: x = x + 1 # Increment x
1275 Okay: # Block comment
1276 E261: x = x + 1 # Increment x
1277 E262: x = x + 1 #Increment x
1278 E262: x = x + 1 # Increment x
1279 E265: #Block comment
1280 </p>
1281 <div align="right"><a href="#top">Up</a></div>
1282 <hr /><hr />
1283 <a NAME="whitespace_before_parameters" ID="whitespace_before_parameters"></a>
1284 <h2>whitespace_before_parameters</h2>
1285 <b>whitespace_before_parameters</b>(<i>logical_line, tokens</i>)
1286 <p>
1287 Avoid extraneous whitespace.
1288 </p><p>
1289 Avoid extraneous whitespace in the following situations:
1290 - before the open parenthesis that starts the argument list of a
1291 function call.
1292 - before the open parenthesis that starts an indexing or slicing.
1293 </p><p>
1294 Okay: spam(1)
1295 E211: spam (1)
1296 </p><p>
1297 Okay: dict['key'] = list[index]
1298 E211: dict ['key'] = list[index]
1299 E211: dict['key'] = list [index]
1300 </p>
1301 <div align="right"><a href="#top">Up</a></div>
1302 <hr />
1303 </body></html>

eric ide

mercurial