51 <table> |
51 <table> |
52 <tr> |
52 <tr> |
53 <td><a href="#_add_check">_add_check</a></td> |
53 <td><a href="#_add_check">_add_check</a></td> |
54 <td></td> |
54 <td></td> |
55 </tr><tr> |
55 </tr><tr> |
|
56 <td><a href="#_get_parameters">_get_parameters</a></td> |
|
57 <td></td> |
|
58 </tr><tr> |
56 <td><a href="#_is_eol_token">_is_eol_token</a></td> |
59 <td><a href="#_is_eol_token">_is_eol_token</a></td> |
57 <td></td> |
60 <td></td> |
58 </tr><tr> |
61 </tr><tr> |
59 <td><a href="#_is_eol_token_1">_is_eol_token</a></td> |
62 <td><a href="#_is_eol_token_1">_is_eol_token</a></td> |
60 <td></td> |
63 <td></td> |
61 </tr><tr> |
64 </tr><tr> |
62 <td><a href="#_main">_main</a></td> |
65 <td><a href="#_main">_main</a></td> |
63 <td>Parse options and run checks on Python source.</td> |
66 <td>Parse options and run checks on Python source.</td> |
64 </tr><tr> |
67 </tr><tr> |
|
68 <td><a href="#_parse_multi_options">_parse_multi_options</a></td> |
|
69 <td>Split and strip and discard empties.</td> |
|
70 </tr><tr> |
65 <td><a href="#blank_lines">blank_lines</a></td> |
71 <td><a href="#blank_lines">blank_lines</a></td> |
66 <td>Separate top-level function and class definitions with two blank lines.</td> |
72 <td>Separate top-level function and class definitions with two blank lines.</td> |
67 </tr><tr> |
73 </tr><tr> |
|
74 <td><a href="#break_around_binary_operator">break_around_binary_operator</a></td> |
|
75 <td>Avoid breaks before binary operators.</td> |
|
76 </tr><tr> |
68 <td><a href="#comparison_negative">comparison_negative</a></td> |
77 <td><a href="#comparison_negative">comparison_negative</a></td> |
69 <td>Negative comparison should be done using "not in" and "is not".</td> |
78 <td>Negative comparison should be done using "not in" and "is not".</td> |
70 </tr><tr> |
79 </tr><tr> |
71 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td> |
80 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td> |
72 <td>Comparison to singletons should use "is" or "is not".</td> |
81 <td>Comparison to singletons should use "is" or "is not".</td> |
102 <td>Use 4 spaces per indentation level.</td> |
111 <td>Use 4 spaces per indentation level.</td> |
103 </tr><tr> |
112 </tr><tr> |
104 <td><a href="#init_checks_registry">init_checks_registry</a></td> |
113 <td><a href="#init_checks_registry">init_checks_registry</a></td> |
105 <td>Register all globally visible functions.</td> |
114 <td>Register all globally visible functions.</td> |
106 </tr><tr> |
115 </tr><tr> |
|
116 <td><a href="#is_binary_operator">is_binary_operator</a></td> |
|
117 <td></td> |
|
118 </tr><tr> |
|
119 <td><a href="#is_string_literal">is_string_literal</a></td> |
|
120 <td></td> |
|
121 </tr><tr> |
107 <td><a href="#maximum_line_length">maximum_line_length</a></td> |
122 <td><a href="#maximum_line_length">maximum_line_length</a></td> |
108 <td>Limit all lines to a maximum of 79 characters.</td> |
123 <td>Limit all lines to a maximum of 79 characters.</td> |
109 </tr><tr> |
124 </tr><tr> |
110 <td><a href="#missing_whitespace">missing_whitespace</a></td> |
125 <td><a href="#missing_whitespace">missing_whitespace</a></td> |
111 <td>Each comma, semicolon or colon should be followed by whitespace.</td> |
126 <td>Each comma, semicolon or colon should be followed by whitespace.</td> |
112 </tr><tr> |
127 </tr><tr> |
113 <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td> |
128 <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> |
129 <td>Surround operators with a single space on either side.</td> |
115 </tr><tr> |
130 </tr><tr> |
|
131 <td><a href="#module_imports_on_top_of_file">module_imports_on_top_of_file</a></td> |
|
132 <td>Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.</td> |
|
133 </tr><tr> |
116 <td><a href="#mute_string">mute_string</a></td> |
134 <td><a href="#mute_string">mute_string</a></td> |
117 <td>Replace contents with 'xxx' to prevent syntax matching.</td> |
135 <td>Replace contents with 'xxx' to prevent syntax matching.</td> |
118 </tr><tr> |
136 </tr><tr> |
119 <td><a href="#normalize_paths">normalize_paths</a></td> |
137 <td><a href="#normalize_paths">normalize_paths</a></td> |
120 <td>Parse a comma-separated list of paths.</td> |
138 <td>Parse a comma-separated list of paths.</td> |
136 </tr><tr> |
154 </tr><tr> |
137 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td> |
155 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td> |
138 <td>When raising an exception, use "raise ValueError('message')".</td> |
156 <td>When raising an exception, use "raise ValueError('message')".</td> |
139 </tr><tr> |
157 </tr><tr> |
140 <td><a href="#read_config">read_config</a></td> |
158 <td><a href="#read_config">read_config</a></td> |
141 <td>Read both user configuration and local configuration.</td> |
159 <td>Read and parse configurations</td> |
142 </tr><tr> |
160 </tr><tr> |
143 <td><a href="#readlines">readlines</a></td> |
161 <td><a href="#readlines">readlines</a></td> |
144 <td>Read the source code.</td> |
162 <td>Read the source code.</td> |
145 </tr><tr> |
163 </tr><tr> |
146 <td><a href="#readlines_1">readlines</a></td> |
164 <td><a href="#readlines_1">readlines</a></td> |
346 <td>Run all physical checks on a raw input line.</td> |
364 <td>Run all physical checks on a raw input line.</td> |
347 </tr><tr> |
365 </tr><tr> |
348 <td><a href="#Checker.generate_tokens">generate_tokens</a></td> |
366 <td><a href="#Checker.generate_tokens">generate_tokens</a></td> |
349 <td>Tokenize the file, run physical line checks and yield tokens.</td> |
367 <td>Tokenize the file, run physical line checks and yield tokens.</td> |
350 </tr><tr> |
368 </tr><tr> |
|
369 <td><a href="#Checker.init_checker_state">init_checker_state</a></td> |
|
370 <td>Prepares a custom state for the specific checker plugin.</td> |
|
371 </tr><tr> |
351 <td><a href="#Checker.maybe_check_physical">maybe_check_physical</a></td> |
372 <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> |
373 <td>If appropriate (based on token), check current physical line(s).</td> |
353 </tr><tr> |
374 </tr><tr> |
354 <td><a href="#Checker.readline">readline</a></td> |
375 <td><a href="#Checker.readline">readline</a></td> |
355 <td>Get the next line from the input buffer.</td> |
376 <td>Get the next line from the input buffer.</td> |
396 </p><a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a> |
417 </p><a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a> |
397 <h4>Checker.generate_tokens</h4> |
418 <h4>Checker.generate_tokens</h4> |
398 <b>generate_tokens</b>(<i></i>) |
419 <b>generate_tokens</b>(<i></i>) |
399 <p> |
420 <p> |
400 Tokenize the file, run physical line checks and yield tokens. |
421 Tokenize the file, run physical line checks and yield tokens. |
|
422 </p><a NAME="Checker.init_checker_state" ID="Checker.init_checker_state"></a> |
|
423 <h4>Checker.init_checker_state</h4> |
|
424 <b>init_checker_state</b>(<i>name, argument_names</i>) |
|
425 <p> |
|
426 Prepares a custom state for the specific checker plugin. |
401 </p><a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a> |
427 </p><a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a> |
402 <h4>Checker.maybe_check_physical</h4> |
428 <h4>Checker.maybe_check_physical</h4> |
403 <b>maybe_check_physical</b>(<i>token</i>) |
429 <b>maybe_check_physical</b>(<i>token</i>) |
404 <p> |
430 <p> |
405 If appropriate (based on token), check current physical line(s). |
431 If appropriate (based on token), check current physical line(s). |
650 <h2>_add_check</h2> |
676 <h2>_add_check</h2> |
651 <b>_add_check</b>(<i>check, kind, codes, args</i>) |
677 <b>_add_check</b>(<i>check, kind, codes, args</i>) |
652 |
678 |
653 <div align="right"><a href="#top">Up</a></div> |
679 <div align="right"><a href="#top">Up</a></div> |
654 <hr /><hr /> |
680 <hr /><hr /> |
|
681 <a NAME="_get_parameters" ID="_get_parameters"></a> |
|
682 <h2>_get_parameters</h2> |
|
683 <b>_get_parameters</b>(<i>function</i>) |
|
684 |
|
685 <div align="right"><a href="#top">Up</a></div> |
|
686 <hr /><hr /> |
655 <a NAME="_is_eol_token" ID="_is_eol_token"></a> |
687 <a NAME="_is_eol_token" ID="_is_eol_token"></a> |
656 <h2>_is_eol_token</h2> |
688 <h2>_is_eol_token</h2> |
657 <b>_is_eol_token</b>(<i>token</i>) |
689 <b>_is_eol_token</b>(<i>token</i>) |
658 |
690 |
659 <div align="right"><a href="#top">Up</a></div> |
691 <div align="right"><a href="#top">Up</a></div> |
660 <hr /><hr /> |
692 <hr /><hr /> |
661 <a NAME="_is_eol_token_1" ID="_is_eol_token_1"></a> |
693 <a NAME="_is_eol_token_1" ID="_is_eol_token_1"></a> |
662 <h2>_is_eol_token</h2> |
694 <h2>_is_eol_token</h2> |
663 <b>_is_eol_token</b>(<i>token</i>) |
695 <b>_is_eol_token</b>(<i>token, _eol_token=_is_eol_token</i>) |
664 |
696 |
665 <div align="right"><a href="#top">Up</a></div> |
697 <div align="right"><a href="#top">Up</a></div> |
666 <hr /><hr /> |
698 <hr /><hr /> |
667 <a NAME="_main" ID="_main"></a> |
699 <a NAME="_main" ID="_main"></a> |
668 <h2>_main</h2> |
700 <h2>_main</h2> |
669 <b>_main</b>(<i></i>) |
701 <b>_main</b>(<i></i>) |
670 <p> |
702 <p> |
671 Parse options and run checks on Python source. |
703 Parse options and run checks on Python source. |
|
704 </p> |
|
705 <div align="right"><a href="#top">Up</a></div> |
|
706 <hr /><hr /> |
|
707 <a NAME="_parse_multi_options" ID="_parse_multi_options"></a> |
|
708 <h2>_parse_multi_options</h2> |
|
709 <b>_parse_multi_options</b>(<i>options, split_token=', '</i>) |
|
710 <p> |
|
711 Split and strip and discard empties. |
|
712 </p><p> |
|
713 Turns the following: |
|
714 </p><p> |
|
715 A, |
|
716 B, |
|
717 </p><p> |
|
718 into ["A", "B"] |
672 </p> |
719 </p> |
673 <div align="right"><a href="#top">Up</a></div> |
720 <div align="right"><a href="#top">Up</a></div> |
674 <hr /><hr /> |
721 <hr /><hr /> |
675 <a NAME="blank_lines" ID="blank_lines"></a> |
722 <a NAME="blank_lines" ID="blank_lines"></a> |
676 <h2>blank_lines</h2> |
723 <h2>blank_lines</h2> |
692 E301: class Foo:\n b = 0\n def bar():\n pass |
739 E301: class Foo:\n b = 0\n def bar():\n pass |
693 E302: def a():\n pass\n\ndef b(n):\n pass |
740 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 |
741 E303: def a():\n pass\n\n\n\ndef b(n):\n pass |
695 E303: def a():\n\n\n\n pass |
742 E303: def a():\n\n\n\n pass |
696 E304: @decorator\n\ndef a():\n pass |
743 E304: @decorator\n\ndef a():\n pass |
|
744 </p> |
|
745 <div align="right"><a href="#top">Up</a></div> |
|
746 <hr /><hr /> |
|
747 <a NAME="break_around_binary_operator" ID="break_around_binary_operator"></a> |
|
748 <h2>break_around_binary_operator</h2> |
|
749 <b>break_around_binary_operator</b>(<i>logical_line, tokens</i>) |
|
750 <p> |
|
751 Avoid breaks before binary operators. |
|
752 </p><p> |
|
753 The preferred place to break around a binary operator is after the |
|
754 operator, not before it. |
|
755 </p><p> |
|
756 W503: (width == 0\n + height == 0) |
|
757 W503: (width == 0\n and height == 0) |
|
758 </p><p> |
|
759 Okay: (width == 0 +\n height == 0) |
|
760 Okay: foo(\n -x) |
|
761 Okay: foo(x\n []) |
|
762 Okay: x = '''\n''' + '' |
|
763 Okay: foo(x,\n -y) |
|
764 Okay: foo(x, # comment\n -y) |
697 </p> |
765 </p> |
698 <div align="right"><a href="#top">Up</a></div> |
766 <div align="right"><a href="#top">Up</a></div> |
699 <hr /><hr /> |
767 <hr /><hr /> |
700 <a NAME="comparison_negative" ID="comparison_negative"></a> |
768 <a NAME="comparison_negative" ID="comparison_negative"></a> |
701 <h2>comparison_negative</h2> |
769 <h2>comparison_negative</h2> |
723 Comparisons to singletons like None should always be done |
791 Comparisons to singletons like None should always be done |
724 with "is" or "is not", never the equality operators. |
792 with "is" or "is not", never the equality operators. |
725 </p><p> |
793 </p><p> |
726 Okay: if arg is not None: |
794 Okay: if arg is not None: |
727 E711: if arg != None: |
795 E711: if arg != None: |
|
796 E711: if None == arg: |
728 E712: if arg == True: |
797 E712: if arg == True: |
|
798 E712: if False == arg: |
729 </p><p> |
799 </p><p> |
730 Also, beware of writing if x when you really mean if x is not None -- |
800 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 |
801 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 |
802 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! |
803 container) that could be false in a boolean context! |
734 </p> |
804 </p> |
735 <div align="right"><a href="#top">Up</a></div> |
805 <div align="right"><a href="#top">Up</a></div> |
736 <hr /><hr /> |
806 <hr /><hr /> |
737 <a NAME="comparison_type" ID="comparison_type"></a> |
807 <a NAME="comparison_type" ID="comparison_type"></a> |
738 <h2>comparison_type</h2> |
808 <h2>comparison_type</h2> |
739 <b>comparison_type</b>(<i>logical_line</i>) |
809 <b>comparison_type</b>(<i>logical_line, noqa</i>) |
740 <p> |
810 <p> |
741 Object type comparisons should always use isinstance(). |
811 Object type comparisons should always use isinstance(). |
742 </p><p> |
812 </p><p> |
743 Do not compare types directly. |
813 Do not compare types directly. |
744 </p><p> |
814 </p><p> |
761 Compound statements (on the same line) are generally discouraged. |
831 Compound statements (on the same line) are generally discouraged. |
762 </p><p> |
832 </p><p> |
763 While sometimes it's okay to put an if/for/while with a small body |
833 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. |
834 on the same line, never do this for multi-clause statements. |
765 Also avoid folding such long lines! |
835 Also avoid folding such long lines! |
|
836 </p><p> |
|
837 Always use a def statement instead of an assignment statement that |
|
838 binds a lambda expression directly to a name. |
766 </p><p> |
839 </p><p> |
767 Okay: if foo == 'blah':\n do_blah_thing() |
840 Okay: if foo == 'blah':\n do_blah_thing() |
768 Okay: do_one() |
841 Okay: do_one() |
769 Okay: do_two() |
842 Okay: do_two() |
770 Okay: do_three() |
843 Okay: do_three() |
775 E701: if foo == 'blah': do_blah_thing() |
848 E701: if foo == 'blah': do_blah_thing() |
776 E701: else: do_non_blah_thing() |
849 E701: else: do_non_blah_thing() |
777 E701: try: something() |
850 E701: try: something() |
778 E701: finally: cleanup() |
851 E701: finally: cleanup() |
779 E701: if foo == 'blah': one(); two(); three() |
852 E701: if foo == 'blah': one(); two(); three() |
780 </p><p> |
|
781 E702: do_one(); do_two(); do_three() |
853 E702: do_one(); do_two(); do_three() |
782 E703: do_four(); # useless semicolon |
854 E703: do_four(); # useless semicolon |
|
855 E704: def f(x): return 2*x |
|
856 E731: f = lambda x: 2*x |
783 </p> |
857 </p> |
784 <div align="right"><a href="#top">Up</a></div> |
858 <div align="right"><a href="#top">Up</a></div> |
785 <hr /><hr /> |
859 <hr /><hr /> |
786 <a NAME="continued_indentation" ID="continued_indentation"></a> |
860 <a NAME="continued_indentation" ID="continued_indentation"></a> |
787 <h2>continued_indentation</h2> |
861 <h2>continued_indentation</h2> |
849 E502: aaa = ("bbb " \\n "ccc") |
923 E502: aaa = ("bbb " \\n "ccc") |
850 </p><p> |
924 </p><p> |
851 Okay: aaa = [123,\n 123] |
925 Okay: aaa = [123,\n 123] |
852 Okay: aaa = ("bbb "\n "ccc") |
926 Okay: aaa = ("bbb "\n "ccc") |
853 Okay: aaa = "bbb " \\n "ccc" |
927 Okay: aaa = "bbb " \\n "ccc" |
|
928 Okay: aaa = 123 # \\ |
854 </p> |
929 </p> |
855 <div align="right"><a href="#top">Up</a></div> |
930 <div align="right"><a href="#top">Up</a></div> |
856 <hr /><hr /> |
931 <hr /><hr /> |
857 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a> |
932 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a> |
858 <h2>extraneous_whitespace</h2> |
933 <h2>extraneous_whitespace</h2> |
921 use 8-space tabs. |
996 use 8-space tabs. |
922 </p><p> |
997 </p><p> |
923 Okay: a = 1 |
998 Okay: a = 1 |
924 Okay: if a == 0:\n a = 1 |
999 Okay: if a == 0:\n a = 1 |
925 E111: a = 1 |
1000 E111: a = 1 |
|
1001 E114: # a = 1 |
926 </p><p> |
1002 </p><p> |
927 Okay: for item in items:\n pass |
1003 Okay: for item in items:\n pass |
928 E112: for item in items:\npass |
1004 E112: for item in items:\npass |
|
1005 E115: for item in items:\n# Hi\n pass |
929 </p><p> |
1006 </p><p> |
930 Okay: a = 1\nb = 2 |
1007 Okay: a = 1\nb = 2 |
931 E113: a = 1\n b = 2 |
1008 E113: a = 1\n b = 2 |
|
1009 E116: a = 1\n # b = 2 |
932 </p> |
1010 </p> |
933 <div align="right"><a href="#top">Up</a></div> |
1011 <div align="right"><a href="#top">Up</a></div> |
934 <hr /><hr /> |
1012 <hr /><hr /> |
935 <a NAME="init_checks_registry" ID="init_checks_registry"></a> |
1013 <a NAME="init_checks_registry" ID="init_checks_registry"></a> |
936 <h2>init_checks_registry</h2> |
1014 <h2>init_checks_registry</h2> |
938 <p> |
1016 <p> |
939 Register all globally visible functions. |
1017 Register all globally visible functions. |
940 </p><p> |
1018 </p><p> |
941 The first argument name is either 'physical_line' or 'logical_line'. |
1019 The first argument name is either 'physical_line' or 'logical_line'. |
942 </p> |
1020 </p> |
|
1021 <div align="right"><a href="#top">Up</a></div> |
|
1022 <hr /><hr /> |
|
1023 <a NAME="is_binary_operator" ID="is_binary_operator"></a> |
|
1024 <h2>is_binary_operator</h2> |
|
1025 <b>is_binary_operator</b>(<i>token_type, text</i>) |
|
1026 |
|
1027 <div align="right"><a href="#top">Up</a></div> |
|
1028 <hr /><hr /> |
|
1029 <a NAME="is_string_literal" ID="is_string_literal"></a> |
|
1030 <h2>is_string_literal</h2> |
|
1031 <b>is_string_literal</b>(<i>line</i>) |
|
1032 |
943 <div align="right"><a href="#top">Up</a></div> |
1033 <div align="right"><a href="#top">Up</a></div> |
944 <hr /><hr /> |
1034 <hr /><hr /> |
945 <a NAME="maximum_line_length" ID="maximum_line_length"></a> |
1035 <a NAME="maximum_line_length" ID="maximum_line_length"></a> |
946 <h2>maximum_line_length</h2> |
1036 <h2>maximum_line_length</h2> |
947 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline</i>) |
1037 <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline</i>) |
1008 E227: c = a|b |
1098 E227: c = a|b |
1009 E228: msg = fmt%(errno, errmsg) |
1099 E228: msg = fmt%(errno, errmsg) |
1010 </p> |
1100 </p> |
1011 <div align="right"><a href="#top">Up</a></div> |
1101 <div align="right"><a href="#top">Up</a></div> |
1012 <hr /><hr /> |
1102 <hr /><hr /> |
|
1103 <a NAME="module_imports_on_top_of_file" ID="module_imports_on_top_of_file"></a> |
|
1104 <h2>module_imports_on_top_of_file</h2> |
|
1105 <b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>) |
|
1106 <p> |
|
1107 Imports are always put at the top of the file, just after any module |
|
1108 comments and docstrings, and before module globals and constants. |
|
1109 </p><p> |
|
1110 Okay: import os |
|
1111 Okay: # this is a comment\nimport os |
|
1112 Okay: '''this is a module docstring'''\nimport os |
|
1113 Okay: r'''this is a module docstring'''\nimport os |
|
1114 Okay: try:\n import x\nexcept:\n pass\nelse:\n pass\nimport y |
|
1115 Okay: try:\n import x\nexcept:\n pass\nfinally:\n pass\nimport y |
|
1116 E402: a=1\nimport os |
|
1117 E402: 'One string'\n"Two string"\nimport os |
|
1118 E402: a=1\nfrom sys import x |
|
1119 </p><p> |
|
1120 Okay: if x:\n import os |
|
1121 </p> |
|
1122 <div align="right"><a href="#top">Up</a></div> |
|
1123 <hr /><hr /> |
1013 <a NAME="mute_string" ID="mute_string"></a> |
1124 <a NAME="mute_string" ID="mute_string"></a> |
1014 <h2>mute_string</h2> |
1125 <h2>mute_string</h2> |
1015 <b>mute_string</b>(<i>text</i>) |
1126 <b>mute_string</b>(<i>text</i>) |
1016 <p> |
1127 <p> |
1017 Replace contents with 'xxx' to prevent syntax matching. |
1128 Replace contents with 'xxx' to prevent syntax matching. |
1046 <a NAME="process_options" ID="process_options"></a> |
1157 <a NAME="process_options" ID="process_options"></a> |
1047 <h2>process_options</h2> |
1158 <h2>process_options</h2> |
1048 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None</i>) |
1159 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None</i>) |
1049 <p> |
1160 <p> |
1050 Process options passed either via arglist or via command line args. |
1161 Process options passed either via arglist or via command line args. |
|
1162 </p><p> |
|
1163 Passing in the ``config_file`` parameter allows other tools, such as flake8 |
|
1164 to specify their own options to be processed in pep8. |
1051 </p> |
1165 </p> |
1052 <div align="right"><a href="#top">Up</a></div> |
1166 <div align="right"><a href="#top">Up</a></div> |
1053 <hr /><hr /> |
1167 <hr /><hr /> |
1054 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a> |
1168 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a> |
1055 <h2>python_3000_backticks</h2> |
1169 <h2>python_3000_backticks</h2> |
1101 <hr /><hr /> |
1215 <hr /><hr /> |
1102 <a NAME="read_config" ID="read_config"></a> |
1216 <a NAME="read_config" ID="read_config"></a> |
1103 <h2>read_config</h2> |
1217 <h2>read_config</h2> |
1104 <b>read_config</b>(<i>options, args, arglist, parser</i>) |
1218 <b>read_config</b>(<i>options, args, arglist, parser</i>) |
1105 <p> |
1219 <p> |
1106 Read both user configuration and local configuration. |
1220 Read and parse configurations |
|
1221 </p><p> |
|
1222 If a config file is specified on the command line with the "--config" |
|
1223 option, then only it is used for configuration. |
|
1224 </p><p> |
|
1225 Otherwise, the user configuration (~/.config/pep8) and any local |
|
1226 configurations in the current directory or above will be merged together |
|
1227 (in that order) using the read method of ConfigParser. |
1107 </p> |
1228 </p> |
1108 <div align="right"><a href="#top">Up</a></div> |
1229 <div align="right"><a href="#top">Up</a></div> |
1109 <hr /><hr /> |
1230 <hr /><hr /> |
1110 <a NAME="readlines" ID="readlines"></a> |
1231 <a NAME="readlines" ID="readlines"></a> |
1111 <h2>readlines</h2> |
1232 <h2>readlines</h2> |
1235 Okay: return magic(r=real, i=imag) |
1356 Okay: return magic(r=real, i=imag) |
1236 Okay: boolean(a == b) |
1357 Okay: boolean(a == b) |
1237 Okay: boolean(a != b) |
1358 Okay: boolean(a != b) |
1238 Okay: boolean(a <= b) |
1359 Okay: boolean(a <= b) |
1239 Okay: boolean(a >= b) |
1360 Okay: boolean(a >= b) |
|
1361 Okay: def foo(arg: int = 42): |
1240 </p><p> |
1362 </p><p> |
1241 E251: def complex(real, imag = 0.0): |
1363 E251: def complex(real, imag = 0.0): |
1242 E251: return magic(r = real, i = imag) |
1364 E251: return magic(r = real, i = imag) |
1243 </p> |
1365 </p> |
1244 <div align="right"><a href="#top">Up</a></div> |
1366 <div align="right"><a href="#top">Up</a></div> |
1275 Okay: # Block comment |
1397 Okay: # Block comment |
1276 E261: x = x + 1 # Increment x |
1398 E261: x = x + 1 # Increment x |
1277 E262: x = x + 1 #Increment x |
1399 E262: x = x + 1 #Increment x |
1278 E262: x = x + 1 # Increment x |
1400 E262: x = x + 1 # Increment x |
1279 E265: #Block comment |
1401 E265: #Block comment |
|
1402 E266: ### Block comment |
1280 </p> |
1403 </p> |
1281 <div align="right"><a href="#top">Up</a></div> |
1404 <div align="right"><a href="#top">Up</a></div> |
1282 <hr /><hr /> |
1405 <hr /><hr /> |
1283 <a NAME="whitespace_before_parameters" ID="whitespace_before_parameters"></a> |
1406 <a NAME="whitespace_before_parameters" ID="whitespace_before_parameters"></a> |
1284 <h2>whitespace_before_parameters</h2> |
1407 <h2>whitespace_before_parameters</h2> |