7 <body> |
7 <body> |
8 <a NAME="top" ID="top"></a> |
8 <a NAME="top" ID="top"></a> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</h1> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle</h1> |
10 |
10 |
11 <h3>Global Attributes</h3> |
11 <h3>Global Attributes</h3> |
12 |
12 <table> |
13 <table> |
13 <tr><td>ARITHMETIC_OP</td></tr> |
14 <tr><td>ARITHMETIC_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>FSTRING_END</td></tr><tr><td>FSTRING_MIDDLE</td></tr><tr><td>FSTRING_START</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>REPORT_FORMAT</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>UNARY_OPERATORS</td></tr><tr><td>USER_CONFIG</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> |
14 <tr><td>BENCHMARK_KEYS</td></tr> |
15 </table> |
15 <tr><td>BLANK_EXCEPT_REGEX</td></tr> |
|
16 <tr><td>BLANK_LINES_CONFIG</td></tr> |
|
17 <tr><td>COMPARE_NEGATIVE_REGEX</td></tr> |
|
18 <tr><td>COMPARE_SINGLETON_REGEX</td></tr> |
|
19 <tr><td>COMPARE_TYPE_REGEX</td></tr> |
|
20 <tr><td>DEFAULT_EXCLUDE</td></tr> |
|
21 <tr><td>DEFAULT_IGNORE</td></tr> |
|
22 <tr><td>DOCSTRING_REGEX</td></tr> |
|
23 <tr><td>DUNDER_REGEX</td></tr> |
|
24 <tr><td>ERRORCODE_REGEX</td></tr> |
|
25 <tr><td>EXTRANEOUS_WHITESPACE_REGEX</td></tr> |
|
26 <tr><td>FSTRING_END</td></tr> |
|
27 <tr><td>FSTRING_MIDDLE</td></tr> |
|
28 <tr><td>FSTRING_START</td></tr> |
|
29 <tr><td>HUNK_REGEX</td></tr> |
|
30 <tr><td>INDENT_REGEX</td></tr> |
|
31 <tr><td>INDENT_SIZE</td></tr> |
|
32 <tr><td>KEYWORDS</td></tr> |
|
33 <tr><td>KEYWORD_REGEX</td></tr> |
|
34 <tr><td>LAMBDA_REGEX</td></tr> |
|
35 <tr><td>MAX_DOC_LENGTH</td></tr> |
|
36 <tr><td>MAX_LINE_LENGTH</td></tr> |
|
37 <tr><td>NEWLINE</td></tr> |
|
38 <tr><td>OPERATOR_REGEX</td></tr> |
|
39 <tr><td>PROJECT_CONFIG</td></tr> |
|
40 <tr><td>PyCF_ONLY_AST</td></tr> |
|
41 <tr><td>REPORT_FORMAT</td></tr> |
|
42 <tr><td>SINGLETONS</td></tr> |
|
43 <tr><td>SKIP_COMMENTS</td></tr> |
|
44 <tr><td>SKIP_TOKENS</td></tr> |
|
45 <tr><td>STARTSWITH_DEF_REGEX</td></tr> |
|
46 <tr><td>STARTSWITH_INDENT_STATEMENT_REGEX</td></tr> |
|
47 <tr><td>STARTSWITH_TOP_LEVEL_REGEX</td></tr> |
|
48 <tr><td>UNARY_OPERATORS</td></tr> |
|
49 <tr><td>USER_CONFIG</td></tr> |
|
50 <tr><td>WHITESPACE</td></tr> |
|
51 <tr><td>WHITESPACE_AFTER_COMMA_REGEX</td></tr> |
|
52 <tr><td>WS_NEEDED_OPERATORS</td></tr> |
|
53 <tr><td>WS_OPTIONAL_OPERATORS</td></tr> |
|
54 <tr><td>_SYMBOLIC_OPS</td></tr> |
|
55 <tr><td>__version__</td></tr> |
|
56 <tr><td>_checks</td></tr> |
|
57 <tr><td>noqa</td></tr> |
|
58 </table> |
|
59 |
16 <h3>Classes</h3> |
60 <h3>Classes</h3> |
17 |
61 <table> |
18 <table> |
|
19 |
|
20 <tr> |
62 <tr> |
21 <td><a href="#BaseReport">BaseReport</a></td> |
63 <td><a href="#BaseReport">BaseReport</a></td> |
22 <td>Collect the results of the checks.</td> |
64 <td>Collect the results of the checks.</td> |
23 </tr> |
65 </tr> |
24 <tr> |
66 <tr> |
322 <tr> |
362 <tr> |
323 <td><a href="#BaseReport.stop">stop</a></td> |
363 <td><a href="#BaseReport.stop">stop</a></td> |
324 <td>Stop the timer.</td> |
364 <td>Stop the timer.</td> |
325 </tr> |
365 </tr> |
326 </table> |
366 </table> |
|
367 |
327 <h3>Static Methods</h3> |
368 <h3>Static Methods</h3> |
328 |
|
329 <table> |
369 <table> |
330 <tr><td>None</td></tr> |
370 <tr><td>None</td></tr> |
331 </table> |
371 </table> |
|
372 |
332 |
373 |
333 <a NAME="BaseReport.__init__" ID="BaseReport.__init__"></a> |
374 <a NAME="BaseReport.__init__" ID="BaseReport.__init__"></a> |
334 <h4>BaseReport (Constructor)</h4> |
375 <h4>BaseReport (Constructor)</h4> |
335 <b>BaseReport</b>(<i>options</i>) |
376 <b>BaseReport</b>(<i>options</i>) |
336 |
377 |
337 <a NAME="BaseReport.error" ID="BaseReport.error"></a> |
378 <a NAME="BaseReport.error" ID="BaseReport.error"></a> |
338 <h4>BaseReport.error</h4> |
379 <h4>BaseReport.error</h4> |
339 <b>error</b>(<i>line_number, offset, text, check</i>) |
380 <b>error</b>(<i>line_number, offset, text, check</i>) |
340 |
|
341 <p> |
381 <p> |
342 Report an error, according to options. |
382 Report an error, according to options. |
343 </p> |
383 </p> |
|
384 |
344 <a NAME="BaseReport.error_args" ID="BaseReport.error_args"></a> |
385 <a NAME="BaseReport.error_args" ID="BaseReport.error_args"></a> |
345 <h4>BaseReport.error_args</h4> |
386 <h4>BaseReport.error_args</h4> |
346 <b>error_args</b>(<i>line_number, offset, text, check, *args</i>) |
387 <b>error_args</b>(<i>line_number, offset, text, check, *args</i>) |
347 |
|
348 <p> |
388 <p> |
349 Report an error, according to options. |
389 Report an error, according to options. |
350 </p> |
390 </p> |
|
391 |
351 <a NAME="BaseReport.get_count" ID="BaseReport.get_count"></a> |
392 <a NAME="BaseReport.get_count" ID="BaseReport.get_count"></a> |
352 <h4>BaseReport.get_count</h4> |
393 <h4>BaseReport.get_count</h4> |
353 <b>get_count</b>(<i>prefix=''</i>) |
394 <b>get_count</b>(<i>prefix=''</i>) |
354 |
|
355 <p> |
395 <p> |
356 Return the total count of errors and warnings. |
396 Return the total count of errors and warnings. |
357 </p> |
397 </p> |
|
398 |
358 <a NAME="BaseReport.get_file_results" ID="BaseReport.get_file_results"></a> |
399 <a NAME="BaseReport.get_file_results" ID="BaseReport.get_file_results"></a> |
359 <h4>BaseReport.get_file_results</h4> |
400 <h4>BaseReport.get_file_results</h4> |
360 <b>get_file_results</b>(<i></i>) |
401 <b>get_file_results</b>(<i></i>) |
361 |
|
362 <p> |
402 <p> |
363 Return the count of errors and warnings for this file. |
403 Return the count of errors and warnings for this file. |
364 </p> |
404 </p> |
|
405 |
365 <a NAME="BaseReport.get_statistics" ID="BaseReport.get_statistics"></a> |
406 <a NAME="BaseReport.get_statistics" ID="BaseReport.get_statistics"></a> |
366 <h4>BaseReport.get_statistics</h4> |
407 <h4>BaseReport.get_statistics</h4> |
367 <b>get_statistics</b>(<i>prefix=''</i>) |
408 <b>get_statistics</b>(<i>prefix=''</i>) |
368 |
|
369 <p> |
409 <p> |
370 Get statistics for message codes that start with the prefix. |
410 Get statistics for message codes that start with the prefix. |
371 </p> |
411 </p> |
372 <p> |
412 <p> |
373 prefix='' matches all errors and warnings |
413 prefix='' matches all errors and warnings |
374 prefix='E' matches all errors |
414 prefix='E' matches all errors |
375 prefix='W' matches all warnings |
415 prefix='W' matches all warnings |
376 prefix='E4' matches all errors that have to do with imports |
416 prefix='E4' matches all errors that have to do with imports |
377 </p> |
417 </p> |
|
418 |
378 <a NAME="BaseReport.increment_logical_line" ID="BaseReport.increment_logical_line"></a> |
419 <a NAME="BaseReport.increment_logical_line" ID="BaseReport.increment_logical_line"></a> |
379 <h4>BaseReport.increment_logical_line</h4> |
420 <h4>BaseReport.increment_logical_line</h4> |
380 <b>increment_logical_line</b>(<i></i>) |
421 <b>increment_logical_line</b>(<i></i>) |
381 |
|
382 <p> |
422 <p> |
383 Signal a new logical line. |
423 Signal a new logical line. |
384 </p> |
424 </p> |
|
425 |
385 <a NAME="BaseReport.init_file" ID="BaseReport.init_file"></a> |
426 <a NAME="BaseReport.init_file" ID="BaseReport.init_file"></a> |
386 <h4>BaseReport.init_file</h4> |
427 <h4>BaseReport.init_file</h4> |
387 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>) |
428 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>) |
388 |
|
389 <p> |
429 <p> |
390 Signal a new file. |
430 Signal a new file. |
391 </p> |
431 </p> |
|
432 |
392 <a NAME="BaseReport.print_benchmark" ID="BaseReport.print_benchmark"></a> |
433 <a NAME="BaseReport.print_benchmark" ID="BaseReport.print_benchmark"></a> |
393 <h4>BaseReport.print_benchmark</h4> |
434 <h4>BaseReport.print_benchmark</h4> |
394 <b>print_benchmark</b>(<i></i>) |
435 <b>print_benchmark</b>(<i></i>) |
395 |
|
396 <p> |
436 <p> |
397 Print benchmark numbers. |
437 Print benchmark numbers. |
398 </p> |
438 </p> |
|
439 |
399 <a NAME="BaseReport.print_statistics" ID="BaseReport.print_statistics"></a> |
440 <a NAME="BaseReport.print_statistics" ID="BaseReport.print_statistics"></a> |
400 <h4>BaseReport.print_statistics</h4> |
441 <h4>BaseReport.print_statistics</h4> |
401 <b>print_statistics</b>(<i>prefix=''</i>) |
442 <b>print_statistics</b>(<i>prefix=''</i>) |
402 |
|
403 <p> |
443 <p> |
404 Print overall statistics (number of errors and warnings). |
444 Print overall statistics (number of errors and warnings). |
405 </p> |
445 </p> |
|
446 |
406 <a NAME="BaseReport.start" ID="BaseReport.start"></a> |
447 <a NAME="BaseReport.start" ID="BaseReport.start"></a> |
407 <h4>BaseReport.start</h4> |
448 <h4>BaseReport.start</h4> |
408 <b>start</b>(<i></i>) |
449 <b>start</b>(<i></i>) |
409 |
|
410 <p> |
450 <p> |
411 Start the timer. |
451 Start the timer. |
412 </p> |
452 </p> |
|
453 |
413 <a NAME="BaseReport.stop" ID="BaseReport.stop"></a> |
454 <a NAME="BaseReport.stop" ID="BaseReport.stop"></a> |
414 <h4>BaseReport.stop</h4> |
455 <h4>BaseReport.stop</h4> |
415 <b>stop</b>(<i></i>) |
456 <b>stop</b>(<i></i>) |
416 |
|
417 <p> |
457 <p> |
418 Stop the timer. |
458 Stop the timer. |
419 </p> |
459 </p> |
|
460 |
420 <div align="right"><a href="#top">Up</a></div> |
461 <div align="right"><a href="#top">Up</a></div> |
421 <hr /> |
462 <hr /> |
422 <hr /> |
463 <hr /> |
423 <a NAME="Checker" ID="Checker"></a> |
464 <a NAME="Checker" ID="Checker"></a> |
424 <h2>Checker</h2> |
465 <h2>Checker</h2> |
425 |
|
426 <p> |
466 <p> |
427 Load a Python source file, tokenize it, check coding style. |
467 Load a Python source file, tokenize it, check coding style. |
428 </p> |
468 </p> |
|
469 |
429 <h3>Derived from</h3> |
470 <h3>Derived from</h3> |
430 None |
471 None |
431 <h3>Class Attributes</h3> |
472 <h3>Class Attributes</h3> |
432 |
|
433 <table> |
473 <table> |
434 <tr><td>None</td></tr> |
474 <tr><td>None</td></tr> |
435 </table> |
475 </table> |
|
476 |
436 <h3>Class Methods</h3> |
477 <h3>Class Methods</h3> |
437 |
|
438 <table> |
478 <table> |
439 <tr><td>None</td></tr> |
479 <tr><td>None</td></tr> |
440 </table> |
480 </table> |
|
481 |
441 <h3>Methods</h3> |
482 <h3>Methods</h3> |
442 |
483 <table> |
443 <table> |
|
444 |
|
445 <tr> |
484 <tr> |
446 <td><a href="#Checker.__init__">Checker</a></td> |
485 <td><a href="#Checker.__init__">Checker</a></td> |
447 <td></td> |
486 <td></td> |
448 </tr> |
487 </tr> |
449 <tr> |
488 <tr> |
489 <tr> |
528 <tr> |
490 <td><a href="#Checker.run_check">run_check</a></td> |
529 <td><a href="#Checker.run_check">run_check</a></td> |
491 <td>Run a check plugin.</td> |
530 <td>Run a check plugin.</td> |
492 </tr> |
531 </tr> |
493 </table> |
532 </table> |
|
533 |
494 <h3>Static Methods</h3> |
534 <h3>Static Methods</h3> |
495 |
|
496 <table> |
535 <table> |
497 <tr><td>None</td></tr> |
536 <tr><td>None</td></tr> |
498 </table> |
537 </table> |
|
538 |
499 |
539 |
500 <a NAME="Checker.__init__" ID="Checker.__init__"></a> |
540 <a NAME="Checker.__init__" ID="Checker.__init__"></a> |
501 <h4>Checker (Constructor)</h4> |
541 <h4>Checker (Constructor)</h4> |
502 <b>Checker</b>(<i>filename=None, lines=None, options=None, report=None, **kwargs</i>) |
542 <b>Checker</b>(<i>filename=None, lines=None, options=None, report=None, **kwargs</i>) |
503 |
543 |
504 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a> |
544 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a> |
505 <h4>Checker.build_tokens_line</h4> |
545 <h4>Checker.build_tokens_line</h4> |
506 <b>build_tokens_line</b>(<i></i>) |
546 <b>build_tokens_line</b>(<i></i>) |
507 |
|
508 <p> |
547 <p> |
509 Build a logical line from tokens. |
548 Build a logical line from tokens. |
510 </p> |
549 </p> |
|
550 |
511 <a NAME="Checker.check_all" ID="Checker.check_all"></a> |
551 <a NAME="Checker.check_all" ID="Checker.check_all"></a> |
512 <h4>Checker.check_all</h4> |
552 <h4>Checker.check_all</h4> |
513 <b>check_all</b>(<i>expected=None, line_offset=0</i>) |
553 <b>check_all</b>(<i>expected=None, line_offset=0</i>) |
514 |
|
515 <p> |
554 <p> |
516 Run all checks on the input file. |
555 Run all checks on the input file. |
517 </p> |
556 </p> |
|
557 |
518 <a NAME="Checker.check_ast" ID="Checker.check_ast"></a> |
558 <a NAME="Checker.check_ast" ID="Checker.check_ast"></a> |
519 <h4>Checker.check_ast</h4> |
559 <h4>Checker.check_ast</h4> |
520 <b>check_ast</b>(<i></i>) |
560 <b>check_ast</b>(<i></i>) |
521 |
|
522 <p> |
561 <p> |
523 Build the file's AST and run all AST checks. |
562 Build the file's AST and run all AST checks. |
524 </p> |
563 </p> |
|
564 |
525 <a NAME="Checker.check_logical" ID="Checker.check_logical"></a> |
565 <a NAME="Checker.check_logical" ID="Checker.check_logical"></a> |
526 <h4>Checker.check_logical</h4> |
566 <h4>Checker.check_logical</h4> |
527 <b>check_logical</b>(<i></i>) |
567 <b>check_logical</b>(<i></i>) |
528 |
|
529 <p> |
568 <p> |
530 Build a line from tokens and run all logical checks on it. |
569 Build a line from tokens and run all logical checks on it. |
531 </p> |
570 </p> |
|
571 |
532 <a NAME="Checker.check_physical" ID="Checker.check_physical"></a> |
572 <a NAME="Checker.check_physical" ID="Checker.check_physical"></a> |
533 <h4>Checker.check_physical</h4> |
573 <h4>Checker.check_physical</h4> |
534 <b>check_physical</b>(<i>line</i>) |
574 <b>check_physical</b>(<i>line</i>) |
535 |
|
536 <p> |
575 <p> |
537 Run all physical checks on a raw input line. |
576 Run all physical checks on a raw input line. |
538 </p> |
577 </p> |
|
578 |
539 <a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a> |
579 <a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a> |
540 <h4>Checker.generate_tokens</h4> |
580 <h4>Checker.generate_tokens</h4> |
541 <b>generate_tokens</b>(<i></i>) |
581 <b>generate_tokens</b>(<i></i>) |
542 |
|
543 <p> |
582 <p> |
544 Tokenize file, run physical line checks and yield tokens. |
583 Tokenize file, run physical line checks and yield tokens. |
545 </p> |
584 </p> |
|
585 |
546 <a NAME="Checker.init_checker_state" ID="Checker.init_checker_state"></a> |
586 <a NAME="Checker.init_checker_state" ID="Checker.init_checker_state"></a> |
547 <h4>Checker.init_checker_state</h4> |
587 <h4>Checker.init_checker_state</h4> |
548 <b>init_checker_state</b>(<i>name, argument_names</i>) |
588 <b>init_checker_state</b>(<i>name, argument_names</i>) |
549 |
|
550 <p> |
589 <p> |
551 Prepare custom state for the specific checker plugin. |
590 Prepare custom state for the specific checker plugin. |
552 </p> |
591 </p> |
|
592 |
553 <a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a> |
593 <a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a> |
554 <h4>Checker.maybe_check_physical</h4> |
594 <h4>Checker.maybe_check_physical</h4> |
555 <b>maybe_check_physical</b>(<i>token, prev_physical</i>) |
595 <b>maybe_check_physical</b>(<i>token, prev_physical</i>) |
556 |
|
557 <p> |
596 <p> |
558 If appropriate for token, check current physical line(s). |
597 If appropriate for token, check current physical line(s). |
559 </p> |
598 </p> |
|
599 |
560 <a NAME="Checker.readline" ID="Checker.readline"></a> |
600 <a NAME="Checker.readline" ID="Checker.readline"></a> |
561 <h4>Checker.readline</h4> |
601 <h4>Checker.readline</h4> |
562 <b>readline</b>(<i></i>) |
602 <b>readline</b>(<i></i>) |
563 |
|
564 <p> |
603 <p> |
565 Get the next line from the input buffer. |
604 Get the next line from the input buffer. |
566 </p> |
605 </p> |
|
606 |
567 <a NAME="Checker.report_invalid_syntax" ID="Checker.report_invalid_syntax"></a> |
607 <a NAME="Checker.report_invalid_syntax" ID="Checker.report_invalid_syntax"></a> |
568 <h4>Checker.report_invalid_syntax</h4> |
608 <h4>Checker.report_invalid_syntax</h4> |
569 <b>report_invalid_syntax</b>(<i></i>) |
609 <b>report_invalid_syntax</b>(<i></i>) |
570 |
|
571 <p> |
610 <p> |
572 Check if the syntax is valid. |
611 Check if the syntax is valid. |
573 </p> |
612 </p> |
|
613 |
574 <a NAME="Checker.run_check" ID="Checker.run_check"></a> |
614 <a NAME="Checker.run_check" ID="Checker.run_check"></a> |
575 <h4>Checker.run_check</h4> |
615 <h4>Checker.run_check</h4> |
576 <b>run_check</b>(<i>check, argument_names</i>) |
616 <b>run_check</b>(<i>check, argument_names</i>) |
577 |
|
578 <p> |
617 <p> |
579 Run a check plugin. |
618 Run a check plugin. |
580 </p> |
619 </p> |
|
620 |
581 <div align="right"><a href="#top">Up</a></div> |
621 <div align="right"><a href="#top">Up</a></div> |
582 <hr /> |
622 <hr /> |
583 <hr /> |
623 <hr /> |
584 <a NAME="DiffReport" ID="DiffReport"></a> |
624 <a NAME="DiffReport" ID="DiffReport"></a> |
585 <h2>DiffReport</h2> |
625 <h2>DiffReport</h2> |
586 |
|
587 <p> |
626 <p> |
588 Collect and print the results for the changed lines only. |
627 Collect and print the results for the changed lines only. |
589 </p> |
628 </p> |
|
629 |
590 <h3>Derived from</h3> |
630 <h3>Derived from</h3> |
591 StandardReport |
631 StandardReport |
592 <h3>Class Attributes</h3> |
632 <h3>Class Attributes</h3> |
593 |
|
594 <table> |
633 <table> |
595 <tr><td>None</td></tr> |
634 <tr><td>None</td></tr> |
596 </table> |
635 </table> |
|
636 |
597 <h3>Class Methods</h3> |
637 <h3>Class Methods</h3> |
598 |
|
599 <table> |
638 <table> |
600 <tr><td>None</td></tr> |
639 <tr><td>None</td></tr> |
601 </table> |
640 </table> |
|
641 |
602 <h3>Methods</h3> |
642 <h3>Methods</h3> |
603 |
643 <table> |
604 <table> |
|
605 |
|
606 <tr> |
644 <tr> |
607 <td><a href="#DiffReport.__init__">DiffReport</a></td> |
645 <td><a href="#DiffReport.__init__">DiffReport</a></td> |
608 <td></td> |
646 <td></td> |
609 </tr> |
647 </tr> |
610 <tr> |
648 <tr> |
611 <td><a href="#DiffReport.error">error</a></td> |
649 <td><a href="#DiffReport.error">error</a></td> |
612 <td></td> |
650 <td></td> |
613 </tr> |
651 </tr> |
614 </table> |
652 </table> |
|
653 |
615 <h3>Static Methods</h3> |
654 <h3>Static Methods</h3> |
616 |
|
617 <table> |
655 <table> |
618 <tr><td>None</td></tr> |
656 <tr><td>None</td></tr> |
619 </table> |
657 </table> |
|
658 |
620 |
659 |
621 <a NAME="DiffReport.__init__" ID="DiffReport.__init__"></a> |
660 <a NAME="DiffReport.__init__" ID="DiffReport.__init__"></a> |
622 <h4>DiffReport (Constructor)</h4> |
661 <h4>DiffReport (Constructor)</h4> |
623 <b>DiffReport</b>(<i>options</i>) |
662 <b>DiffReport</b>(<i>options</i>) |
624 |
663 |
629 <div align="right"><a href="#top">Up</a></div> |
668 <div align="right"><a href="#top">Up</a></div> |
630 <hr /> |
669 <hr /> |
631 <hr /> |
670 <hr /> |
632 <a NAME="FileReport" ID="FileReport"></a> |
671 <a NAME="FileReport" ID="FileReport"></a> |
633 <h2>FileReport</h2> |
672 <h2>FileReport</h2> |
634 |
|
635 <p> |
673 <p> |
636 Collect the results of the checks and print the filenames. |
674 Collect the results of the checks and print the filenames. |
637 </p> |
675 </p> |
|
676 |
638 <h3>Derived from</h3> |
677 <h3>Derived from</h3> |
639 BaseReport |
678 BaseReport |
640 <h3>Class Attributes</h3> |
679 <h3>Class Attributes</h3> |
641 |
|
642 <table> |
680 <table> |
643 <tr><td>print_filename</td></tr> |
681 <tr><td>print_filename</td></tr> |
644 </table> |
682 </table> |
|
683 |
645 <h3>Class Methods</h3> |
684 <h3>Class Methods</h3> |
646 |
|
647 <table> |
685 <table> |
648 <tr><td>None</td></tr> |
686 <tr><td>None</td></tr> |
649 </table> |
687 </table> |
|
688 |
650 <h3>Methods</h3> |
689 <h3>Methods</h3> |
651 |
|
652 <table> |
690 <table> |
653 <tr><td>None</td></tr> |
691 <tr><td>None</td></tr> |
654 </table> |
692 </table> |
|
693 |
655 <h3>Static Methods</h3> |
694 <h3>Static Methods</h3> |
656 |
|
657 <table> |
695 <table> |
658 <tr><td>None</td></tr> |
696 <tr><td>None</td></tr> |
659 </table> |
697 </table> |
|
698 |
660 |
699 |
661 <div align="right"><a href="#top">Up</a></div> |
700 <div align="right"><a href="#top">Up</a></div> |
662 <hr /> |
701 <hr /> |
663 <hr /> |
702 <hr /> |
664 <a NAME="StandardReport" ID="StandardReport"></a> |
703 <a NAME="StandardReport" ID="StandardReport"></a> |
665 <h2>StandardReport</h2> |
704 <h2>StandardReport</h2> |
666 |
|
667 <p> |
705 <p> |
668 Collect and print the results of the checks. |
706 Collect and print the results of the checks. |
669 </p> |
707 </p> |
|
708 |
670 <h3>Derived from</h3> |
709 <h3>Derived from</h3> |
671 BaseReport |
710 BaseReport |
672 <h3>Class Attributes</h3> |
711 <h3>Class Attributes</h3> |
673 |
|
674 <table> |
712 <table> |
675 <tr><td>None</td></tr> |
713 <tr><td>None</td></tr> |
676 </table> |
714 </table> |
|
715 |
677 <h3>Class Methods</h3> |
716 <h3>Class Methods</h3> |
678 |
|
679 <table> |
717 <table> |
680 <tr><td>None</td></tr> |
718 <tr><td>None</td></tr> |
681 </table> |
719 </table> |
|
720 |
682 <h3>Methods</h3> |
721 <h3>Methods</h3> |
683 |
722 <table> |
684 <table> |
|
685 |
|
686 <tr> |
723 <tr> |
687 <td><a href="#StandardReport.__init__">StandardReport</a></td> |
724 <td><a href="#StandardReport.__init__">StandardReport</a></td> |
688 <td></td> |
725 <td></td> |
689 </tr> |
726 </tr> |
690 <tr> |
727 <tr> |
702 <tr> |
739 <tr> |
703 <td><a href="#StandardReport.init_file">init_file</a></td> |
740 <td><a href="#StandardReport.init_file">init_file</a></td> |
704 <td>Signal a new file.</td> |
741 <td>Signal a new file.</td> |
705 </tr> |
742 </tr> |
706 </table> |
743 </table> |
|
744 |
707 <h3>Static Methods</h3> |
745 <h3>Static Methods</h3> |
708 |
|
709 <table> |
746 <table> |
710 <tr><td>None</td></tr> |
747 <tr><td>None</td></tr> |
711 </table> |
748 </table> |
|
749 |
712 |
750 |
713 <a NAME="StandardReport.__init__" ID="StandardReport.__init__"></a> |
751 <a NAME="StandardReport.__init__" ID="StandardReport.__init__"></a> |
714 <h4>StandardReport (Constructor)</h4> |
752 <h4>StandardReport (Constructor)</h4> |
715 <b>StandardReport</b>(<i>options</i>) |
753 <b>StandardReport</b>(<i>options</i>) |
716 |
754 |
717 <a NAME="StandardReport.error" ID="StandardReport.error"></a> |
755 <a NAME="StandardReport.error" ID="StandardReport.error"></a> |
718 <h4>StandardReport.error</h4> |
756 <h4>StandardReport.error</h4> |
719 <b>error</b>(<i>line_number, offset, text, check</i>) |
757 <b>error</b>(<i>line_number, offset, text, check</i>) |
720 |
|
721 <p> |
758 <p> |
722 Report an error, according to options. |
759 Report an error, according to options. |
723 </p> |
760 </p> |
|
761 |
724 <a NAME="StandardReport.error_args" ID="StandardReport.error_args"></a> |
762 <a NAME="StandardReport.error_args" ID="StandardReport.error_args"></a> |
725 <h4>StandardReport.error_args</h4> |
763 <h4>StandardReport.error_args</h4> |
726 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>) |
764 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>) |
727 |
|
728 <p> |
765 <p> |
729 Report an error, according to options. |
766 Report an error, according to options. |
730 </p> |
767 </p> |
|
768 |
731 <a NAME="StandardReport.get_file_results" ID="StandardReport.get_file_results"></a> |
769 <a NAME="StandardReport.get_file_results" ID="StandardReport.get_file_results"></a> |
732 <h4>StandardReport.get_file_results</h4> |
770 <h4>StandardReport.get_file_results</h4> |
733 <b>get_file_results</b>(<i></i>) |
771 <b>get_file_results</b>(<i></i>) |
734 |
|
735 <p> |
772 <p> |
736 Print results and return the overall count for this file. |
773 Print results and return the overall count for this file. |
737 </p> |
774 </p> |
|
775 |
738 <a NAME="StandardReport.init_file" ID="StandardReport.init_file"></a> |
776 <a NAME="StandardReport.init_file" ID="StandardReport.init_file"></a> |
739 <h4>StandardReport.init_file</h4> |
777 <h4>StandardReport.init_file</h4> |
740 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>) |
778 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>) |
741 |
|
742 <p> |
779 <p> |
743 Signal a new file. |
780 Signal a new file. |
744 </p> |
781 </p> |
|
782 |
745 <div align="right"><a href="#top">Up</a></div> |
783 <div align="right"><a href="#top">Up</a></div> |
746 <hr /> |
784 <hr /> |
747 <hr /> |
785 <hr /> |
748 <a NAME="StyleGuide" ID="StyleGuide"></a> |
786 <a NAME="StyleGuide" ID="StyleGuide"></a> |
749 <h2>StyleGuide</h2> |
787 <h2>StyleGuide</h2> |
750 |
|
751 <p> |
788 <p> |
752 Initialize a PEP-8 instance with few options. |
789 Initialize a PEP-8 instance with few options. |
753 </p> |
790 </p> |
|
791 |
754 <h3>Derived from</h3> |
792 <h3>Derived from</h3> |
755 None |
793 None |
756 <h3>Class Attributes</h3> |
794 <h3>Class Attributes</h3> |
757 |
|
758 <table> |
795 <table> |
759 <tr><td>None</td></tr> |
796 <tr><td>None</td></tr> |
760 </table> |
797 </table> |
|
798 |
761 <h3>Class Methods</h3> |
799 <h3>Class Methods</h3> |
762 |
|
763 <table> |
800 <table> |
764 <tr><td>None</td></tr> |
801 <tr><td>None</td></tr> |
765 </table> |
802 </table> |
|
803 |
766 <h3>Methods</h3> |
804 <h3>Methods</h3> |
767 |
805 <table> |
768 <table> |
|
769 |
|
770 <tr> |
806 <tr> |
771 <td><a href="#StyleGuide.__init__">StyleGuide</a></td> |
807 <td><a href="#StyleGuide.__init__">StyleGuide</a></td> |
772 <td></td> |
808 <td></td> |
773 </tr> |
809 </tr> |
774 <tr> |
810 <tr> |
798 <tr> |
834 <tr> |
799 <td><a href="#StyleGuide.input_file">input_file</a></td> |
835 <td><a href="#StyleGuide.input_file">input_file</a></td> |
800 <td>Run all checks on a Python source file.</td> |
836 <td>Run all checks on a Python source file.</td> |
801 </tr> |
837 </tr> |
802 </table> |
838 </table> |
|
839 |
803 <h3>Static Methods</h3> |
840 <h3>Static Methods</h3> |
804 |
|
805 <table> |
841 <table> |
806 <tr><td>None</td></tr> |
842 <tr><td>None</td></tr> |
807 </table> |
843 </table> |
|
844 |
808 |
845 |
809 <a NAME="StyleGuide.__init__" ID="StyleGuide.__init__"></a> |
846 <a NAME="StyleGuide.__init__" ID="StyleGuide.__init__"></a> |
810 <h4>StyleGuide (Constructor)</h4> |
847 <h4>StyleGuide (Constructor)</h4> |
811 <b>StyleGuide</b>(<i>*args, **kwargs</i>) |
848 <b>StyleGuide</b>(<i>*args, **kwargs</i>) |
812 |
849 |
813 <a NAME="StyleGuide.check_files" ID="StyleGuide.check_files"></a> |
850 <a NAME="StyleGuide.check_files" ID="StyleGuide.check_files"></a> |
814 <h4>StyleGuide.check_files</h4> |
851 <h4>StyleGuide.check_files</h4> |
815 <b>check_files</b>(<i>paths=None</i>) |
852 <b>check_files</b>(<i>paths=None</i>) |
816 |
|
817 <p> |
853 <p> |
818 Run all checks on the paths. |
854 Run all checks on the paths. |
819 </p> |
855 </p> |
|
856 |
820 <a NAME="StyleGuide.excluded" ID="StyleGuide.excluded"></a> |
857 <a NAME="StyleGuide.excluded" ID="StyleGuide.excluded"></a> |
821 <h4>StyleGuide.excluded</h4> |
858 <h4>StyleGuide.excluded</h4> |
822 <b>excluded</b>(<i>filename, parent=None</i>) |
859 <b>excluded</b>(<i>filename, parent=None</i>) |
823 |
|
824 <p> |
860 <p> |
825 Check if the file should be excluded. |
861 Check if the file should be excluded. |
826 </p> |
862 </p> |
827 <p> |
863 <p> |
828 Check if 'options.exclude' contains a pattern matching filename. |
864 Check if 'options.exclude' contains a pattern matching filename. |
829 </p> |
865 </p> |
|
866 |
830 <a NAME="StyleGuide.get_checks" ID="StyleGuide.get_checks"></a> |
867 <a NAME="StyleGuide.get_checks" ID="StyleGuide.get_checks"></a> |
831 <h4>StyleGuide.get_checks</h4> |
868 <h4>StyleGuide.get_checks</h4> |
832 <b>get_checks</b>(<i>argument_name</i>) |
869 <b>get_checks</b>(<i>argument_name</i>) |
833 |
|
834 <p> |
870 <p> |
835 Get all the checks for this category. |
871 Get all the checks for this category. |
836 </p> |
872 </p> |
837 <p> |
873 <p> |
838 Find all globally visible functions where the first argument |
874 Find all globally visible functions where the first argument |
839 name starts with argument_name and which contain selected tests. |
875 name starts with argument_name and which contain selected tests. |
840 </p> |
876 </p> |
|
877 |
841 <a NAME="StyleGuide.ignore_code" ID="StyleGuide.ignore_code"></a> |
878 <a NAME="StyleGuide.ignore_code" ID="StyleGuide.ignore_code"></a> |
842 <h4>StyleGuide.ignore_code</h4> |
879 <h4>StyleGuide.ignore_code</h4> |
843 <b>ignore_code</b>(<i>code</i>) |
880 <b>ignore_code</b>(<i>code</i>) |
844 |
|
845 <p> |
881 <p> |
846 Check if the error code should be ignored. |
882 Check if the error code should be ignored. |
847 </p> |
883 </p> |
848 <p> |
884 <p> |
849 If 'options.select' contains a prefix of the error code, |
885 If 'options.select' contains a prefix of the error code, |
850 return False. Else, if 'options.ignore' contains a prefix of |
886 return False. Else, if 'options.ignore' contains a prefix of |
851 the error code, return True. |
887 the error code, return True. |
852 </p> |
888 </p> |
|
889 |
853 <a NAME="StyleGuide.init_report" ID="StyleGuide.init_report"></a> |
890 <a NAME="StyleGuide.init_report" ID="StyleGuide.init_report"></a> |
854 <h4>StyleGuide.init_report</h4> |
891 <h4>StyleGuide.init_report</h4> |
855 <b>init_report</b>(<i>reporter=None</i>) |
892 <b>init_report</b>(<i>reporter=None</i>) |
856 |
|
857 <p> |
893 <p> |
858 Initialize the report instance. |
894 Initialize the report instance. |
859 </p> |
895 </p> |
|
896 |
860 <a NAME="StyleGuide.input_dir" ID="StyleGuide.input_dir"></a> |
897 <a NAME="StyleGuide.input_dir" ID="StyleGuide.input_dir"></a> |
861 <h4>StyleGuide.input_dir</h4> |
898 <h4>StyleGuide.input_dir</h4> |
862 <b>input_dir</b>(<i>dirname</i>) |
899 <b>input_dir</b>(<i>dirname</i>) |
863 |
|
864 <p> |
900 <p> |
865 Check all files in this directory and all subdirectories. |
901 Check all files in this directory and all subdirectories. |
866 </p> |
902 </p> |
|
903 |
867 <a NAME="StyleGuide.input_file" ID="StyleGuide.input_file"></a> |
904 <a NAME="StyleGuide.input_file" ID="StyleGuide.input_file"></a> |
868 <h4>StyleGuide.input_file</h4> |
905 <h4>StyleGuide.input_file</h4> |
869 <b>input_file</b>(<i>filename, lines=None, expected=None, line_offset=0</i>) |
906 <b>input_file</b>(<i>filename, lines=None, expected=None, line_offset=0</i>) |
870 |
|
871 <p> |
907 <p> |
872 Run all checks on a Python source file. |
908 Run all checks on a Python source file. |
873 </p> |
909 </p> |
|
910 |
874 <div align="right"><a href="#top">Up</a></div> |
911 <div align="right"><a href="#top">Up</a></div> |
875 <hr /> |
912 <hr /> |
876 <hr /> |
913 <hr /> |
877 <a NAME="_add_check" ID="_add_check"></a> |
914 <a NAME="_add_check" ID="_add_check"></a> |
878 <h2>_add_check</h2> |
915 <h2>_add_check</h2> |
1003 E741: lambda **l: |
1039 E741: lambda **l: |
1004 E741: def f(**l): |
1040 E741: def f(**l): |
1005 E742: class I(object): |
1041 E742: class I(object): |
1006 E743: def l(x): |
1042 E743: def l(x): |
1007 </p> |
1043 </p> |
|
1044 |
1008 <div align="right"><a href="#top">Up</a></div> |
1045 <div align="right"><a href="#top">Up</a></div> |
1009 <hr /> |
1046 <hr /> |
1010 <hr /> |
1047 <hr /> |
1011 <a NAME="bare_except" ID="bare_except"></a> |
1048 <a NAME="bare_except" ID="bare_except"></a> |
1012 <h2>bare_except</h2> |
1049 <h2>bare_except</h2> |
1013 <b>bare_except</b>(<i>logical_line, noqa</i>) |
1050 <b>bare_except</b>(<i>logical_line, noqa</i>) |
1014 |
|
1015 <p> |
1051 <p> |
1016 When catching exceptions, mention specific exceptions when |
1052 When catching exceptions, mention specific exceptions when |
1017 possible. |
1053 possible. |
1018 </p> |
1054 </p> |
1019 <p> |
1055 <p> |
1020 Okay: except Exception: |
1056 Okay: except Exception: |
1021 Okay: except BaseException: |
1057 Okay: except BaseException: |
1022 E722: except: |
1058 E722: except: |
1023 </p> |
1059 </p> |
|
1060 |
1024 <div align="right"><a href="#top">Up</a></div> |
1061 <div align="right"><a href="#top">Up</a></div> |
1025 <hr /> |
1062 <hr /> |
1026 <hr /> |
1063 <hr /> |
1027 <a NAME="blank_lines" ID="blank_lines"></a> |
1064 <a NAME="blank_lines" ID="blank_lines"></a> |
1028 <h2>blank_lines</h2> |
1065 <h2>blank_lines</h2> |
1029 <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>) |
1066 <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>) |
1030 |
|
1031 <p> |
1067 <p> |
1032 Separate top-level function and class definitions with two blank |
1068 Separate top-level function and class definitions with two blank |
1033 lines. |
1069 lines. |
1034 </p> |
1070 </p> |
1035 <p> |
1071 <p> |
1265 E127: a = (24,\n 42) |
1301 E127: a = (24,\n 42) |
1266 E128: a = (24,\n 42) |
1302 E128: a = (24,\n 42) |
1267 E129: if (a or\n b):\n pass |
1303 E129: if (a or\n b):\n pass |
1268 E131: a = (\n 42\n 24) |
1304 E131: a = (\n 42\n 24) |
1269 </p> |
1305 </p> |
|
1306 |
1270 <div align="right"><a href="#top">Up</a></div> |
1307 <div align="right"><a href="#top">Up</a></div> |
1271 <hr /> |
1308 <hr /> |
1272 <hr /> |
1309 <hr /> |
1273 <a NAME="expand_indent" ID="expand_indent"></a> |
1310 <a NAME="expand_indent" ID="expand_indent"></a> |
1274 <h2>expand_indent</h2> |
1311 <h2>expand_indent</h2> |
1275 <b>expand_indent</b>(<i>line</i>) |
1312 <b>expand_indent</b>(<i>line</i>) |
1276 |
|
1277 <p> |
1313 <p> |
1278 Return the amount of indentation. |
1314 Return the amount of indentation. |
1279 </p> |
1315 </p> |
1280 <p> |
1316 <p> |
1281 Tabs are expanded to the next multiple of 8. |
1317 Tabs are expanded to the next multiple of 8. |
1282 </p> |
1318 </p> |
|
1319 |
1283 <div align="right"><a href="#top">Up</a></div> |
1320 <div align="right"><a href="#top">Up</a></div> |
1284 <hr /> |
1321 <hr /> |
1285 <hr /> |
1322 <hr /> |
1286 <a NAME="explicit_line_join" ID="explicit_line_join"></a> |
1323 <a NAME="explicit_line_join" ID="explicit_line_join"></a> |
1287 <h2>explicit_line_join</h2> |
1324 <h2>explicit_line_join</h2> |
1288 <b>explicit_line_join</b>(<i>logical_line, tokens</i>) |
1325 <b>explicit_line_join</b>(<i>logical_line, tokens</i>) |
1289 |
|
1290 <p> |
1326 <p> |
1291 Avoid explicit line join between brackets. |
1327 Avoid explicit line join between brackets. |
1292 </p> |
1328 </p> |
1293 <p> |
1329 <p> |
1294 The preferred way of wrapping long lines is by using Python's |
1330 The preferred way of wrapping long lines is by using Python's |
1334 <p> |
1370 <p> |
1335 E203: if x == 4: print x, y; x, y = y , x |
1371 E203: if x == 4: print x, y; x, y = y , x |
1336 E203: if x == 4: print x, y ; x, y = y, x |
1372 E203: if x == 4: print x, y ; x, y = y, x |
1337 E203: if x == 4 : print x, y; x, y = y, x |
1373 E203: if x == 4 : print x, y; x, y = y, x |
1338 </p> |
1374 </p> |
|
1375 |
1339 <div align="right"><a href="#top">Up</a></div> |
1376 <div align="right"><a href="#top">Up</a></div> |
1340 <hr /> |
1377 <hr /> |
1341 <hr /> |
1378 <hr /> |
1342 <a NAME="filename_match" ID="filename_match"></a> |
1379 <a NAME="filename_match" ID="filename_match"></a> |
1343 <h2>filename_match</h2> |
1380 <h2>filename_match</h2> |
1344 <b>filename_match</b>(<i>filename, patterns, default=True</i>) |
1381 <b>filename_match</b>(<i>filename, patterns, default=True</i>) |
1345 |
|
1346 <p> |
1382 <p> |
1347 Check if patterns contains a pattern that matches filename. |
1383 Check if patterns contains a pattern that matches filename. |
1348 </p> |
1384 </p> |
1349 <p> |
1385 <p> |
1350 If patterns is unspecified, this always returns True. |
1386 If patterns is unspecified, this always returns True. |
1351 </p> |
1387 </p> |
|
1388 |
1352 <div align="right"><a href="#top">Up</a></div> |
1389 <div align="right"><a href="#top">Up</a></div> |
1353 <hr /> |
1390 <hr /> |
1354 <hr /> |
1391 <hr /> |
1355 <a NAME="get_parser" ID="get_parser"></a> |
1392 <a NAME="get_parser" ID="get_parser"></a> |
1356 <h2>get_parser</h2> |
1393 <h2>get_parser</h2> |
1357 <b>get_parser</b>(<i>prog='pycodestyle', version=__version__</i>) |
1394 <b>get_parser</b>(<i>prog='pycodestyle', version=__version__</i>) |
1358 |
|
1359 <p> |
1395 <p> |
1360 Create the parser for the program. |
1396 Create the parser for the program. |
1361 </p> |
1397 </p> |
|
1398 |
1362 <div align="right"><a href="#top">Up</a></div> |
1399 <div align="right"><a href="#top">Up</a></div> |
1363 <hr /> |
1400 <hr /> |
1364 <hr /> |
1401 <hr /> |
1365 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a> |
1402 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a> |
1366 <h2>imports_on_separate_lines</h2> |
1403 <h2>imports_on_separate_lines</h2> |
1367 <b>imports_on_separate_lines</b>(<i>logical_line</i>) |
1404 <b>imports_on_separate_lines</b>(<i>logical_line</i>) |
1368 |
|
1369 <p> |
1405 <p> |
1370 Place imports on separate lines. |
1406 Place imports on separate lines. |
1371 </p> |
1407 </p> |
1372 <p> |
1408 <p> |
1373 Okay: import os\nimport sys |
1409 Okay: import os\nimport sys |
1421 <hr /> |
1458 <hr /> |
1422 <hr /> |
1459 <hr /> |
1423 <a NAME="maximum_doc_length" ID="maximum_doc_length"></a> |
1460 <a NAME="maximum_doc_length" ID="maximum_doc_length"></a> |
1424 <h2>maximum_doc_length</h2> |
1461 <h2>maximum_doc_length</h2> |
1425 <b>maximum_doc_length</b>(<i>logical_line, max_doc_length, noqa, tokens</i>) |
1462 <b>maximum_doc_length</b>(<i>logical_line, max_doc_length, noqa, tokens</i>) |
1426 |
|
1427 <p> |
1463 <p> |
1428 Limit all doc lines to a maximum of 72 characters. |
1464 Limit all doc lines to a maximum of 72 characters. |
1429 </p> |
1465 </p> |
1430 <p> |
1466 <p> |
1431 For flowing long blocks of text (docstrings or comments), limiting |
1467 For flowing long blocks of text (docstrings or comments), limiting |
1432 the length to 72 characters is recommended. |
1468 the length to 72 characters is recommended. |
1433 </p> |
1469 </p> |
1434 <p> |
1470 <p> |
1435 Reports warning W505 |
1471 Reports warning W505 |
1436 </p> |
1472 </p> |
|
1473 |
1437 <div align="right"><a href="#top">Up</a></div> |
1474 <div align="right"><a href="#top">Up</a></div> |
1438 <hr /> |
1475 <hr /> |
1439 <hr /> |
1476 <hr /> |
1440 <a NAME="maximum_line_length" ID="maximum_line_length"></a> |
1477 <a NAME="maximum_line_length" ID="maximum_line_length"></a> |
1441 <h2>maximum_line_length</h2> |
1478 <h2>maximum_line_length</h2> |
1442 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline, line_number, noqa</i>) |
1479 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline, line_number, noqa</i>) |
1443 |
|
1444 <p> |
1480 <p> |
1445 Limit all lines to a maximum of 79 characters. |
1481 Limit all lines to a maximum of 79 characters. |
1446 </p> |
1482 </p> |
1447 <p> |
1483 <p> |
1448 There are still many devices around that are limited to 80 character |
1484 There are still many devices around that are limited to 80 character |
1506 E228: msg = fmt%(errno, errmsg) |
1542 E228: msg = fmt%(errno, errmsg) |
1507 E231: ['a','b'] |
1543 E231: ['a','b'] |
1508 E231: foo(bar,baz) |
1544 E231: foo(bar,baz) |
1509 E231: [{'a':'b'}] |
1545 E231: [{'a':'b'}] |
1510 </p> |
1546 </p> |
|
1547 |
1511 <div align="right"><a href="#top">Up</a></div> |
1548 <div align="right"><a href="#top">Up</a></div> |
1512 <hr /> |
1549 <hr /> |
1513 <hr /> |
1550 <hr /> |
1514 <a NAME="missing_whitespace_after_keyword" ID="missing_whitespace_after_keyword"></a> |
1551 <a NAME="missing_whitespace_after_keyword" ID="missing_whitespace_after_keyword"></a> |
1515 <h2>missing_whitespace_after_keyword</h2> |
1552 <h2>missing_whitespace_after_keyword</h2> |
1516 <b>missing_whitespace_after_keyword</b>(<i>logical_line, tokens</i>) |
1553 <b>missing_whitespace_after_keyword</b>(<i>logical_line, tokens</i>) |
1517 |
|
1518 <p> |
1554 <p> |
1519 Keywords should be followed by whitespace. |
1555 Keywords should be followed by whitespace. |
1520 </p> |
1556 </p> |
1521 <p> |
1557 <p> |
1522 Okay: from foo import (bar, baz) |
1558 Okay: from foo import (bar, baz) |
1523 E275: from foo import(bar, baz) |
1559 E275: from foo import(bar, baz) |
1524 E275: from importable.module import(bar, baz) |
1560 E275: from importable.module import(bar, baz) |
1525 E275: if(foo): bar |
1561 E275: if(foo): bar |
1526 </p> |
1562 </p> |
|
1563 |
1527 <div align="right"><a href="#top">Up</a></div> |
1564 <div align="right"><a href="#top">Up</a></div> |
1528 <hr /> |
1565 <hr /> |
1529 <hr /> |
1566 <hr /> |
1530 <a NAME="module_imports_on_top_of_file" ID="module_imports_on_top_of_file"></a> |
1567 <a NAME="module_imports_on_top_of_file" ID="module_imports_on_top_of_file"></a> |
1531 <h2>module_imports_on_top_of_file</h2> |
1568 <h2>module_imports_on_top_of_file</h2> |
1532 <b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>) |
1569 <b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>) |
1533 |
|
1534 <p> |
1570 <p> |
1535 Place imports at the top of the file. |
1571 Place imports at the top of the file. |
1536 </p> |
1572 </p> |
1537 <p> |
1573 <p> |
1538 Always put imports at the top of the file, just after any module |
1574 Always put imports at the top of the file, just after any module |
1548 E402: a=1\nfrom sys import x |
1584 E402: a=1\nfrom sys import x |
1549 </p> |
1585 </p> |
1550 <p> |
1586 <p> |
1551 Okay: if x:\n import os |
1587 Okay: if x:\n import os |
1552 </p> |
1588 </p> |
|
1589 |
1553 <div align="right"><a href="#top">Up</a></div> |
1590 <div align="right"><a href="#top">Up</a></div> |
1554 <hr /> |
1591 <hr /> |
1555 <hr /> |
1592 <hr /> |
1556 <a NAME="mute_string" ID="mute_string"></a> |
1593 <a NAME="mute_string" ID="mute_string"></a> |
1557 <h2>mute_string</h2> |
1594 <h2>mute_string</h2> |
1558 <b>mute_string</b>(<i>text</i>) |
1595 <b>mute_string</b>(<i>text</i>) |
1559 |
|
1560 <p> |
1596 <p> |
1561 Replace contents with 'xxx' to prevent syntax matching. |
1597 Replace contents with 'xxx' to prevent syntax matching. |
1562 </p> |
1598 </p> |
|
1599 |
1563 <div align="right"><a href="#top">Up</a></div> |
1600 <div align="right"><a href="#top">Up</a></div> |
1564 <hr /> |
1601 <hr /> |
1565 <hr /> |
1602 <hr /> |
1566 <a NAME="normalize_paths" ID="normalize_paths"></a> |
1603 <a NAME="normalize_paths" ID="normalize_paths"></a> |
1567 <h2>normalize_paths</h2> |
1604 <h2>normalize_paths</h2> |
1568 <b>normalize_paths</b>(<i>value, parent=os.curdir</i>) |
1605 <b>normalize_paths</b>(<i>value, parent=os.curdir</i>) |
1569 |
|
1570 <p> |
1606 <p> |
1571 Parse a comma-separated list of paths. |
1607 Parse a comma-separated list of paths. |
1572 </p> |
1608 </p> |
1573 <p> |
1609 <p> |
1574 Return a list of absolute paths. |
1610 Return a list of absolute paths. |
1575 </p> |
1611 </p> |
|
1612 |
1576 <div align="right"><a href="#top">Up</a></div> |
1613 <div align="right"><a href="#top">Up</a></div> |
1577 <hr /> |
1614 <hr /> |
1578 <hr /> |
1615 <hr /> |
1579 <a NAME="parse_udiff" ID="parse_udiff"></a> |
1616 <a NAME="parse_udiff" ID="parse_udiff"></a> |
1580 <h2>parse_udiff</h2> |
1617 <h2>parse_udiff</h2> |
1581 <b>parse_udiff</b>(<i>diff, patterns=None, parent='.'</i>) |
1618 <b>parse_udiff</b>(<i>diff, patterns=None, parent='.'</i>) |
1582 |
|
1583 <p> |
1619 <p> |
1584 Return a dictionary of matching lines. |
1620 Return a dictionary of matching lines. |
1585 </p> |
1621 </p> |
|
1622 |
1586 <div align="right"><a href="#top">Up</a></div> |
1623 <div align="right"><a href="#top">Up</a></div> |
1587 <hr /> |
1624 <hr /> |
1588 <hr /> |
1625 <hr /> |
1589 <a NAME="process_options" ID="process_options"></a> |
1626 <a NAME="process_options" ID="process_options"></a> |
1590 <h2>process_options</h2> |
1627 <h2>process_options</h2> |
1591 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None</i>) |
1628 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None</i>) |
1592 |
|
1593 <p> |
1629 <p> |
1594 Process options passed either via arglist or command line args. |
1630 Process options passed either via arglist or command line args. |
1595 </p> |
1631 </p> |
1596 <p> |
1632 <p> |
1597 Passing in the ``config_file`` parameter allows other tools, such as |
1633 Passing in the ``config_file`` parameter allows other tools, such as |
1598 flake8 to specify their own options to be processed in pycodestyle. |
1634 flake8 to specify their own options to be processed in pycodestyle. |
1599 </p> |
1635 </p> |
|
1636 |
1600 <div align="right"><a href="#top">Up</a></div> |
1637 <div align="right"><a href="#top">Up</a></div> |
1601 <hr /> |
1638 <hr /> |
1602 <hr /> |
1639 <hr /> |
1603 <a NAME="python_3000_invalid_escape_sequence" ID="python_3000_invalid_escape_sequence"></a> |
1640 <a NAME="python_3000_invalid_escape_sequence" ID="python_3000_invalid_escape_sequence"></a> |
1604 <h2>python_3000_invalid_escape_sequence</h2> |
1641 <h2>python_3000_invalid_escape_sequence</h2> |
1605 <b>python_3000_invalid_escape_sequence</b>(<i>logical_line, tokens, noqa</i>) |
1642 <b>python_3000_invalid_escape_sequence</b>(<i>logical_line, tokens, noqa</i>) |
1606 |
|
1607 <p> |
1643 <p> |
1608 Invalid escape sequences are deprecated in Python 3.6. |
1644 Invalid escape sequences are deprecated in Python 3.6. |
1609 </p> |
1645 </p> |
1610 <p> |
1646 <p> |
1611 Okay: regex = r'\.png$' |
1647 Okay: regex = r'\.png$' |
1612 W605: regex = '\.png$' |
1648 W605: regex = '\.png$' |
1613 </p> |
1649 </p> |
|
1650 |
1614 <div align="right"><a href="#top">Up</a></div> |
1651 <div align="right"><a href="#top">Up</a></div> |
1615 <hr /> |
1652 <hr /> |
1616 <hr /> |
1653 <hr /> |
1617 <a NAME="read_config" ID="read_config"></a> |
1654 <a NAME="read_config" ID="read_config"></a> |
1618 <h2>read_config</h2> |
1655 <h2>read_config</h2> |
1619 <b>read_config</b>(<i>options, args, arglist, parser</i>) |
1656 <b>read_config</b>(<i>options, args, arglist, parser</i>) |
1620 |
|
1621 <p> |
1657 <p> |
1622 Read and parse configurations. |
1658 Read and parse configurations. |
1623 </p> |
1659 </p> |
1624 <p> |
1660 <p> |
1625 If a config file is specified on the command line with the |
1661 If a config file is specified on the command line with the |
1629 Otherwise, the user configuration (~/.config/pycodestyle) and any |
1665 Otherwise, the user configuration (~/.config/pycodestyle) and any |
1630 local configurations in the current directory or above will be |
1666 local configurations in the current directory or above will be |
1631 merged together (in that order) using the read method of |
1667 merged together (in that order) using the read method of |
1632 ConfigParser. |
1668 ConfigParser. |
1633 </p> |
1669 </p> |
|
1670 |
1634 <div align="right"><a href="#top">Up</a></div> |
1671 <div align="right"><a href="#top">Up</a></div> |
1635 <hr /> |
1672 <hr /> |
1636 <hr /> |
1673 <hr /> |
1637 <a NAME="readlines" ID="readlines"></a> |
1674 <a NAME="readlines" ID="readlines"></a> |
1638 <h2>readlines</h2> |
1675 <h2>readlines</h2> |
1639 <b>readlines</b>(<i>filename</i>) |
1676 <b>readlines</b>(<i>filename</i>) |
1640 |
|
1641 <p> |
1677 <p> |
1642 Read the source code. |
1678 Read the source code. |
1643 </p> |
1679 </p> |
|
1680 |
1644 <div align="right"><a href="#top">Up</a></div> |
1681 <div align="right"><a href="#top">Up</a></div> |
1645 <hr /> |
1682 <hr /> |
1646 <hr /> |
1683 <hr /> |
1647 <a NAME="register_check" ID="register_check"></a> |
1684 <a NAME="register_check" ID="register_check"></a> |
1648 <h2>register_check</h2> |
1685 <h2>register_check</h2> |
1649 <b>register_check</b>(<i>check, codes=None</i>) |
1686 <b>register_check</b>(<i>check, codes=None</i>) |
1650 |
|
1651 <p> |
1687 <p> |
1652 Register a new check object. |
1688 Register a new check object. |
1653 </p> |
1689 </p> |
|
1690 |
1654 <div align="right"><a href="#top">Up</a></div> |
1691 <div align="right"><a href="#top">Up</a></div> |
1655 <hr /> |
1692 <hr /> |
1656 <hr /> |
1693 <hr /> |
1657 <a NAME="stdin_get_value" ID="stdin_get_value"></a> |
1694 <a NAME="stdin_get_value" ID="stdin_get_value"></a> |
1658 <h2>stdin_get_value</h2> |
1695 <h2>stdin_get_value</h2> |
1659 <b>stdin_get_value</b>(<i></i>) |
1696 <b>stdin_get_value</b>(<i></i>) |
1660 |
|
1661 <p> |
1697 <p> |
1662 Read the value from stdin. |
1698 Read the value from stdin. |
1663 </p> |
1699 </p> |
|
1700 |
1664 <div align="right"><a href="#top">Up</a></div> |
1701 <div align="right"><a href="#top">Up</a></div> |
1665 <hr /> |
1702 <hr /> |
1666 <hr /> |
1703 <hr /> |
1667 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a> |
1704 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a> |
1668 <h2>tabs_obsolete</h2> |
1705 <h2>tabs_obsolete</h2> |
1669 <b>tabs_obsolete</b>(<i>physical_line</i>) |
1706 <b>tabs_obsolete</b>(<i>physical_line</i>) |
1670 |
|
1671 <p> |
1707 <p> |
1672 On new projects, spaces-only are strongly recommended over tabs. |
1708 On new projects, spaces-only are strongly recommended over tabs. |
1673 </p> |
1709 </p> |
1674 <p> |
1710 <p> |
1675 Okay: if True:\n return |
1711 Okay: if True:\n return |
1676 W191: if True:\n\treturn |
1712 W191: if True:\n\treturn |
1677 </p> |
1713 </p> |
|
1714 |
1678 <div align="right"><a href="#top">Up</a></div> |
1715 <div align="right"><a href="#top">Up</a></div> |
1679 <hr /> |
1716 <hr /> |
1680 <hr /> |
1717 <hr /> |
1681 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a> |
1718 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a> |
1682 <h2>tabs_or_spaces</h2> |
1719 <h2>tabs_or_spaces</h2> |
1683 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>) |
1720 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>) |
1684 |
|
1685 <p> |
1721 <p> |
1686 Never mix tabs and spaces. |
1722 Never mix tabs and spaces. |
1687 </p> |
1723 </p> |
1688 <p> |
1724 <p> |
1689 The most popular way of indenting Python is with spaces only. The |
1725 The most popular way of indenting Python is with spaces only. The |
1695 These options are highly recommended! |
1731 These options are highly recommended! |
1696 </p> |
1732 </p> |
1697 <p> |
1733 <p> |
1698 Okay: if a == 0:\n a = 1\n b = 1 |
1734 Okay: if a == 0:\n a = 1\n b = 1 |
1699 </p> |
1735 </p> |
|
1736 |
1700 <div align="right"><a href="#top">Up</a></div> |
1737 <div align="right"><a href="#top">Up</a></div> |
1701 <hr /> |
1738 <hr /> |
1702 <hr /> |
1739 <hr /> |
1703 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a> |
1740 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a> |
1704 <h2>trailing_blank_lines</h2> |
1741 <h2>trailing_blank_lines</h2> |
1705 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number, total_lines</i>) |
1742 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number, total_lines</i>) |
1706 |
|
1707 <p> |
1743 <p> |
1708 Trailing blank lines are superfluous. |
1744 Trailing blank lines are superfluous. |
1709 </p> |
1745 </p> |
1710 <p> |
1746 <p> |
1711 Okay: spam(1) |
1747 Okay: spam(1) |
1712 W391: spam(1)\n |
1748 W391: spam(1)\n |
1713 </p> |
1749 </p> |
1714 <p> |
1750 <p> |
1715 However the last line should end with a new line (warning W292). |
1751 However the last line should end with a new line (warning W292). |
1716 </p> |
1752 </p> |
|
1753 |
1717 <div align="right"><a href="#top">Up</a></div> |
1754 <div align="right"><a href="#top">Up</a></div> |
1718 <hr /> |
1755 <hr /> |
1719 <hr /> |
1756 <hr /> |
1720 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a> |
1757 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a> |
1721 <h2>trailing_whitespace</h2> |
1758 <h2>trailing_whitespace</h2> |
1722 <b>trailing_whitespace</b>(<i>physical_line</i>) |
1759 <b>trailing_whitespace</b>(<i>physical_line</i>) |
1723 |
|
1724 <p> |
1760 <p> |
1725 Trailing whitespace is superfluous. |
1761 Trailing whitespace is superfluous. |
1726 </p> |
1762 </p> |
1727 <p> |
1763 <p> |
1728 The warning returned varies on whether the line itself is blank, |
1764 The warning returned varies on whether the line itself is blank, |
1760 <p> |
1796 <p> |
1761 Okay: a = (1, 2) |
1797 Okay: a = (1, 2) |
1762 E241: a = (1, 2) |
1798 E241: a = (1, 2) |
1763 E242: a = (1,\t2) |
1799 E242: a = (1,\t2) |
1764 </p> |
1800 </p> |
|
1801 |
1765 <div align="right"><a href="#top">Up</a></div> |
1802 <div align="right"><a href="#top">Up</a></div> |
1766 <hr /> |
1803 <hr /> |
1767 <hr /> |
1804 <hr /> |
1768 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a> |
1805 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a> |
1769 <h2>whitespace_around_keywords</h2> |
1806 <h2>whitespace_around_keywords</h2> |
1770 <b>whitespace_around_keywords</b>(<i>logical_line</i>) |
1807 <b>whitespace_around_keywords</b>(<i>logical_line</i>) |
1771 |
|
1772 <p> |
1808 <p> |
1773 Avoid extraneous whitespace around keywords. |
1809 Avoid extraneous whitespace around keywords. |
1774 </p> |
1810 </p> |
1775 <p> |
1811 <p> |
1776 Okay: True and False |
1812 Okay: True and False |
1777 E271: True and False |
1813 E271: True and False |
1778 E272: True and False |
1814 E272: True and False |
1779 E273: True and\tFalse |
1815 E273: True and\tFalse |
1780 E274: True\tand False |
1816 E274: True\tand False |
1781 </p> |
1817 </p> |
|
1818 |
1782 <div align="right"><a href="#top">Up</a></div> |
1819 <div align="right"><a href="#top">Up</a></div> |
1783 <hr /> |
1820 <hr /> |
1784 <hr /> |
1821 <hr /> |
1785 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a> |
1822 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a> |
1786 <h2>whitespace_around_named_parameter_equals</h2> |
1823 <h2>whitespace_around_named_parameter_equals</h2> |
1787 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>) |
1824 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>) |
1788 |
|
1789 <p> |
1825 <p> |
1790 Don't use spaces around the '=' sign in function arguments. |
1826 Don't use spaces around the '=' sign in function arguments. |
1791 </p> |
1827 </p> |
1792 <p> |
1828 <p> |
1793 Don't use spaces around the '=' sign when used to indicate a |
1829 Don't use spaces around the '=' sign when used to indicate a |
1807 <p> |
1843 <p> |
1808 E251: def complex(real, imag = 0.0): |
1844 E251: def complex(real, imag = 0.0): |
1809 E251: return magic(r = real, i = imag) |
1845 E251: return magic(r = real, i = imag) |
1810 E252: def complex(real, image: float=0.0): |
1846 E252: def complex(real, image: float=0.0): |
1811 </p> |
1847 </p> |
|
1848 |
1812 <div align="right"><a href="#top">Up</a></div> |
1849 <div align="right"><a href="#top">Up</a></div> |
1813 <hr /> |
1850 <hr /> |
1814 <hr /> |
1851 <hr /> |
1815 <a NAME="whitespace_around_operator" ID="whitespace_around_operator"></a> |
1852 <a NAME="whitespace_around_operator" ID="whitespace_around_operator"></a> |
1816 <h2>whitespace_around_operator</h2> |
1853 <h2>whitespace_around_operator</h2> |
1817 <b>whitespace_around_operator</b>(<i>logical_line</i>) |
1854 <b>whitespace_around_operator</b>(<i>logical_line</i>) |
1818 |
|
1819 <p> |
1855 <p> |
1820 Avoid extraneous whitespace around an operator. |
1856 Avoid extraneous whitespace around an operator. |
1821 </p> |
1857 </p> |
1822 <p> |
1858 <p> |
1823 Okay: a = 12 + 3 |
1859 Okay: a = 12 + 3 |
1824 E221: a = 4 + 5 |
1860 E221: a = 4 + 5 |
1825 E222: a = 4 + 5 |
1861 E222: a = 4 + 5 |
1826 E223: a = 4\t+ 5 |
1862 E223: a = 4\t+ 5 |
1827 E224: a = 4 +\t5 |
1863 E224: a = 4 +\t5 |
1828 </p> |
1864 </p> |
|
1865 |
1829 <div align="right"><a href="#top">Up</a></div> |
1866 <div align="right"><a href="#top">Up</a></div> |
1830 <hr /> |
1867 <hr /> |
1831 <hr /> |
1868 <hr /> |
1832 <a NAME="whitespace_before_comment" ID="whitespace_before_comment"></a> |
1869 <a NAME="whitespace_before_comment" ID="whitespace_before_comment"></a> |
1833 <h2>whitespace_before_comment</h2> |
1870 <h2>whitespace_before_comment</h2> |
1834 <b>whitespace_before_comment</b>(<i>logical_line, tokens</i>) |
1871 <b>whitespace_before_comment</b>(<i>logical_line, tokens</i>) |
1835 |
|
1836 <p> |
1872 <p> |
1837 Separate inline comments by at least two spaces. |
1873 Separate inline comments by at least two spaces. |
1838 </p> |
1874 </p> |
1839 <p> |
1875 <p> |
1840 An inline comment is a comment on the same line as a statement. |
1876 An inline comment is a comment on the same line as a statement. |