Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.pep8.html

changeset 832
eb5ff61f927b
child 1228
7afaf2fca55b
child 1278
fb0460fd00b9
equal deleted inserted replaced
831:f046b97785db 832:eb5ff61f927b
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
4 <html><head>
5 <title>eric5.Plugins.CheckerPlugins.Pep8.pep8</title>
6 <style>
7 body {
8 background: #EDECE6;
9 margin: 0em 1em 10em 1em;
10 color: black;
11 }
12
13 h1 { color: white; background: #85774A; }
14 h2 { color: white; background: #85774A; }
15 h3 { color: white; background: #9D936E; }
16 h4 { color: white; background: #9D936E; }
17
18 a { color: #BA6D36; }
19
20 </style>
21 </head>
22 <body><a NAME="top" ID="top"></a>
23 <h1>eric5.Plugins.CheckerPlugins.Pep8.pep8</h1>
24
25 <h3>Global Attributes</h3>
26 <table>
27 <tr><td>BENCHMARK_KEYS</td></tr><tr><td>BINARY_OPERATORS</td></tr><tr><td>DEFAULT_EXCLUDE</td></tr><tr><td>DEFAULT_IGNORE</td></tr><tr><td>DOCSTRING_REGEX</td></tr><tr><td>E225NOT_KEYWORDS</td></tr><tr><td>ERRORCODE_REGEX</td></tr><tr><td>EXTRANEOUS_WHITESPACE_REGEX</td></tr><tr><td>INDENT_REGEX</td></tr><tr><td>MAX_LINE_LENGTH</td></tr><tr><td>OPERATORS</td></tr><tr><td>RAISE_COMMA_REGEX</td></tr><tr><td>SELFTEST_REGEX</td></tr><tr><td>SKIP_TOKENS</td></tr><tr><td>UNARY_OPERATORS</td></tr><tr><td>WHITESPACE</td></tr><tr><td>WHITESPACE_AROUND_NAMED_PARAMETER_REGEX</td></tr><tr><td>WHITESPACE_AROUND_OPERATOR_REGEX</td></tr><tr><td>__version__</td></tr><tr><td>args</td></tr><tr><td>options</td></tr><tr><td>pep8_messages</td></tr><tr><td>pep8_messages_sample_args</td></tr>
28 </table>
29 <h3>Classes</h3>
30 <table>
31 <tr>
32 <td><a href="#Checker">Checker</a></td>
33 <td>Load a Python source file, tokenize it, check coding style.</td>
34 </tr>
35 </table>
36 <h3>Functions</h3>
37 <table>
38 <tr>
39 <td><a href="#_main">_main</a></td>
40 <td>Parse options and run checks on Python source.</td>
41 </tr><tr>
42 <td><a href="#blank_lines">blank_lines</a></td>
43 <td></td>
44 </tr><tr>
45 <td><a href="#compound_statements">compound_statements</a></td>
46 <td></td>
47 </tr><tr>
48 <td><a href="#excluded">excluded</a></td>
49 <td>Check if options.exclude contains a pattern that matches filename.</td>
50 </tr><tr>
51 <td><a href="#expand_indent">expand_indent</a></td>
52 <td>Return the amount of indentation.</td>
53 </tr><tr>
54 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
55 <td>Avoid extraneous whitespace in the following situations:</td>
56 </tr><tr>
57 <td><a href="#filename_match">filename_match</a></td>
58 <td>Check if options.filename contains a pattern that matches filename.</td>
59 </tr><tr>
60 <td><a href="#find_checks">find_checks</a></td>
61 <td>Find all globally visible functions where the first argument name starts with argument_name.</td>
62 </tr><tr>
63 <td><a href="#getMessage">getMessage</a></td>
64 <td>Function to get a translated and formatted message for a given code.</td>
65 </tr><tr>
66 <td><a href="#get_count">get_count</a></td>
67 <td>Return the total count of errors and warnings.</td>
68 </tr><tr>
69 <td><a href="#get_error_statistics">get_error_statistics</a></td>
70 <td>Get error statistics.</td>
71 </tr><tr>
72 <td><a href="#get_statistics">get_statistics</a></td>
73 <td>Get statistics for message codes that start with the prefix.</td>
74 </tr><tr>
75 <td><a href="#get_warning_statistics">get_warning_statistics</a></td>
76 <td>Get warning statistics.</td>
77 </tr><tr>
78 <td><a href="#ignore_code">ignore_code</a></td>
79 <td>Check if options.ignore contains a prefix of the error code.</td>
80 </tr><tr>
81 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
82 <td></td>
83 </tr><tr>
84 <td><a href="#indentation">indentation</a></td>
85 <td></td>
86 </tr><tr>
87 <td><a href="#input_dir">input_dir</a></td>
88 <td>Check all Python source files in this directory and all subdirectories.</td>
89 </tr><tr>
90 <td><a href="#input_file">input_file</a></td>
91 <td>Run all checks on a Python source file.</td>
92 </tr><tr>
93 <td><a href="#maximum_line_length">maximum_line_length</a></td>
94 <td>Limit all lines to a maximum of 79 characters.</td>
95 </tr><tr>
96 <td><a href="#message">message</a></td>
97 <td>Print a message.</td>
98 </tr><tr>
99 <td><a href="#missing_newline">missing_newline</a></td>
100 <td>JCR: The last line should have a newline.</td>
101 </tr><tr>
102 <td><a href="#missing_whitespace">missing_whitespace</a></td>
103 <td>JCR: Each comma, semicolon or colon should be followed by whitespace.</td>
104 </tr><tr>
105 <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td>
106 <td></td>
107 </tr><tr>
108 <td><a href="#mute_string">mute_string</a></td>
109 <td>Replace contents with 'xxx' to prevent syntax matching.</td>
110 </tr><tr>
111 <td><a href="#print_benchmark">print_benchmark</a></td>
112 <td>Print benchmark numbers.</td>
113 </tr><tr>
114 <td><a href="#print_statistics">print_statistics</a></td>
115 <td>Print overall statistics (number of errors and warnings).</td>
116 </tr><tr>
117 <td><a href="#process_options">process_options</a></td>
118 <td>Process options passed either via arglist or via command line args.</td>
119 </tr><tr>
120 <td><a href="#python_3000_backticks">python_3000_backticks</a></td>
121 <td>Backticks are removed in Python 3000.</td>
122 </tr><tr>
123 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
124 <td>The {}.has_key() method will be removed in the future version of Python.</td>
125 </tr><tr>
126 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
127 <td>!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only.</td>
128 </tr><tr>
129 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td>
130 <td>When raising an exception, use "raise ValueError('message')" instead of the older form "raise ValueError, 'message'".</td>
131 </tr><tr>
132 <td><a href="#readlines">readlines</a></td>
133 <td></td>
134 </tr><tr>
135 <td><a href="#readlines_1">readlines</a></td>
136 <td></td>
137 </tr><tr>
138 <td><a href="#reset_counters">reset_counters</a></td>
139 <td></td>
140 </tr><tr>
141 <td><a href="#run_tests">run_tests</a></td>
142 <td>Run all the tests from a file.</td>
143 </tr><tr>
144 <td><a href="#selftest">selftest</a></td>
145 <td>Test all check functions with test cases in docstrings.</td>
146 </tr><tr>
147 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
148 <td></td>
149 </tr><tr>
150 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
151 <td></td>
152 </tr><tr>
153 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
154 <td></td>
155 </tr><tr>
156 <td><a href="#trailing_whitespace">trailing_whitespace</a></td>
157 <td></td>
158 </tr><tr>
159 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
160 <td>Avoid extraneous whitespace in the following situations:</td>
161 </tr><tr>
162 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
163 <td>Don't use spaces around the '=' sign when used to indicate a keyword argument or a default parameter value.</td>
164 </tr><tr>
165 <td><a href="#whitespace_around_operator">whitespace_around_operator</a></td>
166 <td>Avoid extraneous whitespace in the following situations:</td>
167 </tr><tr>
168 <td><a href="#whitespace_before_inline_comment">whitespace_before_inline_comment</a></td>
169 <td>Separate inline comments by at least two spaces.</td>
170 </tr><tr>
171 <td><a href="#whitespace_before_parameters">whitespace_before_parameters</a></td>
172 <td>Avoid extraneous whitespace in the following situations:</td>
173 </tr>
174 </table>
175 <hr /><hr />
176 <a NAME="Checker" ID="Checker"></a>
177 <h2>Checker</h2>
178 <p>
179 Load a Python source file, tokenize it, check coding style.
180 </p>
181 <h3>Derived from</h3>
182 object
183 <h3>Class Attributes</h3>
184 <table>
185 <tr><td>None</td></tr>
186 </table>
187 <h3>Methods</h3>
188 <table>
189 <tr>
190 <td><a href="#Checker.__init__">Checker</a></td>
191 <td></td>
192 </tr><tr>
193 <td><a href="#Checker.build_tokens_line">build_tokens_line</a></td>
194 <td>Build a logical line from tokens.</td>
195 </tr><tr>
196 <td><a href="#Checker.check_all">check_all</a></td>
197 <td>Run all checks on the input file.</td>
198 </tr><tr>
199 <td><a href="#Checker.check_logical">check_logical</a></td>
200 <td>Build a line from tokens and run all logical checks on it.</td>
201 </tr><tr>
202 <td><a href="#Checker.check_physical">check_physical</a></td>
203 <td>Run all physical checks on a raw input line.</td>
204 </tr><tr>
205 <td><a href="#Checker.readline">readline</a></td>
206 <td>Get the next line from the input buffer.</td>
207 </tr><tr>
208 <td><a href="#Checker.readline_check_physical">readline_check_physical</a></td>
209 <td>Check and return the next physical line.</td>
210 </tr><tr>
211 <td><a href="#Checker.report_error">report_error</a></td>
212 <td>Report an error, according to options.</td>
213 </tr><tr>
214 <td><a href="#Checker.run_check">run_check</a></td>
215 <td>Run a check plugin.</td>
216 </tr>
217 </table>
218 <a NAME="Checker.__init__" ID="Checker.__init__"></a>
219 <h4>Checker (Constructor)</h4>
220 <b>Checker</b>(<i>filename, lines=None</i>)
221 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a>
222 <h4>Checker.build_tokens_line</h4>
223 <b>build_tokens_line</b>(<i></i>)
224 <p>
225 Build a logical line from tokens.
226 </p><a NAME="Checker.check_all" ID="Checker.check_all"></a>
227 <h4>Checker.check_all</h4>
228 <b>check_all</b>(<i>expected=None, line_offset=0</i>)
229 <p>
230 Run all checks on the input file.
231 </p><a NAME="Checker.check_logical" ID="Checker.check_logical"></a>
232 <h4>Checker.check_logical</h4>
233 <b>check_logical</b>(<i></i>)
234 <p>
235 Build a line from tokens and run all logical checks on it.
236 </p><a NAME="Checker.check_physical" ID="Checker.check_physical"></a>
237 <h4>Checker.check_physical</h4>
238 <b>check_physical</b>(<i>line</i>)
239 <p>
240 Run all physical checks on a raw input line.
241 </p><a NAME="Checker.readline" ID="Checker.readline"></a>
242 <h4>Checker.readline</h4>
243 <b>readline</b>(<i></i>)
244 <p>
245 Get the next line from the input buffer.
246 </p><a NAME="Checker.readline_check_physical" ID="Checker.readline_check_physical"></a>
247 <h4>Checker.readline_check_physical</h4>
248 <b>readline_check_physical</b>(<i></i>)
249 <p>
250 Check and return the next physical line. This method can be
251 used to feed tokenize.generate_tokens.
252 </p><a NAME="Checker.report_error" ID="Checker.report_error"></a>
253 <h4>Checker.report_error</h4>
254 <b>report_error</b>(<i>line_number, offset, text, check</i>)
255 <p>
256 Report an error, according to options.
257 </p><a NAME="Checker.run_check" ID="Checker.run_check"></a>
258 <h4>Checker.run_check</h4>
259 <b>run_check</b>(<i>check, argument_names</i>)
260 <p>
261 Run a check plugin.
262 </p>
263 <div align="right"><a href="#top">Up</a></div>
264 <hr /><hr />
265 <a NAME="_main" ID="_main"></a>
266 <h2>_main</h2>
267 <b>_main</b>(<i></i>)
268 <p>
269 Parse options and run checks on Python source.
270 </p>
271 <div align="right"><a href="#top">Up</a></div>
272 <hr /><hr />
273 <a NAME="blank_lines" ID="blank_lines"></a>
274 <h2>blank_lines</h2>
275 <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, previous_logical, previous_indent_level, blank_lines_before_comment</i>)
276
277 <div align="right"><a href="#top">Up</a></div>
278 <hr /><hr />
279 <a NAME="compound_statements" ID="compound_statements"></a>
280 <h2>compound_statements</h2>
281 <b>compound_statements</b>(<i>logical_line</i>)
282
283 <div align="right"><a href="#top">Up</a></div>
284 <hr /><hr />
285 <a NAME="excluded" ID="excluded"></a>
286 <h2>excluded</h2>
287 <b>excluded</b>(<i>filename</i>)
288 <p>
289 Check if options.exclude contains a pattern that matches filename.
290 </p>
291 <div align="right"><a href="#top">Up</a></div>
292 <hr /><hr />
293 <a NAME="expand_indent" ID="expand_indent"></a>
294 <h2>expand_indent</h2>
295 <b>expand_indent</b>(<i>line</i>)
296 <p>
297 Return the amount of indentation.
298 Tabs are expanded to the next multiple of 8.
299 </p><p>
300 >>> expand_indent(' ')
301 4
302 >>> expand_indent('\\t')
303 8
304 >>> expand_indent(' \\t')
305 8
306 >>> expand_indent(' \\t')
307 8
308 >>> expand_indent(' \\t')
309 16
310 </p>
311 <div align="right"><a href="#top">Up</a></div>
312 <hr /><hr />
313 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
314 <h2>extraneous_whitespace</h2>
315 <b>extraneous_whitespace</b>(<i>logical_line</i>)
316 <p>
317 Avoid extraneous whitespace in the following situations:
318 </p><p>
319 - Immediately inside parentheses, brackets or braces.
320 </p><p>
321 - Immediately before a comma, semicolon, or colon.
322 </p><p>
323 Okay: spam(ham[1], {eggs: 2})
324 E201: spam( ham[1], {eggs: 2})
325 E201: spam(ham[ 1], {eggs: 2})
326 E201: spam(ham[1], { eggs: 2})
327 E202: spam(ham[1], {eggs: 2} )
328 E202: spam(ham[1 ], {eggs: 2})
329 E202: spam(ham[1], {eggs: 2 })
330 </p><p>
331 E203: if x == 4: print x, y; x, y = y , x
332 E203: if x == 4: print x, y ; x, y = y, x
333 E203: if x == 4 : print x, y; x, y = y, x
334 </p>
335 <div align="right"><a href="#top">Up</a></div>
336 <hr /><hr />
337 <a NAME="filename_match" ID="filename_match"></a>
338 <h2>filename_match</h2>
339 <b>filename_match</b>(<i>filename</i>)
340 <p>
341 Check if options.filename contains a pattern that matches filename.
342 If options.filename is unspecified, this always returns True.
343 </p>
344 <div align="right"><a href="#top">Up</a></div>
345 <hr /><hr />
346 <a NAME="find_checks" ID="find_checks"></a>
347 <h2>find_checks</h2>
348 <b>find_checks</b>(<i>argument_name</i>)
349 <p>
350 Find all globally visible functions where the first argument name
351 starts with argument_name.
352 </p>
353 <div align="right"><a href="#top">Up</a></div>
354 <hr /><hr />
355 <a NAME="getMessage" ID="getMessage"></a>
356 <h2>getMessage</h2>
357 <b>getMessage</b>(<i>code, *args</i>)
358 <p>
359 Function to get a translated and formatted message for a given code.
360 </p><dl>
361 <dt><i>code</i></dt>
362 <dd>
363 message code (string)
364 </dd><dt><i>args</i></dt>
365 <dd>
366 arguments for a formatted message (list)
367 </dd>
368 </dl><dl>
369 <dt>Returns:</dt>
370 <dd>
371 translated and formatted message (string)
372 </dd>
373 </dl>
374 <div align="right"><a href="#top">Up</a></div>
375 <hr /><hr />
376 <a NAME="get_count" ID="get_count"></a>
377 <h2>get_count</h2>
378 <b>get_count</b>(<i>prefix=''</i>)
379 <p>
380 Return the total count of errors and warnings.
381 </p>
382 <div align="right"><a href="#top">Up</a></div>
383 <hr /><hr />
384 <a NAME="get_error_statistics" ID="get_error_statistics"></a>
385 <h2>get_error_statistics</h2>
386 <b>get_error_statistics</b>(<i></i>)
387 <p>
388 Get error statistics.
389 </p>
390 <div align="right"><a href="#top">Up</a></div>
391 <hr /><hr />
392 <a NAME="get_statistics" ID="get_statistics"></a>
393 <h2>get_statistics</h2>
394 <b>get_statistics</b>(<i>prefix=''</i>)
395 <p>
396 Get statistics for message codes that start with the prefix.
397 </p><p>
398 prefix='' matches all errors and warnings
399 prefix='E' matches all errors
400 prefix='W' matches all warnings
401 prefix='E4' matches all errors that have to do with imports
402 </p>
403 <div align="right"><a href="#top">Up</a></div>
404 <hr /><hr />
405 <a NAME="get_warning_statistics" ID="get_warning_statistics"></a>
406 <h2>get_warning_statistics</h2>
407 <b>get_warning_statistics</b>(<i></i>)
408 <p>
409 Get warning statistics.
410 </p>
411 <div align="right"><a href="#top">Up</a></div>
412 <hr /><hr />
413 <a NAME="ignore_code" ID="ignore_code"></a>
414 <h2>ignore_code</h2>
415 <b>ignore_code</b>(<i>code</i>)
416 <p>
417 Check if options.ignore contains a prefix of the error code.
418 If options.select contains a prefix of the error code, do not ignore it.
419 </p>
420 <div align="right"><a href="#top">Up</a></div>
421 <hr /><hr />
422 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
423 <h2>imports_on_separate_lines</h2>
424 <b>imports_on_separate_lines</b>(<i>logical_line</i>)
425
426 <div align="right"><a href="#top">Up</a></div>
427 <hr /><hr />
428 <a NAME="indentation" ID="indentation"></a>
429 <h2>indentation</h2>
430 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
431
432 <div align="right"><a href="#top">Up</a></div>
433 <hr /><hr />
434 <a NAME="input_dir" ID="input_dir"></a>
435 <h2>input_dir</h2>
436 <b>input_dir</b>(<i>dirname, runner=None</i>)
437 <p>
438 Check all Python source files in this directory and all subdirectories.
439 </p>
440 <div align="right"><a href="#top">Up</a></div>
441 <hr /><hr />
442 <a NAME="input_file" ID="input_file"></a>
443 <h2>input_file</h2>
444 <b>input_file</b>(<i>filename</i>)
445 <p>
446 Run all checks on a Python source file.
447 </p>
448 <div align="right"><a href="#top">Up</a></div>
449 <hr /><hr />
450 <a NAME="maximum_line_length" ID="maximum_line_length"></a>
451 <h2>maximum_line_length</h2>
452 <b>maximum_line_length</b>(<i>physical_line</i>)
453 <p>
454 Limit all lines to a maximum of 79 characters.
455 </p><p>
456 There are still many devices around that are limited to 80 character
457 lines; plus, limiting windows to 80 characters makes it possible to have
458 several windows side-by-side. The default wrapping on such devices looks
459 ugly. Therefore, please limit all lines to a maximum of 79 characters.
460 For flowing long blocks of text (docstrings or comments), limiting the
461 length to 72 characters is recommended.
462 </p>
463 <div align="right"><a href="#top">Up</a></div>
464 <hr /><hr />
465 <a NAME="message" ID="message"></a>
466 <h2>message</h2>
467 <b>message</b>(<i>text</i>)
468 <p>
469 Print a message.
470 </p>
471 <div align="right"><a href="#top">Up</a></div>
472 <hr /><hr />
473 <a NAME="missing_newline" ID="missing_newline"></a>
474 <h2>missing_newline</h2>
475 <b>missing_newline</b>(<i>physical_line</i>)
476 <p>
477 JCR: The last line should have a newline.
478 </p>
479 <div align="right"><a href="#top">Up</a></div>
480 <hr /><hr />
481 <a NAME="missing_whitespace" ID="missing_whitespace"></a>
482 <h2>missing_whitespace</h2>
483 <b>missing_whitespace</b>(<i>logical_line</i>)
484 <p>
485 JCR: Each comma, semicolon or colon should be followed by whitespace.
486 </p><p>
487 Okay: [a, b]
488 Okay: (3,)
489 Okay: a[1:4]
490 Okay: a[:4]
491 Okay: a[1:]
492 Okay: a[1:4:2]
493 E231: ['a','b']
494 E231: foo(bar,baz)
495 </p>
496 <div align="right"><a href="#top">Up</a></div>
497 <hr /><hr />
498 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
499 <h2>missing_whitespace_around_operator</h2>
500 <b>missing_whitespace_around_operator</b>(<i>logical_line, tokens</i>)
501
502 <div align="right"><a href="#top">Up</a></div>
503 <hr /><hr />
504 <a NAME="mute_string" ID="mute_string"></a>
505 <h2>mute_string</h2>
506 <b>mute_string</b>(<i>text</i>)
507 <p>
508 Replace contents with 'xxx' to prevent syntax matching.
509 </p><p>
510 >>> mute_string('"abc"')
511 '"xxx"'
512 >>> mute_string("'''abc'''")
513 "'''xxx'''"
514 >>> mute_string("r'abc'")
515 "r'xxx'"
516 </p>
517 <div align="right"><a href="#top">Up</a></div>
518 <hr /><hr />
519 <a NAME="print_benchmark" ID="print_benchmark"></a>
520 <h2>print_benchmark</h2>
521 <b>print_benchmark</b>(<i>elapsed</i>)
522 <p>
523 Print benchmark numbers.
524 </p>
525 <div align="right"><a href="#top">Up</a></div>
526 <hr /><hr />
527 <a NAME="print_statistics" ID="print_statistics"></a>
528 <h2>print_statistics</h2>
529 <b>print_statistics</b>(<i>prefix=''</i>)
530 <p>
531 Print overall statistics (number of errors and warnings).
532 </p>
533 <div align="right"><a href="#top">Up</a></div>
534 <hr /><hr />
535 <a NAME="process_options" ID="process_options"></a>
536 <h2>process_options</h2>
537 <b>process_options</b>(<i>arglist=None</i>)
538 <p>
539 Process options passed either via arglist or via command line args.
540 </p>
541 <div align="right"><a href="#top">Up</a></div>
542 <hr /><hr />
543 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a>
544 <h2>python_3000_backticks</h2>
545 <b>python_3000_backticks</b>(<i>logical_line</i>)
546 <p>
547 Backticks are removed in Python 3000.
548 Use repr() instead.
549 </p>
550 <div align="right"><a href="#top">Up</a></div>
551 <hr /><hr />
552 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
553 <h2>python_3000_has_key</h2>
554 <b>python_3000_has_key</b>(<i>logical_line</i>)
555 <p>
556 The {}.has_key() method will be removed in the future version of
557 Python. Use the 'in' operation instead, like:
558 d = {"a": 1, "b": 2}
559 if "b" in d:
560 print d["b"]
561 </p>
562 <div align="right"><a href="#top">Up</a></div>
563 <hr /><hr />
564 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
565 <h2>python_3000_not_equal</h2>
566 <b>python_3000_not_equal</b>(<i>logical_line</i>)
567 <p>
568 != can also be written <>, but this is an obsolete usage kept for
569 backwards compatibility only. New code should always use !=.
570 The older syntax is removed in Python 3000.
571 </p>
572 <div align="right"><a href="#top">Up</a></div>
573 <hr /><hr />
574 <a NAME="python_3000_raise_comma" ID="python_3000_raise_comma"></a>
575 <h2>python_3000_raise_comma</h2>
576 <b>python_3000_raise_comma</b>(<i>logical_line</i>)
577 <p>
578 When raising an exception, use "raise ValueError('message')"
579 instead of the older form "raise ValueError, 'message'".
580 </p><p>
581 The paren-using form is preferred because when the exception arguments
582 are long or include string formatting, you don't need to use line
583 continuation characters thanks to the containing parentheses. The older
584 form will be removed in Python 3000.
585 </p>
586 <div align="right"><a href="#top">Up</a></div>
587 <hr /><hr />
588 <a NAME="readlines" ID="readlines"></a>
589 <h2>readlines</h2>
590 <b>readlines</b>(<i>filename</i>)
591
592 <div align="right"><a href="#top">Up</a></div>
593 <hr /><hr />
594 <a NAME="readlines_1" ID="readlines_1"></a>
595 <h2>readlines</h2>
596 <b>readlines</b>(<i>filename</i>)
597
598 <div align="right"><a href="#top">Up</a></div>
599 <hr /><hr />
600 <a NAME="reset_counters" ID="reset_counters"></a>
601 <h2>reset_counters</h2>
602 <b>reset_counters</b>(<i></i>)
603
604 <div align="right"><a href="#top">Up</a></div>
605 <hr /><hr />
606 <a NAME="run_tests" ID="run_tests"></a>
607 <h2>run_tests</h2>
608 <b>run_tests</b>(<i>filename</i>)
609 <p>
610 Run all the tests from a file.
611 </p><p>
612 A test file can provide many tests. Each test starts with a declaration.
613 This declaration is a single line starting with '#:'.
614 It declares codes of expected failures, separated by spaces or 'Okay'
615 if no failure is expected.
616 If the file does not contain such declaration, it should pass all tests.
617 If the declaration is empty, following lines are not checked, until next
618 declaration.
619 </p><p>
620 Examples:
621 </p><p>
622 * Only E224 and W701 are expected: #: E224 W701
623 * Following example is conform: #: Okay
624 * Don't check these lines: #:
625 </p>
626 <div align="right"><a href="#top">Up</a></div>
627 <hr /><hr />
628 <a NAME="selftest" ID="selftest"></a>
629 <h2>selftest</h2>
630 <b>selftest</b>(<i></i>)
631 <p>
632 Test all check functions with test cases in docstrings.
633 </p>
634 <div align="right"><a href="#top">Up</a></div>
635 <hr /><hr />
636 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
637 <h2>tabs_obsolete</h2>
638 <b>tabs_obsolete</b>(<i>physical_line</i>)
639
640 <div align="right"><a href="#top">Up</a></div>
641 <hr /><hr />
642 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a>
643 <h2>tabs_or_spaces</h2>
644 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
645
646 <div align="right"><a href="#top">Up</a></div>
647 <hr /><hr />
648 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
649 <h2>trailing_blank_lines</h2>
650 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number</i>)
651
652 <div align="right"><a href="#top">Up</a></div>
653 <hr /><hr />
654 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a>
655 <h2>trailing_whitespace</h2>
656 <b>trailing_whitespace</b>(<i>physical_line</i>)
657
658 <div align="right"><a href="#top">Up</a></div>
659 <hr /><hr />
660 <a NAME="whitespace_around_comma" ID="whitespace_around_comma"></a>
661 <h2>whitespace_around_comma</h2>
662 <b>whitespace_around_comma</b>(<i>logical_line</i>)
663 <p>
664 Avoid extraneous whitespace in the following situations:
665 </p><p>
666 - More than one space around an assignment (or other) operator to
667 align it with another.
668 </p><p>
669 JCR: This should also be applied around comma etc.
670 Note: these checks are disabled by default
671 </p><p>
672 Okay: a = (1, 2)
673 E241: a = (1, 2)
674 E242: a = (1,\t2)
675 </p>
676 <div align="right"><a href="#top">Up</a></div>
677 <hr /><hr />
678 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
679 <h2>whitespace_around_named_parameter_equals</h2>
680 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line</i>)
681 <p>
682 Don't use spaces around the '=' sign when used to indicate a
683 keyword argument or a default parameter value.
684 </p><p>
685 Okay: def complex(real, imag=0.0):
686 Okay: return magic(r=real, i=imag)
687 Okay: boolean(a == b)
688 Okay: boolean(a != b)
689 Okay: boolean(a <= b)
690 Okay: boolean(a >= b)
691 </p><p>
692 E251: def complex(real, imag = 0.0):
693 E251: return magic(r = real, i = imag)
694 </p>
695 <div align="right"><a href="#top">Up</a></div>
696 <hr /><hr />
697 <a NAME="whitespace_around_operator" ID="whitespace_around_operator"></a>
698 <h2>whitespace_around_operator</h2>
699 <b>whitespace_around_operator</b>(<i>logical_line</i>)
700 <p>
701 Avoid extraneous whitespace in the following situations:
702 </p><p>
703 - More than one space around an assignment (or other) operator to
704 align it with another.
705 </p><p>
706 Okay: a = 12 + 3
707 E221: a = 4 + 5
708 E222: a = 4 + 5
709 E223: a = 4\t+ 5
710 E224: a = 4 +\t5
711 </p>
712 <div align="right"><a href="#top">Up</a></div>
713 <hr /><hr />
714 <a NAME="whitespace_before_inline_comment" ID="whitespace_before_inline_comment"></a>
715 <h2>whitespace_before_inline_comment</h2>
716 <b>whitespace_before_inline_comment</b>(<i>logical_line, tokens</i>)
717 <p>
718 Separate inline comments by at least two spaces.
719 </p><p>
720 An inline comment is a comment on the same line as a statement. Inline
721 comments should be separated by at least two spaces from the statement.
722 They should start with a # and a single space.
723 </p><p>
724 Okay: x = x + 1 # Increment x
725 Okay: x = x + 1 # Increment x
726 E261: x = x + 1 # Increment x
727 E262: x = x + 1 #Increment x
728 E262: x = x + 1 # Increment x
729 </p>
730 <div align="right"><a href="#top">Up</a></div>
731 <hr /><hr />
732 <a NAME="whitespace_before_parameters" ID="whitespace_before_parameters"></a>
733 <h2>whitespace_before_parameters</h2>
734 <b>whitespace_before_parameters</b>(<i>logical_line, tokens</i>)
735 <p>
736 Avoid extraneous whitespace in the following situations:
737 </p><p>
738 - Immediately before the open parenthesis that starts the argument
739 list of a function call.
740 </p><p>
741 - Immediately before the open parenthesis that starts an indexing or
742 slicing.
743 </p><p>
744 Okay: spam(1)
745 E211: spam (1)
746 </p><p>
747 Okay: dict['key'] = list[index]
748 E211: dict ['key'] = list[index]
749 E211: dict['key'] = list [index]
750 </p>
751 <div align="right"><a href="#top">Up</a></div>
752 <hr />
753 </body></html>

eric ide

mercurial