Documentation/Source/eric5.UtilitiesPython2.pep8.html

changeset 2867
eb325d7f7335
parent 2387
2d119e79ab54
child 2923
01ac1f364b38
equal deleted inserted replaced
2866:c77e08c38a5c 2867:eb325d7f7335
21 <body><a NAME="top" ID="top"></a> 21 <body><a NAME="top" ID="top"></a>
22 <h1>eric5.UtilitiesPython2.pep8</h1> 22 <h1>eric5.UtilitiesPython2.pep8</h1>
23 23
24 <h3>Global Attributes</h3> 24 <h3>Global Attributes</h3>
25 <table> 25 <table>
26 <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> 26 <tr><td>ARITHMETIC_OP</td></tr><tr><td>BENCHMARK_KEYS</td></tr><tr><td>COMMENT_WITH_NL</td></tr><tr><td>COMPARE_SINGLETON_REGEX</td></tr><tr><td>COMPARE_TYPE_REGEX</td></tr><tr><td>DEFAULT_EXCLUDE</td></tr><tr><td>DEFAULT_IGNORE</td></tr><tr><td>DOCSTRING_REGEX</td></tr><tr><td>ERRORCODE_REGEX</td></tr><tr><td>EXTRANEOUS_WHITESPACE_REGEX</td></tr><tr><td>HUNK_REGEX</td></tr><tr><td>INDENT_REGEX</td></tr><tr><td>KEYWORDS</td></tr><tr><td>KEYWORD_REGEX</td></tr><tr><td>LAMBDA_REGEX</td></tr><tr><td>MAX_LINE_LENGTH</td></tr><tr><td>OPERATOR_REGEX</td></tr><tr><td>PROJECT_CONFIG</td></tr><tr><td>PyCF_ONLY_AST</td></tr><tr><td>RAISE_COMMA_REGEX</td></tr><tr><td>REPORT_FORMAT</td></tr><tr><td>RERAISE_COMMA_REGEX</td></tr><tr><td>SINGLETONS</td></tr><tr><td>SKIP_TOKENS</td></tr><tr><td>TESTSUITE_PATH</td></tr><tr><td>UNARY_OPERATORS</td></tr><tr><td>WHITESPACE</td></tr><tr><td>WHITESPACE_AFTER_COMMA_REGEX</td></tr><tr><td>WS_NEEDED_OPERATORS</td></tr><tr><td>WS_OPTIONAL_OPERATORS</td></tr><tr><td>__version__</td></tr><tr><td>_checks</td></tr><tr><td>noqa</td></tr>
27 </table> 27 </table>
28 <h3>Classes</h3> 28 <h3>Classes</h3>
29 <table> 29 <table>
30 <tr> 30 <tr>
31 <td><a href="#BaseReport">BaseReport</a></td>
32 <td>Collect the results of the checks.</td>
33 </tr><tr>
31 <td><a href="#Checker">Checker</a></td> 34 <td><a href="#Checker">Checker</a></td>
32 <td>Load a Python source file, tokenize it, check coding style.</td> 35 <td>Load a Python source file, tokenize it, check coding style.</td>
36 </tr><tr>
37 <td><a href="#DiffReport">DiffReport</a></td>
38 <td>Collect and print the results for the changed lines only.</td>
39 </tr><tr>
40 <td><a href="#FileReport">FileReport</a></td>
41 <td>Collect the results of the checks and print only the filenames.</td>
42 </tr><tr>
43 <td><a href="#StandardReport">StandardReport</a></td>
44 <td>Collect and print the results of the checks.</td>
45 </tr><tr>
46 <td><a href="#StyleGuide">StyleGuide</a></td>
47 <td>Initialize a PEP-8 instance with few options.</td>
33 </tr> 48 </tr>
34 </table> 49 </table>
35 <h3>Functions</h3> 50 <h3>Functions</h3>
36 <table> 51 <table>
37 <tr> 52 <tr>
53 <td><a href="#_add_check">_add_check</a></td>
54 <td></td>
55 </tr><tr>
38 <td><a href="#_main">_main</a></td> 56 <td><a href="#_main">_main</a></td>
39 <td>Parse options and run checks on Python source.</td> 57 <td>Parse options and run checks on Python source.</td>
40 </tr><tr> 58 </tr><tr>
41 <td><a href="#blank_lines">blank_lines</a></td> 59 <td><a href="#blank_lines">blank_lines</a></td>
42 <td></td> 60 <td></td>
43 </tr><tr> 61 </tr><tr>
62 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
63 <td>Comparisons to singletons like None should always be done with "is" or "is not", never the equality operators.</td>
64 </tr><tr>
65 <td><a href="#comparison_type">comparison_type</a></td>
66 <td>Object type comparisons should always use isinstance() instead of comparing types directly.</td>
67 </tr><tr>
44 <td><a href="#compound_statements">compound_statements</a></td> 68 <td><a href="#compound_statements">compound_statements</a></td>
45 <td></td> 69 <td></td>
46 </tr><tr> 70 </tr><tr>
47 <td><a href="#excluded">excluded</a></td> 71 <td><a href="#continued_indentation">continued_indentation</a></td>
48 <td>Check if options.exclude contains a pattern that matches filename.</td> 72 <td></td>
49 </tr><tr> 73 </tr><tr>
50 <td><a href="#expand_indent">expand_indent</a></td> 74 <td><a href="#expand_indent">expand_indent</a></td>
51 <td>Return the amount of indentation.</td> 75 <td></td>
76 </tr><tr>
77 <td><a href="#explicit_line_join">explicit_line_join</a></td>
78 <td></td>
52 </tr><tr> 79 </tr><tr>
53 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td> 80 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
54 <td>Avoid extraneous whitespace in the following situations:</td> 81 <td>Avoid extraneous whitespace in the following situations:</td>
55 </tr><tr> 82 </tr><tr>
56 <td><a href="#filename_match">filename_match</a></td> 83 <td><a href="#filename_match">filename_match</a></td>
57 <td>Check if options.filename contains a pattern that matches filename.</td> 84 <td>Check if patterns contains a pattern that matches filename.</td>
58 </tr><tr> 85 </tr><tr>
59 <td><a href="#find_checks">find_checks</a></td> 86 <td><a href="#get_parser">get_parser</a></td>
60 <td>Find all globally visible functions where the first argument name starts with argument_name.</td> 87 <td></td>
61 </tr><tr>
62 <td><a href="#get_count">get_count</a></td>
63 <td>Return the total count of errors and warnings.</td>
64 </tr><tr>
65 <td><a href="#get_error_statistics">get_error_statistics</a></td>
66 <td>Get error statistics.</td>
67 </tr><tr>
68 <td><a href="#get_statistics">get_statistics</a></td>
69 <td>Get statistics for message codes that start with the prefix.</td>
70 </tr><tr>
71 <td><a href="#get_warning_statistics">get_warning_statistics</a></td>
72 <td>Get warning statistics.</td>
73 </tr><tr>
74 <td><a href="#ignore_code">ignore_code</a></td>
75 <td>Check if options.ignore contains a prefix of the error code.</td>
76 </tr><tr> 88 </tr><tr>
77 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td> 89 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
78 <td></td> 90 <td></td>
79 </tr><tr> 91 </tr><tr>
80 <td><a href="#indentation">indentation</a></td> 92 <td><a href="#indentation">indentation</a></td>
81 <td></td> 93 <td></td>
82 </tr><tr> 94 </tr><tr>
83 <td><a href="#input_dir">input_dir</a></td> 95 <td><a href="#init_checks_registry">init_checks_registry</a></td>
84 <td>Check all Python source files in this directory and all subdirectories.</td> 96 <td>Register all globally visible functions where the first argument name is 'physical_line' or 'logical_line'.</td>
85 </tr><tr>
86 <td><a href="#input_file">input_file</a></td>
87 <td>Run all checks on a Python source file.</td>
88 </tr><tr> 97 </tr><tr>
89 <td><a href="#maximum_line_length">maximum_line_length</a></td> 98 <td><a href="#maximum_line_length">maximum_line_length</a></td>
90 <td>Limit all lines to a maximum of 79 characters.</td> 99 <td>Limit all lines to a maximum of 79 characters.</td>
91 </tr><tr> 100 </tr><tr>
92 <td><a href="#message">message</a></td>
93 <td>Print a message.</td>
94 </tr><tr>
95 <td><a href="#missing_newline">missing_newline</a></td> 101 <td><a href="#missing_newline">missing_newline</a></td>
96 <td>JCR: The last line should have a newline.</td> 102 <td>JCR: The last line should have a newline.</td>
97 </tr><tr> 103 </tr><tr>
98 <td><a href="#missing_whitespace">missing_whitespace</a></td> 104 <td><a href="#missing_whitespace">missing_whitespace</a></td>
99 <td>JCR: Each comma, semicolon or colon should be followed by whitespace.</td> 105 <td>JCR: Each comma, semicolon or colon should be followed by whitespace.</td>
102 <td></td> 108 <td></td>
103 </tr><tr> 109 </tr><tr>
104 <td><a href="#mute_string">mute_string</a></td> 110 <td><a href="#mute_string">mute_string</a></td>
105 <td>Replace contents with 'xxx' to prevent syntax matching.</td> 111 <td>Replace contents with 'xxx' to prevent syntax matching.</td>
106 </tr><tr> 112 </tr><tr>
107 <td><a href="#print_benchmark">print_benchmark</a></td> 113 <td><a href="#parse_udiff">parse_udiff</a></td>
108 <td>Print benchmark numbers.</td> 114 <td>Return a dictionary of matching lines.</td>
109 </tr><tr>
110 <td><a href="#print_statistics">print_statistics</a></td>
111 <td>Print overall statistics (number of errors and warnings).</td>
112 </tr><tr> 115 </tr><tr>
113 <td><a href="#process_options">process_options</a></td> 116 <td><a href="#process_options">process_options</a></td>
114 <td>Process options passed either via arglist or via command line args.</td> 117 <td>Process options passed either via arglist or via command line args.</td>
115 </tr><tr> 118 </tr><tr>
116 <td><a href="#python_3000_backticks">python_3000_backticks</a></td> 119 <td><a href="#python_3000_backticks">python_3000_backticks</a></td>
117 <td>Backticks are removed in Python 3000.</td> 120 <td>Backticks are removed in Python 3.</td>
118 </tr><tr> 121 </tr><tr>
119 <td><a href="#python_3000_has_key">python_3000_has_key</a></td> 122 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
120 <td>The {}.has_key() method will be removed in the future version of Python.</td> 123 <td></td>
121 </tr><tr> 124 </tr><tr>
122 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td> 125 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
123 <td>!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only.</td> 126 <td>!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only.</td>
124 </tr><tr> 127 </tr><tr>
125 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td> 128 <td><a href="#python_3000_raise_comma">python_3000_raise_comma</a></td>
126 <td>When raising an exception, use "raise ValueError('message')" instead of the older form "raise ValueError, 'message'".</td> 129 <td>When raising an exception, use "raise ValueError('message')" instead of the older form "raise ValueError, 'message'".</td>
127 </tr><tr> 130 </tr><tr>
131 <td><a href="#read_config">read_config</a></td>
132 <td>Read both user configuration and local configuration.</td>
133 </tr><tr>
128 <td><a href="#readlines">readlines</a></td> 134 <td><a href="#readlines">readlines</a></td>
129 <td></td> 135 <td></td>
130 </tr><tr> 136 </tr><tr>
131 <td><a href="#readlines_1">readlines</a></td> 137 <td><a href="#readlines_1">readlines</a></td>
132 <td></td> 138 <td></td>
133 </tr><tr> 139 </tr><tr>
134 <td><a href="#reset_counters">reset_counters</a></td> 140 <td><a href="#register_check">register_check</a></td>
135 <td></td> 141 <td>Register a new check object.</td>
136 </tr><tr> 142 </tr><tr>
137 <td><a href="#run_tests">run_tests</a></td> 143 <td><a href="#stdin_get_value">stdin_get_value</a></td>
138 <td>Run all the tests from a file.</td> 144 <td></td>
139 </tr><tr>
140 <td><a href="#selftest">selftest</a></td>
141 <td>Test all check functions with test cases in docstrings.</td>
142 </tr><tr> 145 </tr><tr>
143 <td><a href="#tabs_obsolete">tabs_obsolete</a></td> 146 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
144 <td></td> 147 <td></td>
145 </tr><tr> 148 </tr><tr>
146 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td> 149 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
152 <td><a href="#trailing_whitespace">trailing_whitespace</a></td> 155 <td><a href="#trailing_whitespace">trailing_whitespace</a></td>
153 <td></td> 156 <td></td>
154 </tr><tr> 157 </tr><tr>
155 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td> 158 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
156 <td>Avoid extraneous whitespace in the following situations:</td> 159 <td>Avoid extraneous whitespace in the following situations:</td>
160 </tr><tr>
161 <td><a href="#whitespace_around_keywords">whitespace_around_keywords</a></td>
162 <td></td>
157 </tr><tr> 163 </tr><tr>
158 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td> 164 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
159 <td>Don't use spaces around the '=' sign when used to indicate a keyword argument or a default parameter value.</td> 165 <td>Don't use spaces around the '=' sign when used to indicate a keyword argument or a default parameter value.</td>
160 </tr><tr> 166 </tr><tr>
161 <td><a href="#whitespace_around_operator">whitespace_around_operator</a></td> 167 <td><a href="#whitespace_around_operator">whitespace_around_operator</a></td>
167 <td><a href="#whitespace_before_parameters">whitespace_before_parameters</a></td> 173 <td><a href="#whitespace_before_parameters">whitespace_before_parameters</a></td>
168 <td>Avoid extraneous whitespace in the following situations:</td> 174 <td>Avoid extraneous whitespace in the following situations:</td>
169 </tr> 175 </tr>
170 </table> 176 </table>
171 <hr /><hr /> 177 <hr /><hr />
172 <a NAME="Checker" ID="Checker"></a> 178 <a NAME="BaseReport" ID="BaseReport"></a>
173 <h2>Checker</h2> 179 <h2>BaseReport</h2>
174 <p> 180 <p>
175 Load a Python source file, tokenize it, check coding style. 181 Collect the results of the checks.
176 </p> 182 </p>
177 <h3>Derived from</h3> 183 <h3>Derived from</h3>
178 object 184 object
179 <h3>Class Attributes</h3> 185 <h3>Class Attributes</h3>
180 <table> 186 <table>
187 <tr><td>print_filename</td></tr>
188 </table>
189 <h3>Class Methods</h3>
190 <table>
191 <tr><td>None</td></tr>
192 </table>
193 <h3>Methods</h3>
194 <table>
195 <tr>
196 <td><a href="#BaseReport.__init__">BaseReport</a></td>
197 <td></td>
198 </tr><tr>
199 <td><a href="#BaseReport.error">error</a></td>
200 <td>Report an error, according to options.</td>
201 </tr><tr>
202 <td><a href="#BaseReport.error_args">error_args</a></td>
203 <td>Report an error, according to options.</td>
204 </tr><tr>
205 <td><a href="#BaseReport.get_count">get_count</a></td>
206 <td>Return the total count of errors and warnings.</td>
207 </tr><tr>
208 <td><a href="#BaseReport.get_file_results">get_file_results</a></td>
209 <td>Return the count of errors and warnings for this file.</td>
210 </tr><tr>
211 <td><a href="#BaseReport.get_statistics">get_statistics</a></td>
212 <td>Get statistics for message codes that start with the prefix.</td>
213 </tr><tr>
214 <td><a href="#BaseReport.increment_logical_line">increment_logical_line</a></td>
215 <td>Signal a new logical line.</td>
216 </tr><tr>
217 <td><a href="#BaseReport.init_file">init_file</a></td>
218 <td>Signal a new file.</td>
219 </tr><tr>
220 <td><a href="#BaseReport.print_benchmark">print_benchmark</a></td>
221 <td>Print benchmark numbers.</td>
222 </tr><tr>
223 <td><a href="#BaseReport.print_statistics">print_statistics</a></td>
224 <td>Print overall statistics (number of errors and warnings).</td>
225 </tr><tr>
226 <td><a href="#BaseReport.start">start</a></td>
227 <td>Start the timer.</td>
228 </tr><tr>
229 <td><a href="#BaseReport.stop">stop</a></td>
230 <td>Stop the timer.</td>
231 </tr>
232 </table>
233 <h3>Static Methods</h3>
234 <table>
235 <tr><td>None</td></tr>
236 </table>
237 <a NAME="BaseReport.__init__" ID="BaseReport.__init__"></a>
238 <h4>BaseReport (Constructor)</h4>
239 <b>BaseReport</b>(<i>options</i>)
240 <a NAME="BaseReport.error" ID="BaseReport.error"></a>
241 <h4>BaseReport.error</h4>
242 <b>error</b>(<i>line_number, offset, text, check</i>)
243 <p>
244 Report an error, according to options.
245 </p><a NAME="BaseReport.error_args" ID="BaseReport.error_args"></a>
246 <h4>BaseReport.error_args</h4>
247 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>)
248 <p>
249 Report an error, according to options.
250 </p><a NAME="BaseReport.get_count" ID="BaseReport.get_count"></a>
251 <h4>BaseReport.get_count</h4>
252 <b>get_count</b>(<i>prefix=''</i>)
253 <p>
254 Return the total count of errors and warnings.
255 </p><a NAME="BaseReport.get_file_results" ID="BaseReport.get_file_results"></a>
256 <h4>BaseReport.get_file_results</h4>
257 <b>get_file_results</b>(<i></i>)
258 <p>
259 Return the count of errors and warnings for this file.
260 </p><a NAME="BaseReport.get_statistics" ID="BaseReport.get_statistics"></a>
261 <h4>BaseReport.get_statistics</h4>
262 <b>get_statistics</b>(<i>prefix=''</i>)
263 <p>
264 Get statistics for message codes that start with the prefix.
265 </p><p>
266 prefix='' matches all errors and warnings
267 prefix='E' matches all errors
268 prefix='W' matches all warnings
269 prefix='E4' matches all errors that have to do with imports
270 </p><a NAME="BaseReport.increment_logical_line" ID="BaseReport.increment_logical_line"></a>
271 <h4>BaseReport.increment_logical_line</h4>
272 <b>increment_logical_line</b>(<i></i>)
273 <p>
274 Signal a new logical line.
275 </p><a NAME="BaseReport.init_file" ID="BaseReport.init_file"></a>
276 <h4>BaseReport.init_file</h4>
277 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
278 <p>
279 Signal a new file.
280 </p><a NAME="BaseReport.print_benchmark" ID="BaseReport.print_benchmark"></a>
281 <h4>BaseReport.print_benchmark</h4>
282 <b>print_benchmark</b>(<i></i>)
283 <p>
284 Print benchmark numbers.
285 </p><a NAME="BaseReport.print_statistics" ID="BaseReport.print_statistics"></a>
286 <h4>BaseReport.print_statistics</h4>
287 <b>print_statistics</b>(<i>prefix=''</i>)
288 <p>
289 Print overall statistics (number of errors and warnings).
290 </p><a NAME="BaseReport.start" ID="BaseReport.start"></a>
291 <h4>BaseReport.start</h4>
292 <b>start</b>(<i></i>)
293 <p>
294 Start the timer.
295 </p><a NAME="BaseReport.stop" ID="BaseReport.stop"></a>
296 <h4>BaseReport.stop</h4>
297 <b>stop</b>(<i></i>)
298 <p>
299 Stop the timer.
300 </p>
301 <div align="right"><a href="#top">Up</a></div>
302 <hr /><hr />
303 <a NAME="Checker" ID="Checker"></a>
304 <h2>Checker</h2>
305 <p>
306 Load a Python source file, tokenize it, check coding style.
307 </p>
308 <h3>Derived from</h3>
309 object
310 <h3>Class Attributes</h3>
311 <table>
181 <tr><td>None</td></tr> 312 <tr><td>None</td></tr>
182 </table> 313 </table>
183 <h3>Class Methods</h3> 314 <h3>Class Methods</h3>
184 <table> 315 <table>
185 <tr><td>None</td></tr> 316 <tr><td>None</td></tr>
194 <td>Build a logical line from tokens.</td> 325 <td>Build a logical line from tokens.</td>
195 </tr><tr> 326 </tr><tr>
196 <td><a href="#Checker.check_all">check_all</a></td> 327 <td><a href="#Checker.check_all">check_all</a></td>
197 <td>Run all checks on the input file.</td> 328 <td>Run all checks on the input file.</td>
198 </tr><tr> 329 </tr><tr>
330 <td><a href="#Checker.check_ast">check_ast</a></td>
331 <td></td>
332 </tr><tr>
199 <td><a href="#Checker.check_logical">check_logical</a></td> 333 <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> 334 <td>Build a line from tokens and run all logical checks on it.</td>
201 </tr><tr> 335 </tr><tr>
202 <td><a href="#Checker.check_physical">check_physical</a></td> 336 <td><a href="#Checker.check_physical">check_physical</a></td>
203 <td>Run all physical checks on a raw input line.</td> 337 <td>Run all physical checks on a raw input line.</td>
204 </tr><tr> 338 </tr><tr>
339 <td><a href="#Checker.generate_tokens">generate_tokens</a></td>
340 <td></td>
341 </tr><tr>
205 <td><a href="#Checker.readline">readline</a></td> 342 <td><a href="#Checker.readline">readline</a></td>
206 <td>Get the next line from the input buffer.</td> 343 <td>Get the next line from the input buffer.</td>
207 </tr><tr> 344 </tr><tr>
208 <td><a href="#Checker.readline_check_physical">readline_check_physical</a></td> 345 <td><a href="#Checker.readline_check_physical">readline_check_physical</a></td>
209 <td>Check and return the next physical line.</td> 346 <td>Check and return the next physical line.</td>
210 </tr><tr> 347 </tr><tr>
211 <td><a href="#Checker.report_error">report_error</a></td> 348 <td><a href="#Checker.report_invalid_syntax">report_invalid_syntax</a></td>
212 <td>Report an error, according to options.</td> 349 <td></td>
213 </tr><tr> 350 </tr><tr>
214 <td><a href="#Checker.run_check">run_check</a></td> 351 <td><a href="#Checker.run_check">run_check</a></td>
215 <td>Run a check plugin.</td> 352 <td>Run a check plugin.</td>
216 </tr> 353 </tr>
217 </table> 354 </table>
219 <table> 356 <table>
220 <tr><td>None</td></tr> 357 <tr><td>None</td></tr>
221 </table> 358 </table>
222 <a NAME="Checker.__init__" ID="Checker.__init__"></a> 359 <a NAME="Checker.__init__" ID="Checker.__init__"></a>
223 <h4>Checker (Constructor)</h4> 360 <h4>Checker (Constructor)</h4>
224 <b>Checker</b>(<i>filename, lines=None</i>) 361 <b>Checker</b>(<i>filename=None, lines=None, options=None, report=None, **kwargs</i>)
225 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a> 362 <a NAME="Checker.build_tokens_line" ID="Checker.build_tokens_line"></a>
226 <h4>Checker.build_tokens_line</h4> 363 <h4>Checker.build_tokens_line</h4>
227 <b>build_tokens_line</b>(<i></i>) 364 <b>build_tokens_line</b>(<i></i>)
228 <p> 365 <p>
229 Build a logical line from tokens. 366 Build a logical line from tokens.
230 </p><a NAME="Checker.check_all" ID="Checker.check_all"></a> 367 </p><a NAME="Checker.check_all" ID="Checker.check_all"></a>
231 <h4>Checker.check_all</h4> 368 <h4>Checker.check_all</h4>
232 <b>check_all</b>(<i>expected=None, line_offset=0</i>) 369 <b>check_all</b>(<i>expected=None, line_offset=0</i>)
233 <p> 370 <p>
234 Run all checks on the input file. 371 Run all checks on the input file.
235 </p><a NAME="Checker.check_logical" ID="Checker.check_logical"></a> 372 </p><a NAME="Checker.check_ast" ID="Checker.check_ast"></a>
373 <h4>Checker.check_ast</h4>
374 <b>check_ast</b>(<i></i>)
375 <a NAME="Checker.check_logical" ID="Checker.check_logical"></a>
236 <h4>Checker.check_logical</h4> 376 <h4>Checker.check_logical</h4>
237 <b>check_logical</b>(<i></i>) 377 <b>check_logical</b>(<i></i>)
238 <p> 378 <p>
239 Build a line from tokens and run all logical checks on it. 379 Build a line from tokens and run all logical checks on it.
240 </p><a NAME="Checker.check_physical" ID="Checker.check_physical"></a> 380 </p><a NAME="Checker.check_physical" ID="Checker.check_physical"></a>
241 <h4>Checker.check_physical</h4> 381 <h4>Checker.check_physical</h4>
242 <b>check_physical</b>(<i>line</i>) 382 <b>check_physical</b>(<i>line</i>)
243 <p> 383 <p>
244 Run all physical checks on a raw input line. 384 Run all physical checks on a raw input line.
245 </p><a NAME="Checker.readline" ID="Checker.readline"></a> 385 </p><a NAME="Checker.generate_tokens" ID="Checker.generate_tokens"></a>
386 <h4>Checker.generate_tokens</h4>
387 <b>generate_tokens</b>(<i></i>)
388 <a NAME="Checker.readline" ID="Checker.readline"></a>
246 <h4>Checker.readline</h4> 389 <h4>Checker.readline</h4>
247 <b>readline</b>(<i></i>) 390 <b>readline</b>(<i></i>)
248 <p> 391 <p>
249 Get the next line from the input buffer. 392 Get the next line from the input buffer.
250 </p><a NAME="Checker.readline_check_physical" ID="Checker.readline_check_physical"></a> 393 </p><a NAME="Checker.readline_check_physical" ID="Checker.readline_check_physical"></a>
251 <h4>Checker.readline_check_physical</h4> 394 <h4>Checker.readline_check_physical</h4>
252 <b>readline_check_physical</b>(<i></i>) 395 <b>readline_check_physical</b>(<i></i>)
253 <p> 396 <p>
254 Check and return the next physical line. This method can be 397 Check and return the next physical line. This method can be
255 used to feed tokenize.generate_tokens. 398 used to feed tokenize.generate_tokens.
256 </p><a NAME="Checker.report_error" ID="Checker.report_error"></a> 399 </p><a NAME="Checker.report_invalid_syntax" ID="Checker.report_invalid_syntax"></a>
257 <h4>Checker.report_error</h4> 400 <h4>Checker.report_invalid_syntax</h4>
258 <b>report_error</b>(<i>line_number, offset, text, check</i>) 401 <b>report_invalid_syntax</b>(<i></i>)
259 <p> 402 <a NAME="Checker.run_check" ID="Checker.run_check"></a>
260 Report an error, according to options.
261 </p><a NAME="Checker.run_check" ID="Checker.run_check"></a>
262 <h4>Checker.run_check</h4> 403 <h4>Checker.run_check</h4>
263 <b>run_check</b>(<i>check, argument_names</i>) 404 <b>run_check</b>(<i>check, argument_names</i>)
264 <p> 405 <p>
265 Run a check plugin. 406 Run a check plugin.
266 </p> 407 </p>
408 <div align="right"><a href="#top">Up</a></div>
409 <hr /><hr />
410 <a NAME="DiffReport" ID="DiffReport"></a>
411 <h2>DiffReport</h2>
412 <p>
413 Collect and print the results for the changed lines only.
414 </p>
415 <h3>Derived from</h3>
416 StandardReport
417 <h3>Class Attributes</h3>
418 <table>
419 <tr><td>None</td></tr>
420 </table>
421 <h3>Class Methods</h3>
422 <table>
423 <tr><td>None</td></tr>
424 </table>
425 <h3>Methods</h3>
426 <table>
427 <tr>
428 <td><a href="#DiffReport.__init__">DiffReport</a></td>
429 <td></td>
430 </tr><tr>
431 <td><a href="#DiffReport.error">error</a></td>
432 <td></td>
433 </tr>
434 </table>
435 <h3>Static Methods</h3>
436 <table>
437 <tr><td>None</td></tr>
438 </table>
439 <a NAME="DiffReport.__init__" ID="DiffReport.__init__"></a>
440 <h4>DiffReport (Constructor)</h4>
441 <b>DiffReport</b>(<i>options</i>)
442 <a NAME="DiffReport.error" ID="DiffReport.error"></a>
443 <h4>DiffReport.error</h4>
444 <b>error</b>(<i>line_number, offset, text, check</i>)
445
446 <div align="right"><a href="#top">Up</a></div>
447 <hr /><hr />
448 <a NAME="FileReport" ID="FileReport"></a>
449 <h2>FileReport</h2>
450 <p>
451 Collect the results of the checks and print only the filenames.
452 </p>
453 <h3>Derived from</h3>
454 BaseReport
455 <h3>Class Attributes</h3>
456 <table>
457 <tr><td>print_filename</td></tr>
458 </table>
459 <h3>Class Methods</h3>
460 <table>
461 <tr><td>None</td></tr>
462 </table>
463 <h3>Methods</h3>
464 <table>
465 <tr><td>None</td></tr>
466 </table>
467 <h3>Static Methods</h3>
468 <table>
469 <tr><td>None</td></tr>
470 </table>
471
472 <div align="right"><a href="#top">Up</a></div>
473 <hr /><hr />
474 <a NAME="StandardReport" ID="StandardReport"></a>
475 <h2>StandardReport</h2>
476 <p>
477 Collect and print the results of the checks.
478 </p>
479 <h3>Derived from</h3>
480 BaseReport
481 <h3>Class Attributes</h3>
482 <table>
483 <tr><td>None</td></tr>
484 </table>
485 <h3>Class Methods</h3>
486 <table>
487 <tr><td>None</td></tr>
488 </table>
489 <h3>Methods</h3>
490 <table>
491 <tr>
492 <td><a href="#StandardReport.__init__">StandardReport</a></td>
493 <td></td>
494 </tr><tr>
495 <td><a href="#StandardReport.error">error</a></td>
496 <td>Report an error, according to options.</td>
497 </tr><tr>
498 <td><a href="#StandardReport.error_args">error_args</a></td>
499 <td>Report an error, according to options.</td>
500 </tr><tr>
501 <td><a href="#StandardReport.get_file_results">get_file_results</a></td>
502 <td>Print the result and return the overall count for this file.</td>
503 </tr><tr>
504 <td><a href="#StandardReport.init_file">init_file</a></td>
505 <td>Signal a new file.</td>
506 </tr>
507 </table>
508 <h3>Static Methods</h3>
509 <table>
510 <tr><td>None</td></tr>
511 </table>
512 <a NAME="StandardReport.__init__" ID="StandardReport.__init__"></a>
513 <h4>StandardReport (Constructor)</h4>
514 <b>StandardReport</b>(<i>options</i>)
515 <a NAME="StandardReport.error" ID="StandardReport.error"></a>
516 <h4>StandardReport.error</h4>
517 <b>error</b>(<i>line_number, offset, text, check</i>)
518 <p>
519 Report an error, according to options.
520 </p><a NAME="StandardReport.error_args" ID="StandardReport.error_args"></a>
521 <h4>StandardReport.error_args</h4>
522 <b>error_args</b>(<i>line_number, offset, code, check, *args</i>)
523 <p>
524 Report an error, according to options.
525 </p><a NAME="StandardReport.get_file_results" ID="StandardReport.get_file_results"></a>
526 <h4>StandardReport.get_file_results</h4>
527 <b>get_file_results</b>(<i></i>)
528 <p>
529 Print the result and return the overall count for this file.
530 </p><a NAME="StandardReport.init_file" ID="StandardReport.init_file"></a>
531 <h4>StandardReport.init_file</h4>
532 <b>init_file</b>(<i>filename, lines, expected, line_offset</i>)
533 <p>
534 Signal a new file.
535 </p>
536 <div align="right"><a href="#top">Up</a></div>
537 <hr /><hr />
538 <a NAME="StyleGuide" ID="StyleGuide"></a>
539 <h2>StyleGuide</h2>
540 <p>
541 Initialize a PEP-8 instance with few options.
542 </p>
543 <h3>Derived from</h3>
544 object
545 <h3>Class Attributes</h3>
546 <table>
547 <tr><td>None</td></tr>
548 </table>
549 <h3>Class Methods</h3>
550 <table>
551 <tr><td>None</td></tr>
552 </table>
553 <h3>Methods</h3>
554 <table>
555 <tr>
556 <td><a href="#StyleGuide.__init__">StyleGuide</a></td>
557 <td></td>
558 </tr><tr>
559 <td><a href="#StyleGuide.check_files">check_files</a></td>
560 <td>Run all checks on the paths.</td>
561 </tr><tr>
562 <td><a href="#StyleGuide.excluded">excluded</a></td>
563 <td>Check if options.exclude contains a pattern that matches filename.</td>
564 </tr><tr>
565 <td><a href="#StyleGuide.get_checks">get_checks</a></td>
566 <td>Find all globally visible functions where the first argument name starts with argument_name and which contain selected tests.</td>
567 </tr><tr>
568 <td><a href="#StyleGuide.ignore_code">ignore_code</a></td>
569 <td>Check if the error code should be ignored.</td>
570 </tr><tr>
571 <td><a href="#StyleGuide.init_report">init_report</a></td>
572 <td>Initialize the report instance.</td>
573 </tr><tr>
574 <td><a href="#StyleGuide.input_dir">input_dir</a></td>
575 <td>Check all files in this directory and all subdirectories.</td>
576 </tr><tr>
577 <td><a href="#StyleGuide.input_file">input_file</a></td>
578 <td>Run all checks on a Python source file.</td>
579 </tr>
580 </table>
581 <h3>Static Methods</h3>
582 <table>
583 <tr><td>None</td></tr>
584 </table>
585 <a NAME="StyleGuide.__init__" ID="StyleGuide.__init__"></a>
586 <h4>StyleGuide (Constructor)</h4>
587 <b>StyleGuide</b>(<i>*args, **kwargs</i>)
588 <a NAME="StyleGuide.check_files" ID="StyleGuide.check_files"></a>
589 <h4>StyleGuide.check_files</h4>
590 <b>check_files</b>(<i>paths=None</i>)
591 <p>
592 Run all checks on the paths.
593 </p><a NAME="StyleGuide.excluded" ID="StyleGuide.excluded"></a>
594 <h4>StyleGuide.excluded</h4>
595 <b>excluded</b>(<i>filename, parent=None</i>)
596 <p>
597 Check if options.exclude contains a pattern that matches filename.
598 </p><a NAME="StyleGuide.get_checks" ID="StyleGuide.get_checks"></a>
599 <h4>StyleGuide.get_checks</h4>
600 <b>get_checks</b>(<i>argument_name</i>)
601 <p>
602 Find all globally visible functions where the first argument name
603 starts with argument_name and which contain selected tests.
604 </p><a NAME="StyleGuide.ignore_code" ID="StyleGuide.ignore_code"></a>
605 <h4>StyleGuide.ignore_code</h4>
606 <b>ignore_code</b>(<i>code</i>)
607 <p>
608 Check if the error code should be ignored.
609 </p><p>
610 If 'options.select' contains a prefix of the error code,
611 return False. Else, if 'options.ignore' contains a prefix of
612 the error code, return True.
613 </p><a NAME="StyleGuide.init_report" ID="StyleGuide.init_report"></a>
614 <h4>StyleGuide.init_report</h4>
615 <b>init_report</b>(<i>reporter=None</i>)
616 <p>
617 Initialize the report instance.
618 </p><a NAME="StyleGuide.input_dir" ID="StyleGuide.input_dir"></a>
619 <h4>StyleGuide.input_dir</h4>
620 <b>input_dir</b>(<i>dirname</i>)
621 <p>
622 Check all files in this directory and all subdirectories.
623 </p><a NAME="StyleGuide.input_file" ID="StyleGuide.input_file"></a>
624 <h4>StyleGuide.input_file</h4>
625 <b>input_file</b>(<i>filename, lines=None, expected=None, line_offset=0</i>)
626 <p>
627 Run all checks on a Python source file.
628 </p>
629 <div align="right"><a href="#top">Up</a></div>
630 <hr /><hr />
631 <a NAME="_add_check" ID="_add_check"></a>
632 <h2>_add_check</h2>
633 <b>_add_check</b>(<i>check, kind, codes, args</i>)
634
267 <div align="right"><a href="#top">Up</a></div> 635 <div align="right"><a href="#top">Up</a></div>
268 <hr /><hr /> 636 <hr /><hr />
269 <a NAME="_main" ID="_main"></a> 637 <a NAME="_main" ID="_main"></a>
270 <h2>_main</h2> 638 <h2>_main</h2>
271 <b>_main</b>(<i></i>) 639 <b>_main</b>(<i></i>)
272 <p> 640 <p>
273 Parse options and run checks on Python source. 641 Parse options and run checks on Python source.
274 </p> 642 </p>
275 <div align="right"><a href="#top">Up</a></div> 643 <div align="right"><a href="#top">Up</a></div>
276 <hr /><hr /> 644 <hr /><hr />
277 <a NAME="blank_lines" ID="blank_lines"></a> 645 <a NAME="blank_lines" ID="blank_lines"></a>
278 <h2>blank_lines</h2> 646 <h2>blank_lines</h2>
279 <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, previous_logical, previous_indent_level, blank_lines_before_comment</i>) 647 <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, previous_logical, previous_indent_level</i>)
280 648
649 <div align="right"><a href="#top">Up</a></div>
650 <hr /><hr />
651 <a NAME="comparison_to_singleton" ID="comparison_to_singleton"></a>
652 <h2>comparison_to_singleton</h2>
653 <b>comparison_to_singleton</b>(<i>logical_line, noqa</i>)
654 <p>
655 Comparisons to singletons like None should always be done
656 with "is" or "is not", never the equality operators.
657 </p><p>
658 Okay: if arg is not None:
659 E711: if arg != None:
660 E712: if arg == True:
661 </p><p>
662 Also, beware of writing if x when you really mean if x is not None --
663 e.g. when testing whether a variable or argument that defaults to None was
664 set to some other value. The other value might have a type (such as a
665 container) that could be false in a boolean context!
666 </p>
667 <div align="right"><a href="#top">Up</a></div>
668 <hr /><hr />
669 <a NAME="comparison_type" ID="comparison_type"></a>
670 <h2>comparison_type</h2>
671 <b>comparison_type</b>(<i>logical_line</i>)
672 <p>
673 Object type comparisons should always use isinstance() instead of
674 comparing types directly.
675 </p><p>
676 Okay: if isinstance(obj, int):
677 E721: if type(obj) is type(1):
678 </p><p>
679 When checking if an object is a string, keep in mind that it might be a
680 unicode string too! In Python 2.3, str and unicode have a common base
681 class, basestring, so you can do:
682 </p><p>
683 Okay: if isinstance(obj, basestring):
684 Okay: if type(a1) is type(b1):
685 </p>
281 <div align="right"><a href="#top">Up</a></div> 686 <div align="right"><a href="#top">Up</a></div>
282 <hr /><hr /> 687 <hr /><hr />
283 <a NAME="compound_statements" ID="compound_statements"></a> 688 <a NAME="compound_statements" ID="compound_statements"></a>
284 <h2>compound_statements</h2> 689 <h2>compound_statements</h2>
285 <b>compound_statements</b>(<i>logical_line</i>) 690 <b>compound_statements</b>(<i>logical_line</i>)
286 691
287 <div align="right"><a href="#top">Up</a></div> 692 <div align="right"><a href="#top">Up</a></div>
288 <hr /><hr /> 693 <hr /><hr />
289 <a NAME="excluded" ID="excluded"></a> 694 <a NAME="continued_indentation" ID="continued_indentation"></a>
290 <h2>excluded</h2> 695 <h2>continued_indentation</h2>
291 <b>excluded</b>(<i>filename</i>) 696 <b>continued_indentation</b>(<i>logical_line, tokens, indent_level, hang_closing, noqa, verbose</i>)
292 <p> 697
293 Check if options.exclude contains a pattern that matches filename.
294 </p>
295 <div align="right"><a href="#top">Up</a></div> 698 <div align="right"><a href="#top">Up</a></div>
296 <hr /><hr /> 699 <hr /><hr />
297 <a NAME="expand_indent" ID="expand_indent"></a> 700 <a NAME="expand_indent" ID="expand_indent"></a>
298 <h2>expand_indent</h2> 701 <h2>expand_indent</h2>
299 <b>expand_indent</b>(<i>line</i>) 702 <b>expand_indent</b>(<i>line</i>)
300 <p> 703
301 Return the amount of indentation. 704 <div align="right"><a href="#top">Up</a></div>
302 Tabs are expanded to the next multiple of 8. 705 <hr /><hr />
303 </p><p> 706 <a NAME="explicit_line_join" ID="explicit_line_join"></a>
304 >>> expand_indent(' ') 707 <h2>explicit_line_join</h2>
305 4 708 <b>explicit_line_join</b>(<i>logical_line, tokens</i>)
306 >>> expand_indent('\\t') 709
307 8
308 >>> expand_indent(' \\t')
309 8
310 >>> expand_indent(' \\t')
311 8
312 >>> expand_indent(' \\t')
313 16
314 </p>
315 <div align="right"><a href="#top">Up</a></div> 710 <div align="right"><a href="#top">Up</a></div>
316 <hr /><hr /> 711 <hr /><hr />
317 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a> 712 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
318 <h2>extraneous_whitespace</h2> 713 <h2>extraneous_whitespace</h2>
319 <b>extraneous_whitespace</b>(<i>logical_line</i>) 714 <b>extraneous_whitespace</b>(<i>logical_line</i>)
338 </p> 733 </p>
339 <div align="right"><a href="#top">Up</a></div> 734 <div align="right"><a href="#top">Up</a></div>
340 <hr /><hr /> 735 <hr /><hr />
341 <a NAME="filename_match" ID="filename_match"></a> 736 <a NAME="filename_match" ID="filename_match"></a>
342 <h2>filename_match</h2> 737 <h2>filename_match</h2>
343 <b>filename_match</b>(<i>filename</i>) 738 <b>filename_match</b>(<i>filename, patterns, default=True</i>)
344 <p> 739 <p>
345 Check if options.filename contains a pattern that matches filename. 740 Check if patterns contains a pattern that matches filename.
346 If options.filename is unspecified, this always returns True. 741 If patterns is unspecified, this always returns True.
347 </p> 742 </p>
348 <div align="right"><a href="#top">Up</a></div> 743 <div align="right"><a href="#top">Up</a></div>
349 <hr /><hr /> 744 <hr /><hr />
350 <a NAME="find_checks" ID="find_checks"></a> 745 <a NAME="get_parser" ID="get_parser"></a>
351 <h2>find_checks</h2> 746 <h2>get_parser</h2>
352 <b>find_checks</b>(<i>argument_name</i>) 747 <b>get_parser</b>(<i>prog='pep8', version=__version__</i>)
353 <p> 748
354 Find all globally visible functions where the first argument name
355 starts with argument_name.
356 </p>
357 <div align="right"><a href="#top">Up</a></div>
358 <hr /><hr />
359 <a NAME="get_count" ID="get_count"></a>
360 <h2>get_count</h2>
361 <b>get_count</b>(<i>prefix=''</i>)
362 <p>
363 Return the total count of errors and warnings.
364 </p>
365 <div align="right"><a href="#top">Up</a></div>
366 <hr /><hr />
367 <a NAME="get_error_statistics" ID="get_error_statistics"></a>
368 <h2>get_error_statistics</h2>
369 <b>get_error_statistics</b>(<i></i>)
370 <p>
371 Get error statistics.
372 </p>
373 <div align="right"><a href="#top">Up</a></div>
374 <hr /><hr />
375 <a NAME="get_statistics" ID="get_statistics"></a>
376 <h2>get_statistics</h2>
377 <b>get_statistics</b>(<i>prefix=''</i>)
378 <p>
379 Get statistics for message codes that start with the prefix.
380 </p><p>
381 prefix='' matches all errors and warnings
382 prefix='E' matches all errors
383 prefix='W' matches all warnings
384 prefix='E4' matches all errors that have to do with imports
385 </p>
386 <div align="right"><a href="#top">Up</a></div>
387 <hr /><hr />
388 <a NAME="get_warning_statistics" ID="get_warning_statistics"></a>
389 <h2>get_warning_statistics</h2>
390 <b>get_warning_statistics</b>(<i></i>)
391 <p>
392 Get warning statistics.
393 </p>
394 <div align="right"><a href="#top">Up</a></div>
395 <hr /><hr />
396 <a NAME="ignore_code" ID="ignore_code"></a>
397 <h2>ignore_code</h2>
398 <b>ignore_code</b>(<i>code</i>)
399 <p>
400 Check if options.ignore contains a prefix of the error code.
401 If options.select contains a prefix of the error code, do not ignore it.
402 </p>
403 <div align="right"><a href="#top">Up</a></div> 749 <div align="right"><a href="#top">Up</a></div>
404 <hr /><hr /> 750 <hr /><hr />
405 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a> 751 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
406 <h2>imports_on_separate_lines</h2> 752 <h2>imports_on_separate_lines</h2>
407 <b>imports_on_separate_lines</b>(<i>logical_line</i>) 753 <b>imports_on_separate_lines</b>(<i>logical_line</i>)
412 <h2>indentation</h2> 758 <h2>indentation</h2>
413 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>) 759 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
414 760
415 <div align="right"><a href="#top">Up</a></div> 761 <div align="right"><a href="#top">Up</a></div>
416 <hr /><hr /> 762 <hr /><hr />
417 <a NAME="input_dir" ID="input_dir"></a> 763 <a NAME="init_checks_registry" ID="init_checks_registry"></a>
418 <h2>input_dir</h2> 764 <h2>init_checks_registry</h2>
419 <b>input_dir</b>(<i>dirname, runner=None</i>) 765 <b>init_checks_registry</b>(<i></i>)
420 <p> 766 <p>
421 Check all Python source files in this directory and all subdirectories. 767 Register all globally visible functions where the first argument name
422 </p> 768 is 'physical_line' or 'logical_line'.
423 <div align="right"><a href="#top">Up</a></div>
424 <hr /><hr />
425 <a NAME="input_file" ID="input_file"></a>
426 <h2>input_file</h2>
427 <b>input_file</b>(<i>filename</i>)
428 <p>
429 Run all checks on a Python source file.
430 </p> 769 </p>
431 <div align="right"><a href="#top">Up</a></div> 770 <div align="right"><a href="#top">Up</a></div>
432 <hr /><hr /> 771 <hr /><hr />
433 <a NAME="maximum_line_length" ID="maximum_line_length"></a> 772 <a NAME="maximum_line_length" ID="maximum_line_length"></a>
434 <h2>maximum_line_length</h2> 773 <h2>maximum_line_length</h2>
435 <b>maximum_line_length</b>(<i>physical_line</i>) 774 <b>maximum_line_length</b>(<i>physical_line, max_line_length</i>)
436 <p> 775 <p>
437 Limit all lines to a maximum of 79 characters. 776 Limit all lines to a maximum of 79 characters.
438 </p><p> 777 </p><p>
439 There are still many devices around that are limited to 80 character 778 There are still many devices around that are limited to 80 character
440 lines; plus, limiting windows to 80 characters makes it possible to have 779 lines; plus, limiting windows to 80 characters makes it possible to have
441 several windows side-by-side. The default wrapping on such devices looks 780 several windows side-by-side. The default wrapping on such devices looks
442 ugly. Therefore, please limit all lines to a maximum of 79 characters. 781 ugly. Therefore, please limit all lines to a maximum of 79 characters.
443 For flowing long blocks of text (docstrings or comments), limiting the 782 For flowing long blocks of text (docstrings or comments), limiting the
444 length to 72 characters is recommended. 783 length to 72 characters is recommended.
445 </p> 784 </p><p>
446 <div align="right"><a href="#top">Up</a></div> 785 Reports error E501.
447 <hr /><hr />
448 <a NAME="message" ID="message"></a>
449 <h2>message</h2>
450 <b>message</b>(<i>text</i>)
451 <p>
452 Print a message.
453 </p> 786 </p>
454 <div align="right"><a href="#top">Up</a></div> 787 <div align="right"><a href="#top">Up</a></div>
455 <hr /><hr /> 788 <hr /><hr />
456 <a NAME="missing_newline" ID="missing_newline"></a> 789 <a NAME="missing_newline" ID="missing_newline"></a>
457 <h2>missing_newline</h2> 790 <h2>missing_newline</h2>
458 <b>missing_newline</b>(<i>physical_line</i>) 791 <b>missing_newline</b>(<i>physical_line</i>)
459 <p> 792 <p>
460 JCR: The last line should have a newline. 793 JCR: The last line should have a newline.
794 </p><p>
795 Reports warning W292.
461 </p> 796 </p>
462 <div align="right"><a href="#top">Up</a></div> 797 <div align="right"><a href="#top">Up</a></div>
463 <hr /><hr /> 798 <hr /><hr />
464 <a NAME="missing_whitespace" ID="missing_whitespace"></a> 799 <a NAME="missing_whitespace" ID="missing_whitespace"></a>
465 <h2>missing_whitespace</h2> 800 <h2>missing_whitespace</h2>
473 Okay: a[:4] 808 Okay: a[:4]
474 Okay: a[1:] 809 Okay: a[1:]
475 Okay: a[1:4:2] 810 Okay: a[1:4:2]
476 E231: ['a','b'] 811 E231: ['a','b']
477 E231: foo(bar,baz) 812 E231: foo(bar,baz)
813 E231: [{'a':'b'}]
478 </p> 814 </p>
479 <div align="right"><a href="#top">Up</a></div> 815 <div align="right"><a href="#top">Up</a></div>
480 <hr /><hr /> 816 <hr /><hr />
481 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a> 817 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
482 <h2>missing_whitespace_around_operator</h2> 818 <h2>missing_whitespace_around_operator</h2>
497 >>> mute_string("r'abc'") 833 >>> mute_string("r'abc'")
498 "r'xxx'" 834 "r'xxx'"
499 </p> 835 </p>
500 <div align="right"><a href="#top">Up</a></div> 836 <div align="right"><a href="#top">Up</a></div>
501 <hr /><hr /> 837 <hr /><hr />
502 <a NAME="print_benchmark" ID="print_benchmark"></a> 838 <a NAME="parse_udiff" ID="parse_udiff"></a>
503 <h2>print_benchmark</h2> 839 <h2>parse_udiff</h2>
504 <b>print_benchmark</b>(<i>elapsed</i>) 840 <b>parse_udiff</b>(<i>diff, patterns=None, parent='.'</i>)
505 <p> 841 <p>
506 Print benchmark numbers. 842 Return a dictionary of matching lines.
507 </p>
508 <div align="right"><a href="#top">Up</a></div>
509 <hr /><hr />
510 <a NAME="print_statistics" ID="print_statistics"></a>
511 <h2>print_statistics</h2>
512 <b>print_statistics</b>(<i>prefix=''</i>)
513 <p>
514 Print overall statistics (number of errors and warnings).
515 </p> 843 </p>
516 <div align="right"><a href="#top">Up</a></div> 844 <div align="right"><a href="#top">Up</a></div>
517 <hr /><hr /> 845 <hr /><hr />
518 <a NAME="process_options" ID="process_options"></a> 846 <a NAME="process_options" ID="process_options"></a>
519 <h2>process_options</h2> 847 <h2>process_options</h2>
520 <b>process_options</b>(<i>arglist=None</i>) 848 <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None</i>)
521 <p> 849 <p>
522 Process options passed either via arglist or via command line args. 850 Process options passed either via arglist or via command line args.
523 </p> 851 </p>
524 <div align="right"><a href="#top">Up</a></div> 852 <div align="right"><a href="#top">Up</a></div>
525 <hr /><hr /> 853 <hr /><hr />
526 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a> 854 <a NAME="python_3000_backticks" ID="python_3000_backticks"></a>
527 <h2>python_3000_backticks</h2> 855 <h2>python_3000_backticks</h2>
528 <b>python_3000_backticks</b>(<i>logical_line</i>) 856 <b>python_3000_backticks</b>(<i>logical_line</i>)
529 <p> 857 <p>
530 Backticks are removed in Python 3000. 858 Backticks are removed in Python 3.
531 Use repr() instead. 859 Use repr() instead.
860 </p><p>
861 Okay: val = repr(1 + 2)
862 W604: val = `1 + 2`
532 </p> 863 </p>
533 <div align="right"><a href="#top">Up</a></div> 864 <div align="right"><a href="#top">Up</a></div>
534 <hr /><hr /> 865 <hr /><hr />
535 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a> 866 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
536 <h2>python_3000_has_key</h2> 867 <h2>python_3000_has_key</h2>
537 <b>python_3000_has_key</b>(<i>logical_line</i>) 868 <b>python_3000_has_key</b>(<i>logical_line</i>)
538 <p> 869
539 The {}.has_key() method will be removed in the future version of
540 Python. Use the 'in' operation instead, like:
541 d = {"a": 1, "b": 2}
542 if "b" in d:
543 print d["b"]
544 </p>
545 <div align="right"><a href="#top">Up</a></div> 870 <div align="right"><a href="#top">Up</a></div>
546 <hr /><hr /> 871 <hr /><hr />
547 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a> 872 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
548 <h2>python_3000_not_equal</h2> 873 <h2>python_3000_not_equal</h2>
549 <b>python_3000_not_equal</b>(<i>logical_line</i>) 874 <b>python_3000_not_equal</b>(<i>logical_line</i>)
550 <p> 875 <p>
551 != can also be written <>, but this is an obsolete usage kept for 876 != can also be written <>, but this is an obsolete usage kept for
552 backwards compatibility only. New code should always use !=. 877 backwards compatibility only. New code should always use !=.
553 The older syntax is removed in Python 3000. 878 The older syntax is removed in Python 3.
879 </p><p>
880 Okay: if a != 'no':
881 W603: if a <> 'no':
554 </p> 882 </p>
555 <div align="right"><a href="#top">Up</a></div> 883 <div align="right"><a href="#top">Up</a></div>
556 <hr /><hr /> 884 <hr /><hr />
557 <a NAME="python_3000_raise_comma" ID="python_3000_raise_comma"></a> 885 <a NAME="python_3000_raise_comma" ID="python_3000_raise_comma"></a>
558 <h2>python_3000_raise_comma</h2> 886 <h2>python_3000_raise_comma</h2>
562 instead of the older form "raise ValueError, 'message'". 890 instead of the older form "raise ValueError, 'message'".
563 </p><p> 891 </p><p>
564 The paren-using form is preferred because when the exception arguments 892 The paren-using form is preferred because when the exception arguments
565 are long or include string formatting, you don't need to use line 893 are long or include string formatting, you don't need to use line
566 continuation characters thanks to the containing parentheses. The older 894 continuation characters thanks to the containing parentheses. The older
567 form will be removed in Python 3000. 895 form is removed in Python 3.
896 </p><p>
897 Okay: raise DummyError("Message")
898 W602: raise DummyError, "Message"
899 </p>
900 <div align="right"><a href="#top">Up</a></div>
901 <hr /><hr />
902 <a NAME="read_config" ID="read_config"></a>
903 <h2>read_config</h2>
904 <b>read_config</b>(<i>options, args, arglist, parser</i>)
905 <p>
906 Read both user configuration and local configuration.
568 </p> 907 </p>
569 <div align="right"><a href="#top">Up</a></div> 908 <div align="right"><a href="#top">Up</a></div>
570 <hr /><hr /> 909 <hr /><hr />
571 <a NAME="readlines" ID="readlines"></a> 910 <a NAME="readlines" ID="readlines"></a>
572 <h2>readlines</h2> 911 <h2>readlines</h2>
578 <h2>readlines</h2> 917 <h2>readlines</h2>
579 <b>readlines</b>(<i>filename</i>) 918 <b>readlines</b>(<i>filename</i>)
580 919
581 <div align="right"><a href="#top">Up</a></div> 920 <div align="right"><a href="#top">Up</a></div>
582 <hr /><hr /> 921 <hr /><hr />
583 <a NAME="reset_counters" ID="reset_counters"></a> 922 <a NAME="register_check" ID="register_check"></a>
584 <h2>reset_counters</h2> 923 <h2>register_check</h2>
585 <b>reset_counters</b>(<i></i>) 924 <b>register_check</b>(<i>check, codes=None</i>)
586 925 <p>
587 <div align="right"><a href="#top">Up</a></div> 926 Register a new check object.
588 <hr /><hr /> 927 </p>
589 <a NAME="run_tests" ID="run_tests"></a> 928 <div align="right"><a href="#top">Up</a></div>
590 <h2>run_tests</h2> 929 <hr /><hr />
591 <b>run_tests</b>(<i>filename</i>) 930 <a NAME="stdin_get_value" ID="stdin_get_value"></a>
592 <p> 931 <h2>stdin_get_value</h2>
593 Run all the tests from a file. 932 <b>stdin_get_value</b>(<i></i>)
594 </p><p> 933
595 A test file can provide many tests. Each test starts with a declaration.
596 This declaration is a single line starting with '#:'.
597 It declares codes of expected failures, separated by spaces or 'Okay'
598 if no failure is expected.
599 If the file does not contain such declaration, it should pass all tests.
600 If the declaration is empty, following lines are not checked, until next
601 declaration.
602 </p><p>
603 Examples:
604 </p><p>
605 * Only E224 and W701 are expected: #: E224 W701
606 * Following example is conform: #: Okay
607 * Don't check these lines: #:
608 </p>
609 <div align="right"><a href="#top">Up</a></div>
610 <hr /><hr />
611 <a NAME="selftest" ID="selftest"></a>
612 <h2>selftest</h2>
613 <b>selftest</b>(<i></i>)
614 <p>
615 Test all check functions with test cases in docstrings.
616 </p>
617 <div align="right"><a href="#top">Up</a></div> 934 <div align="right"><a href="#top">Up</a></div>
618 <hr /><hr /> 935 <hr /><hr />
619 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a> 936 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
620 <h2>tabs_obsolete</h2> 937 <h2>tabs_obsolete</h2>
621 <b>tabs_obsolete</b>(<i>physical_line</i>) 938 <b>tabs_obsolete</b>(<i>physical_line</i>)
656 E241: a = (1, 2) 973 E241: a = (1, 2)
657 E242: a = (1,\t2) 974 E242: a = (1,\t2)
658 </p> 975 </p>
659 <div align="right"><a href="#top">Up</a></div> 976 <div align="right"><a href="#top">Up</a></div>
660 <hr /><hr /> 977 <hr /><hr />
978 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a>
979 <h2>whitespace_around_keywords</h2>
980 <b>whitespace_around_keywords</b>(<i>logical_line</i>)
981
982 <div align="right"><a href="#top">Up</a></div>
983 <hr /><hr />
661 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a> 984 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
662 <h2>whitespace_around_named_parameter_equals</h2> 985 <h2>whitespace_around_named_parameter_equals</h2>
663 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line</i>) 986 <b>whitespace_around_named_parameter_equals</b>(<i>logical_line, tokens</i>)
664 <p> 987 <p>
665 Don't use spaces around the '=' sign when used to indicate a 988 Don't use spaces around the '=' sign when used to indicate a
666 keyword argument or a default parameter value. 989 keyword argument or a default parameter value.
667 </p><p> 990 </p><p>
668 Okay: def complex(real, imag=0.0): 991 Okay: def complex(real, imag=0.0):

eric ide

mercurial