|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer</h1> |
|
23 <p> |
|
24 Module implementing a class to fix certain code style issues. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>FixableCodeStyleIssues</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#CodeStyleFixer">CodeStyleFixer</a></td> |
|
34 <td>Class implementing a fixer for certain code style issues.</td> |
|
35 </tr><tr> |
|
36 <td><a href="#IndentationWrapper">IndentationWrapper</a></td> |
|
37 <td>Class used by fixers dealing with indentation.</td> |
|
38 </tr><tr> |
|
39 <td><a href="#LineShortener">LineShortener</a></td> |
|
40 <td>Class used to shorten lines to a given maximum of characters.</td> |
|
41 </tr><tr> |
|
42 <td><a href="#Reindenter">Reindenter</a></td> |
|
43 <td>Class to reindent badly-indented code to uniformly use four-space indentation.</td> |
|
44 </tr> |
|
45 </table> |
|
46 <h3>Functions</h3> |
|
47 <table> |
|
48 <tr><td>None</td></tr> |
|
49 </table> |
|
50 <hr /><hr /> |
|
51 <a NAME="CodeStyleFixer" ID="CodeStyleFixer"></a> |
|
52 <h2>CodeStyleFixer</h2> |
|
53 <p> |
|
54 Class implementing a fixer for certain code style issues. |
|
55 </p> |
|
56 <h3>Derived from</h3> |
|
57 object |
|
58 <h3>Class Attributes</h3> |
|
59 <table> |
|
60 <tr><td>None</td></tr> |
|
61 </table> |
|
62 <h3>Class Methods</h3> |
|
63 <table> |
|
64 <tr><td>None</td></tr> |
|
65 </table> |
|
66 <h3>Methods</h3> |
|
67 <table> |
|
68 <tr> |
|
69 <td><a href="#CodeStyleFixer.__init__">CodeStyleFixer</a></td> |
|
70 <td>Constructor</td> |
|
71 </tr><tr> |
|
72 <td><a href="#CodeStyleFixer.__codeMatch">__codeMatch</a></td> |
|
73 <td>Private method to check, if the code should be fixed.</td> |
|
74 </tr><tr> |
|
75 <td><a href="#CodeStyleFixer.__findLogical">__findLogical</a></td> |
|
76 <td>Private method to extract the index of all the starts and ends of lines.</td> |
|
77 </tr><tr> |
|
78 <td><a href="#CodeStyleFixer.__fixD111">__fixD111</a></td> |
|
79 <td>Private method to fix docstring enclosed in wrong quotes.</td> |
|
80 </tr><tr> |
|
81 <td><a href="#CodeStyleFixer.__fixD112">__fixD112</a></td> |
|
82 <td>Private method to fix docstring 'r' or 'u' in leading quotes.</td> |
|
83 </tr><tr> |
|
84 <td><a href="#CodeStyleFixer.__fixD131">__fixD131</a></td> |
|
85 <td>Private method to fix a docstring summary not ending with a period.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#CodeStyleFixer.__fixD141">__fixD141</a></td> |
|
88 <td>Private method to fix a function/method docstring preceded by a blank line.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#CodeStyleFixer.__fixD142">__fixD142</a></td> |
|
91 <td>Private method to fix a class docstring not preceded by a blank line.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#CodeStyleFixer.__fixD143">__fixD143</a></td> |
|
94 <td>Private method to fix a class docstring not followed by a blank line.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#CodeStyleFixer.__fixD144">__fixD144</a></td> |
|
97 <td>Private method to fix a docstring summary not followed by a blank line.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#CodeStyleFixer.__fixD145">__fixD145</a></td> |
|
100 <td>Private method to fix the last paragraph of a multi-line docstring not followed by a blank line.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#CodeStyleFixer.__fixD221">__fixD221</a></td> |
|
103 <td>Private method to fix leading and trailing quotes of docstring not on separate lines.</td> |
|
104 </tr><tr> |
|
105 <td><a href="#CodeStyleFixer.__fixD242">__fixD242</a></td> |
|
106 <td>Private method to fix a class or function/method docstring preceded by a blank line.</td> |
|
107 </tr><tr> |
|
108 <td><a href="#CodeStyleFixer.__fixD243">__fixD243</a></td> |
|
109 <td>Private method to fix a class or function/method docstring followed by a blank line.</td> |
|
110 </tr><tr> |
|
111 <td><a href="#CodeStyleFixer.__fixD247">__fixD247</a></td> |
|
112 <td>Private method to fix a last paragraph of a docstring followed by a blank line.</td> |
|
113 </tr><tr> |
|
114 <td><a href="#CodeStyleFixer.__fixE101">__fixE101</a></td> |
|
115 <td>Private method to fix obsolete tab usage and indentation errors.</td> |
|
116 </tr><tr> |
|
117 <td><a href="#CodeStyleFixer.__fixE121">__fixE121</a></td> |
|
118 <td>Private method to fix the indentation of continuation lines and closing brackets.</td> |
|
119 </tr><tr> |
|
120 <td><a href="#CodeStyleFixer.__fixE122">__fixE122</a></td> |
|
121 <td>Private method to fix a missing indentation of continuation lines.</td> |
|
122 </tr><tr> |
|
123 <td><a href="#CodeStyleFixer.__fixE123">__fixE123</a></td> |
|
124 <td>Private method to fix the indentation of a closing bracket lines.</td> |
|
125 </tr><tr> |
|
126 <td><a href="#CodeStyleFixer.__fixE125">__fixE125</a></td> |
|
127 <td>Private method to fix the indentation of continuation lines not distinguishable from next logical line.</td> |
|
128 </tr><tr> |
|
129 <td><a href="#CodeStyleFixer.__fixE126">__fixE126</a></td> |
|
130 <td>Private method to fix over-indented/under-indented hanging indentation.</td> |
|
131 </tr><tr> |
|
132 <td><a href="#CodeStyleFixer.__fixE127">__fixE127</a></td> |
|
133 <td>Private method to fix over/under indented lines.</td> |
|
134 </tr><tr> |
|
135 <td><a href="#CodeStyleFixer.__fixE201">__fixE201</a></td> |
|
136 <td>Private method to fix extraneous whitespace.</td> |
|
137 </tr><tr> |
|
138 <td><a href="#CodeStyleFixer.__fixE221">__fixE221</a></td> |
|
139 <td>Private method to fix extraneous whitespace around operator or keyword.</td> |
|
140 </tr><tr> |
|
141 <td><a href="#CodeStyleFixer.__fixE231">__fixE231</a></td> |
|
142 <td>Private method to fix missing whitespace after ',;:'.</td> |
|
143 </tr><tr> |
|
144 <td><a href="#CodeStyleFixer.__fixE251">__fixE251</a></td> |
|
145 <td>Private method to fix extraneous whitespace around keyword and default parameter equals.</td> |
|
146 </tr><tr> |
|
147 <td><a href="#CodeStyleFixer.__fixE261">__fixE261</a></td> |
|
148 <td>Private method to fix whitespace before or after inline comment.</td> |
|
149 </tr><tr> |
|
150 <td><a href="#CodeStyleFixer.__fixE301">__fixE301</a></td> |
|
151 <td>Private method to fix the need for one blank line.</td> |
|
152 </tr><tr> |
|
153 <td><a href="#CodeStyleFixer.__fixE302">__fixE302</a></td> |
|
154 <td>Private method to fix the need for two blank lines.</td> |
|
155 </tr><tr> |
|
156 <td><a href="#CodeStyleFixer.__fixE303">__fixE303</a></td> |
|
157 <td>Private method to fix superfluous blank lines.</td> |
|
158 </tr><tr> |
|
159 <td><a href="#CodeStyleFixer.__fixE304">__fixE304</a></td> |
|
160 <td>Private method to fix superfluous blank lines after a function decorator.</td> |
|
161 </tr><tr> |
|
162 <td><a href="#CodeStyleFixer.__fixE401">__fixE401</a></td> |
|
163 <td>Private method to fix multiple imports on one line.</td> |
|
164 </tr><tr> |
|
165 <td><a href="#CodeStyleFixer.__fixE501">__fixE501</a></td> |
|
166 <td>Private method to fix the long lines by breaking them.</td> |
|
167 </tr><tr> |
|
168 <td><a href="#CodeStyleFixer.__fixE502">__fixE502</a></td> |
|
169 <td>Private method to fix redundant backslash within brackets.</td> |
|
170 </tr><tr> |
|
171 <td><a href="#CodeStyleFixer.__fixE701">__fixE701</a></td> |
|
172 <td>Private method to fix colon-separated compound statements.</td> |
|
173 </tr><tr> |
|
174 <td><a href="#CodeStyleFixer.__fixE702">__fixE702</a></td> |
|
175 <td>Private method to fix semicolon-separated compound statements.</td> |
|
176 </tr><tr> |
|
177 <td><a href="#CodeStyleFixer.__fixE711">__fixE711</a></td> |
|
178 <td>Private method to fix comparison with None.</td> |
|
179 </tr><tr> |
|
180 <td><a href="#CodeStyleFixer.__fixN804">__fixN804</a></td> |
|
181 <td>Private method to fix a wrong first argument of normal and class methods.</td> |
|
182 </tr><tr> |
|
183 <td><a href="#CodeStyleFixer.__fixN806">__fixN806</a></td> |
|
184 <td>Private method to fix a wrong first argument of static methods.</td> |
|
185 </tr><tr> |
|
186 <td><a href="#CodeStyleFixer.__fixReindent">__fixReindent</a></td> |
|
187 <td>Private method to fix a badly indented line.</td> |
|
188 </tr><tr> |
|
189 <td><a href="#CodeStyleFixer.__fixW291">__fixW291</a></td> |
|
190 <td>Private method to fix trailing whitespace.</td> |
|
191 </tr><tr> |
|
192 <td><a href="#CodeStyleFixer.__fixW292">__fixW292</a></td> |
|
193 <td>Private method to fix a missing newline at the end of file.</td> |
|
194 </tr><tr> |
|
195 <td><a href="#CodeStyleFixer.__fixW391">__fixW391</a></td> |
|
196 <td>Private method to fix trailing blank lines.</td> |
|
197 </tr><tr> |
|
198 <td><a href="#CodeStyleFixer.__fixW603">__fixW603</a></td> |
|
199 <td>Private method to fix the not equal notation.</td> |
|
200 </tr><tr> |
|
201 <td><a href="#CodeStyleFixer.__fixWhitespace">__fixWhitespace</a></td> |
|
202 <td>Private method to correct whitespace at the given offset.</td> |
|
203 </tr><tr> |
|
204 <td><a href="#CodeStyleFixer.__getID">__getID</a></td> |
|
205 <td>Private method to get the ID for a deferred fix.</td> |
|
206 </tr><tr> |
|
207 <td><a href="#CodeStyleFixer.__getIndent">__getIndent</a></td> |
|
208 <td>Private method to get the indentation string.</td> |
|
209 </tr><tr> |
|
210 <td><a href="#CodeStyleFixer.__getIndentWord">__getIndentWord</a></td> |
|
211 <td>Private method to determine the indentation type.</td> |
|
212 </tr><tr> |
|
213 <td><a href="#CodeStyleFixer.__getLogical">__getLogical</a></td> |
|
214 <td>Private method to get the logical line corresponding to the given position.</td> |
|
215 </tr><tr> |
|
216 <td><a href="#CodeStyleFixer.__multilineStringLines">__multilineStringLines</a></td> |
|
217 <td>Private method to determine the line numbers that are within multi line strings and these which are part of a documentation string.</td> |
|
218 </tr><tr> |
|
219 <td><a href="#CodeStyleFixer.finalize">finalize</a></td> |
|
220 <td>Public method to apply all deferred fixes.</td> |
|
221 </tr><tr> |
|
222 <td><a href="#CodeStyleFixer.fixIssue">fixIssue</a></td> |
|
223 <td>Public method to fix the fixable issues.</td> |
|
224 </tr><tr> |
|
225 <td><a href="#CodeStyleFixer.mutualStartswith">mutualStartswith</a></td> |
|
226 <td>Local helper method to compare the beginnings of two strings against each other.</td> |
|
227 </tr><tr> |
|
228 <td><a href="#CodeStyleFixer.saveFile">saveFile</a></td> |
|
229 <td>Public method to save the modified file.</td> |
|
230 </tr> |
|
231 </table> |
|
232 <h3>Static Methods</h3> |
|
233 <table> |
|
234 <tr><td>None</td></tr> |
|
235 </table> |
|
236 <a NAME="CodeStyleFixer.__init__" ID="CodeStyleFixer.__init__"></a> |
|
237 <h4>CodeStyleFixer (Constructor)</h4> |
|
238 <b>CodeStyleFixer</b>(<i>filename, sourceLines, fixCodes, noFixCodes, maxLineLength, inPlace, eol, backup=False</i>) |
|
239 <p> |
|
240 Constructor |
|
241 </p><dl> |
|
242 <dt><i>filename</i></dt> |
|
243 <dd> |
|
244 name of the file to be fixed (string) |
|
245 </dd><dt><i>sourceLines</i></dt> |
|
246 <dd> |
|
247 list of source lines including eol marker |
|
248 (list of string) |
|
249 </dd><dt><i>fixCodes</i></dt> |
|
250 <dd> |
|
251 list of codes to be fixed as a comma separated |
|
252 string (string) |
|
253 </dd><dt><i>noFixCodes</i></dt> |
|
254 <dd> |
|
255 list of codes not to be fixed as a comma |
|
256 separated string (string) |
|
257 </dd><dt><i>maxLineLength</i></dt> |
|
258 <dd> |
|
259 maximum allowed line length (integer) |
|
260 </dd><dt><i>inPlace</i></dt> |
|
261 <dd> |
|
262 flag indicating to modify the file in place (boolean) |
|
263 </dd><dt><i>eol</i></dt> |
|
264 <dd> |
|
265 end of line character(s) (string) |
|
266 </dd><dt><i>backup</i></dt> |
|
267 <dd> |
|
268 flag indicating to create a backup before fixing |
|
269 anything (boolean) |
|
270 </dd> |
|
271 </dl><a NAME="CodeStyleFixer.__codeMatch" ID="CodeStyleFixer.__codeMatch"></a> |
|
272 <h4>CodeStyleFixer.__codeMatch</h4> |
|
273 <b>__codeMatch</b>(<i>code</i>) |
|
274 <p> |
|
275 Private method to check, if the code should be fixed. |
|
276 </p><dl> |
|
277 <dt><i>code</i></dt> |
|
278 <dd> |
|
279 to check (string) |
|
280 </dd> |
|
281 </dl><dl> |
|
282 <dt>Returns:</dt> |
|
283 <dd> |
|
284 flag indicating it should be fixed (boolean) |
|
285 </dd> |
|
286 </dl><a NAME="CodeStyleFixer.__findLogical" ID="CodeStyleFixer.__findLogical"></a> |
|
287 <h4>CodeStyleFixer.__findLogical</h4> |
|
288 <b>__findLogical</b>(<i></i>) |
|
289 <p> |
|
290 Private method to extract the index of all the starts and ends of |
|
291 lines. |
|
292 </p><dl> |
|
293 <dt>Returns:</dt> |
|
294 <dd> |
|
295 tuple containing two lists of integer with start and end tuples |
|
296 of lines |
|
297 </dd> |
|
298 </dl><a NAME="CodeStyleFixer.__fixD111" ID="CodeStyleFixer.__fixD111"></a> |
|
299 <h4>CodeStyleFixer.__fixD111</h4> |
|
300 <b>__fixD111</b>(<i>code, line, pos</i>) |
|
301 <p> |
|
302 Private method to fix docstring enclosed in wrong quotes. |
|
303 </p><p> |
|
304 Codes: D111 |
|
305 </p><dl> |
|
306 <dt><i>code</i></dt> |
|
307 <dd> |
|
308 code of the issue (string) |
|
309 </dd><dt><i>line</i></dt> |
|
310 <dd> |
|
311 line number of the issue (integer) |
|
312 </dd><dt><i>pos</i></dt> |
|
313 <dd> |
|
314 position inside line (integer) |
|
315 </dd> |
|
316 </dl><dl> |
|
317 <dt>Returns:</dt> |
|
318 <dd> |
|
319 value indicating an applied/deferred fix (-1, 0, 1), |
|
320 a message for the fix (string) and an ID for a deferred |
|
321 fix (integer) |
|
322 </dd> |
|
323 </dl><a NAME="CodeStyleFixer.__fixD112" ID="CodeStyleFixer.__fixD112"></a> |
|
324 <h4>CodeStyleFixer.__fixD112</h4> |
|
325 <b>__fixD112</b>(<i>code, line, pos</i>) |
|
326 <p> |
|
327 Private method to fix docstring 'r' or 'u' in leading quotes. |
|
328 </p><p> |
|
329 Codes: D112, D113 |
|
330 </p><dl> |
|
331 <dt><i>code</i></dt> |
|
332 <dd> |
|
333 code of the issue (string) |
|
334 </dd><dt><i>line</i></dt> |
|
335 <dd> |
|
336 line number of the issue (integer) |
|
337 </dd><dt><i>pos</i></dt> |
|
338 <dd> |
|
339 position inside line (integer) |
|
340 </dd> |
|
341 </dl><dl> |
|
342 <dt>Returns:</dt> |
|
343 <dd> |
|
344 value indicating an applied/deferred fix (-1, 0, 1), |
|
345 a message for the fix (string) and an ID for a deferred |
|
346 fix (integer) |
|
347 </dd> |
|
348 </dl><a NAME="CodeStyleFixer.__fixD131" ID="CodeStyleFixer.__fixD131"></a> |
|
349 <h4>CodeStyleFixer.__fixD131</h4> |
|
350 <b>__fixD131</b>(<i>code, line, pos</i>) |
|
351 <p> |
|
352 Private method to fix a docstring summary not ending with a |
|
353 period. |
|
354 </p><p> |
|
355 Codes: D131 |
|
356 </p><dl> |
|
357 <dt><i>code</i></dt> |
|
358 <dd> |
|
359 code of the issue (string) |
|
360 </dd><dt><i>line</i></dt> |
|
361 <dd> |
|
362 line number of the issue (integer) |
|
363 </dd><dt><i>pos</i></dt> |
|
364 <dd> |
|
365 position inside line (integer) |
|
366 </dd> |
|
367 </dl><dl> |
|
368 <dt>Returns:</dt> |
|
369 <dd> |
|
370 value indicating an applied/deferred fix (-1, 0, 1), |
|
371 a message for the fix (string) and an ID for a deferred |
|
372 fix (integer) |
|
373 </dd> |
|
374 </dl><a NAME="CodeStyleFixer.__fixD141" ID="CodeStyleFixer.__fixD141"></a> |
|
375 <h4>CodeStyleFixer.__fixD141</h4> |
|
376 <b>__fixD141</b>(<i>code, line, pos, apply=False</i>) |
|
377 <p> |
|
378 Private method to fix a function/method docstring preceded by a |
|
379 blank line. |
|
380 </p><p> |
|
381 Codes: D141 |
|
382 </p><dl> |
|
383 <dt><i>code</i></dt> |
|
384 <dd> |
|
385 code of the issue (string) |
|
386 </dd><dt><i>line</i></dt> |
|
387 <dd> |
|
388 line number of the issue (integer) |
|
389 </dd><dt><i>pos</i></dt> |
|
390 <dd> |
|
391 position inside line (integer) |
|
392 </dd><dt><i>apply=</i></dt> |
|
393 <dd> |
|
394 flag indicating, that the fix should be applied |
|
395 (boolean) |
|
396 </dd> |
|
397 </dl><dl> |
|
398 <dt>Returns:</dt> |
|
399 <dd> |
|
400 value indicating an applied/deferred fix (-1, 0, 1), |
|
401 a message for the fix (string) and an ID for a deferred |
|
402 fix (integer) |
|
403 </dd> |
|
404 </dl><a NAME="CodeStyleFixer.__fixD142" ID="CodeStyleFixer.__fixD142"></a> |
|
405 <h4>CodeStyleFixer.__fixD142</h4> |
|
406 <b>__fixD142</b>(<i>code, line, pos, apply=False</i>) |
|
407 <p> |
|
408 Private method to fix a class docstring not preceded by a |
|
409 blank line. |
|
410 </p><p> |
|
411 Codes: D142 |
|
412 </p><dl> |
|
413 <dt><i>code</i></dt> |
|
414 <dd> |
|
415 code of the issue (string) |
|
416 </dd><dt><i>line</i></dt> |
|
417 <dd> |
|
418 line number of the issue (integer) |
|
419 </dd><dt><i>pos</i></dt> |
|
420 <dd> |
|
421 position inside line (integer) |
|
422 </dd><dt><i>apply=</i></dt> |
|
423 <dd> |
|
424 flag indicating, that the fix should be applied |
|
425 (boolean) |
|
426 </dd> |
|
427 </dl><dl> |
|
428 <dt>Returns:</dt> |
|
429 <dd> |
|
430 value indicating an applied/deferred fix (-1, 0, 1), |
|
431 a message for the fix (string) and an ID for a deferred |
|
432 fix (integer) |
|
433 </dd> |
|
434 </dl><a NAME="CodeStyleFixer.__fixD143" ID="CodeStyleFixer.__fixD143"></a> |
|
435 <h4>CodeStyleFixer.__fixD143</h4> |
|
436 <b>__fixD143</b>(<i>code, line, pos, apply=False</i>) |
|
437 <p> |
|
438 Private method to fix a class docstring not followed by a |
|
439 blank line. |
|
440 </p><p> |
|
441 Codes: D143 |
|
442 </p><dl> |
|
443 <dt><i>code</i></dt> |
|
444 <dd> |
|
445 code of the issue (string) |
|
446 </dd><dt><i>line</i></dt> |
|
447 <dd> |
|
448 line number of the issue (integer) |
|
449 </dd><dt><i>pos</i></dt> |
|
450 <dd> |
|
451 position inside line (integer) |
|
452 </dd><dt><i>apply=</i></dt> |
|
453 <dd> |
|
454 flag indicating, that the fix should be applied |
|
455 (boolean) |
|
456 </dd> |
|
457 </dl><dl> |
|
458 <dt>Returns:</dt> |
|
459 <dd> |
|
460 value indicating an applied/deferred fix (-1, 0, 1), |
|
461 a message for the fix (string) and an ID for a deferred |
|
462 fix (integer) |
|
463 </dd> |
|
464 </dl><a NAME="CodeStyleFixer.__fixD144" ID="CodeStyleFixer.__fixD144"></a> |
|
465 <h4>CodeStyleFixer.__fixD144</h4> |
|
466 <b>__fixD144</b>(<i>code, line, pos, apply=False</i>) |
|
467 <p> |
|
468 Private method to fix a docstring summary not followed by a |
|
469 blank line. |
|
470 </p><p> |
|
471 Codes: D144 |
|
472 </p><dl> |
|
473 <dt><i>code</i></dt> |
|
474 <dd> |
|
475 code of the issue (string) |
|
476 </dd><dt><i>line</i></dt> |
|
477 <dd> |
|
478 line number of the issue (integer) |
|
479 </dd><dt><i>pos</i></dt> |
|
480 <dd> |
|
481 position inside line (integer) |
|
482 </dd><dt><i>apply=</i></dt> |
|
483 <dd> |
|
484 flag indicating, that the fix should be applied |
|
485 (boolean) |
|
486 </dd> |
|
487 </dl><dl> |
|
488 <dt>Returns:</dt> |
|
489 <dd> |
|
490 value indicating an applied/deferred fix (-1, 0, 1), |
|
491 a message for the fix (string) and an ID for a deferred |
|
492 fix (integer) |
|
493 </dd> |
|
494 </dl><a NAME="CodeStyleFixer.__fixD145" ID="CodeStyleFixer.__fixD145"></a> |
|
495 <h4>CodeStyleFixer.__fixD145</h4> |
|
496 <b>__fixD145</b>(<i>code, line, pos, apply=False</i>) |
|
497 <p> |
|
498 Private method to fix the last paragraph of a multi-line docstring |
|
499 not followed by a blank line. |
|
500 </p><p> |
|
501 Codes: D143 |
|
502 </p><dl> |
|
503 <dt><i>code</i></dt> |
|
504 <dd> |
|
505 code of the issue (string) |
|
506 </dd><dt><i>line</i></dt> |
|
507 <dd> |
|
508 line number of the issue (integer) |
|
509 </dd><dt><i>pos</i></dt> |
|
510 <dd> |
|
511 position inside line (integer) |
|
512 </dd><dt><i>apply=</i></dt> |
|
513 <dd> |
|
514 flag indicating, that the fix should be applied |
|
515 (boolean) |
|
516 </dd> |
|
517 </dl><dl> |
|
518 <dt>Returns:</dt> |
|
519 <dd> |
|
520 value indicating an applied/deferred fix (-1, 0, 1), |
|
521 a message for the fix (string) and an ID for a deferred |
|
522 fix (integer) |
|
523 </dd> |
|
524 </dl><a NAME="CodeStyleFixer.__fixD221" ID="CodeStyleFixer.__fixD221"></a> |
|
525 <h4>CodeStyleFixer.__fixD221</h4> |
|
526 <b>__fixD221</b>(<i>code, line, pos, apply=False</i>) |
|
527 <p> |
|
528 Private method to fix leading and trailing quotes of docstring |
|
529 not on separate lines. |
|
530 </p><p> |
|
531 Codes: D221, D222 |
|
532 </p><dl> |
|
533 <dt><i>code</i></dt> |
|
534 <dd> |
|
535 code of the issue (string) |
|
536 </dd><dt><i>line</i></dt> |
|
537 <dd> |
|
538 line number of the issue (integer) |
|
539 </dd><dt><i>pos</i></dt> |
|
540 <dd> |
|
541 position inside line (integer) |
|
542 </dd><dt><i>apply=</i></dt> |
|
543 <dd> |
|
544 flag indicating, that the fix should be applied |
|
545 (boolean) |
|
546 </dd> |
|
547 </dl><dl> |
|
548 <dt>Returns:</dt> |
|
549 <dd> |
|
550 value indicating an applied/deferred fix (-1, 0, 1), |
|
551 a message for the fix (string) and an ID for a deferred |
|
552 fix (integer) |
|
553 </dd> |
|
554 </dl><a NAME="CodeStyleFixer.__fixD242" ID="CodeStyleFixer.__fixD242"></a> |
|
555 <h4>CodeStyleFixer.__fixD242</h4> |
|
556 <b>__fixD242</b>(<i>code, line, pos, apply=False</i>) |
|
557 <p> |
|
558 Private method to fix a class or function/method docstring preceded |
|
559 by a blank line. |
|
560 </p><p> |
|
561 Codes: D242, D244 |
|
562 </p><dl> |
|
563 <dt><i>code</i></dt> |
|
564 <dd> |
|
565 code of the issue (string) |
|
566 </dd><dt><i>line</i></dt> |
|
567 <dd> |
|
568 line number of the issue (integer) |
|
569 </dd><dt><i>pos</i></dt> |
|
570 <dd> |
|
571 position inside line (integer) |
|
572 </dd><dt><i>apply=</i></dt> |
|
573 <dd> |
|
574 flag indicating, that the fix should be applied |
|
575 (boolean) |
|
576 </dd> |
|
577 </dl><dl> |
|
578 <dt>Returns:</dt> |
|
579 <dd> |
|
580 value indicating an applied/deferred fix (-1, 0, 1), |
|
581 a message for the fix (string) and an ID for a deferred |
|
582 fix (integer) |
|
583 </dd> |
|
584 </dl><a NAME="CodeStyleFixer.__fixD243" ID="CodeStyleFixer.__fixD243"></a> |
|
585 <h4>CodeStyleFixer.__fixD243</h4> |
|
586 <b>__fixD243</b>(<i>code, line, pos, apply=False</i>) |
|
587 <p> |
|
588 Private method to fix a class or function/method docstring followed |
|
589 by a blank line. |
|
590 </p><p> |
|
591 Codes: D243, D245 |
|
592 </p><dl> |
|
593 <dt><i>code</i></dt> |
|
594 <dd> |
|
595 code of the issue (string) |
|
596 </dd><dt><i>line</i></dt> |
|
597 <dd> |
|
598 line number of the issue (integer) |
|
599 </dd><dt><i>pos</i></dt> |
|
600 <dd> |
|
601 position inside line (integer) |
|
602 </dd><dt><i>apply=</i></dt> |
|
603 <dd> |
|
604 flag indicating, that the fix should be applied |
|
605 (boolean) |
|
606 </dd> |
|
607 </dl><dl> |
|
608 <dt>Returns:</dt> |
|
609 <dd> |
|
610 value indicating an applied/deferred fix (-1, 0, 1), |
|
611 a message for the fix (string) and an ID for a deferred |
|
612 fix (integer) |
|
613 </dd> |
|
614 </dl><a NAME="CodeStyleFixer.__fixD247" ID="CodeStyleFixer.__fixD247"></a> |
|
615 <h4>CodeStyleFixer.__fixD247</h4> |
|
616 <b>__fixD247</b>(<i>code, line, pos, apply=False</i>) |
|
617 <p> |
|
618 Private method to fix a last paragraph of a docstring followed |
|
619 by a blank line. |
|
620 </p><p> |
|
621 Codes: D247 |
|
622 </p><dl> |
|
623 <dt><i>code</i></dt> |
|
624 <dd> |
|
625 code of the issue (string) |
|
626 </dd><dt><i>line</i></dt> |
|
627 <dd> |
|
628 line number of the issue (integer) |
|
629 </dd><dt><i>pos</i></dt> |
|
630 <dd> |
|
631 position inside line (integer) |
|
632 </dd><dt><i>apply=</i></dt> |
|
633 <dd> |
|
634 flag indicating, that the fix should be applied |
|
635 (boolean) |
|
636 </dd> |
|
637 </dl><dl> |
|
638 <dt>Returns:</dt> |
|
639 <dd> |
|
640 value indicating an applied/deferred fix (-1, 0, 1), |
|
641 a message for the fix (string) and an ID for a deferred |
|
642 fix (integer) |
|
643 </dd> |
|
644 </dl><a NAME="CodeStyleFixer.__fixE101" ID="CodeStyleFixer.__fixE101"></a> |
|
645 <h4>CodeStyleFixer.__fixE101</h4> |
|
646 <b>__fixE101</b>(<i>code, line, pos</i>) |
|
647 <p> |
|
648 Private method to fix obsolete tab usage and indentation errors. |
|
649 </p><p> |
|
650 Codes: E101, E111, W191 |
|
651 </p><dl> |
|
652 <dt><i>code</i></dt> |
|
653 <dd> |
|
654 code of the issue (string) |
|
655 </dd><dt><i>line</i></dt> |
|
656 <dd> |
|
657 line number of the issue (integer) |
|
658 </dd><dt><i>pos</i></dt> |
|
659 <dd> |
|
660 position inside line (integer) |
|
661 </dd> |
|
662 </dl><dl> |
|
663 <dt>Returns:</dt> |
|
664 <dd> |
|
665 value indicating an applied/deferred fix (-1, 0, 1), |
|
666 a message for the fix (string) and an ID for a deferred |
|
667 fix (integer) |
|
668 </dd> |
|
669 </dl><a NAME="CodeStyleFixer.__fixE121" ID="CodeStyleFixer.__fixE121"></a> |
|
670 <h4>CodeStyleFixer.__fixE121</h4> |
|
671 <b>__fixE121</b>(<i>code, line, pos, apply=False</i>) |
|
672 <p> |
|
673 Private method to fix the indentation of continuation lines and |
|
674 closing brackets. |
|
675 </p><p> |
|
676 Codes: E121, E124 |
|
677 </p><dl> |
|
678 <dt><i>code</i></dt> |
|
679 <dd> |
|
680 code of the issue (string) |
|
681 </dd><dt><i>line</i></dt> |
|
682 <dd> |
|
683 line number of the issue (integer) |
|
684 </dd><dt><i>pos</i></dt> |
|
685 <dd> |
|
686 position inside line (integer) |
|
687 </dd><dt><i>apply=</i></dt> |
|
688 <dd> |
|
689 flag indicating, that the fix should be applied |
|
690 (boolean) |
|
691 </dd> |
|
692 </dl><dl> |
|
693 <dt>Returns:</dt> |
|
694 <dd> |
|
695 value indicating an applied/deferred fix (-1, 0, 1), |
|
696 a message for the fix (string) and an ID for a deferred |
|
697 fix (integer) |
|
698 </dd> |
|
699 </dl><a NAME="CodeStyleFixer.__fixE122" ID="CodeStyleFixer.__fixE122"></a> |
|
700 <h4>CodeStyleFixer.__fixE122</h4> |
|
701 <b>__fixE122</b>(<i>code, line, pos, apply=False</i>) |
|
702 <p> |
|
703 Private method to fix a missing indentation of continuation lines. |
|
704 </p><p> |
|
705 Codes: E122 |
|
706 </p><dl> |
|
707 <dt><i>code</i></dt> |
|
708 <dd> |
|
709 code of the issue (string) |
|
710 </dd><dt><i>line</i></dt> |
|
711 <dd> |
|
712 line number of the issue (integer) |
|
713 </dd><dt><i>pos</i></dt> |
|
714 <dd> |
|
715 position inside line (integer) |
|
716 </dd><dt><i>apply=</i></dt> |
|
717 <dd> |
|
718 flag indicating, that the fix should be applied |
|
719 (boolean) |
|
720 </dd> |
|
721 </dl><dl> |
|
722 <dt>Returns:</dt> |
|
723 <dd> |
|
724 value indicating an applied/deferred fix (-1, 0, 1), |
|
725 a message for the fix (string) and an ID for a deferred |
|
726 fix (integer) |
|
727 </dd> |
|
728 </dl><a NAME="CodeStyleFixer.__fixE123" ID="CodeStyleFixer.__fixE123"></a> |
|
729 <h4>CodeStyleFixer.__fixE123</h4> |
|
730 <b>__fixE123</b>(<i>code, line, pos, apply=False</i>) |
|
731 <p> |
|
732 Private method to fix the indentation of a closing bracket lines. |
|
733 </p><p> |
|
734 Codes: E123 |
|
735 </p><dl> |
|
736 <dt><i>code</i></dt> |
|
737 <dd> |
|
738 code of the issue (string) |
|
739 </dd><dt><i>line</i></dt> |
|
740 <dd> |
|
741 line number of the issue (integer) |
|
742 </dd><dt><i>pos</i></dt> |
|
743 <dd> |
|
744 position inside line (integer) |
|
745 </dd><dt><i>apply=</i></dt> |
|
746 <dd> |
|
747 flag indicating, that the fix should be applied |
|
748 (boolean) |
|
749 </dd> |
|
750 </dl><dl> |
|
751 <dt>Returns:</dt> |
|
752 <dd> |
|
753 value indicating an applied/deferred fix (-1, 0, 1), |
|
754 a message for the fix (string) and an ID for a deferred |
|
755 fix (integer) |
|
756 </dd> |
|
757 </dl><a NAME="CodeStyleFixer.__fixE125" ID="CodeStyleFixer.__fixE125"></a> |
|
758 <h4>CodeStyleFixer.__fixE125</h4> |
|
759 <b>__fixE125</b>(<i>code, line, pos, apply=False</i>) |
|
760 <p> |
|
761 Private method to fix the indentation of continuation lines not |
|
762 distinguishable from next logical line. |
|
763 </p><p> |
|
764 Codes: E125 |
|
765 </p><dl> |
|
766 <dt><i>code</i></dt> |
|
767 <dd> |
|
768 code of the issue (string) |
|
769 </dd><dt><i>line</i></dt> |
|
770 <dd> |
|
771 line number of the issue (integer) |
|
772 </dd><dt><i>pos</i></dt> |
|
773 <dd> |
|
774 position inside line (integer) |
|
775 </dd><dt><i>apply=</i></dt> |
|
776 <dd> |
|
777 flag indicating, that the fix should be applied |
|
778 (boolean) |
|
779 </dd> |
|
780 </dl><dl> |
|
781 <dt>Returns:</dt> |
|
782 <dd> |
|
783 value indicating an applied/deferred fix (-1, 0, 1), |
|
784 a message for the fix (string) and an ID for a deferred |
|
785 fix (integer) |
|
786 </dd> |
|
787 </dl><a NAME="CodeStyleFixer.__fixE126" ID="CodeStyleFixer.__fixE126"></a> |
|
788 <h4>CodeStyleFixer.__fixE126</h4> |
|
789 <b>__fixE126</b>(<i>code, line, pos, apply=False</i>) |
|
790 <p> |
|
791 Private method to fix over-indented/under-indented hanging |
|
792 indentation. |
|
793 </p><p> |
|
794 Codes: E126, E133 |
|
795 </p><dl> |
|
796 <dt><i>code</i></dt> |
|
797 <dd> |
|
798 code of the issue (string) |
|
799 </dd><dt><i>line</i></dt> |
|
800 <dd> |
|
801 line number of the issue (integer) |
|
802 </dd><dt><i>pos</i></dt> |
|
803 <dd> |
|
804 position inside line (integer) |
|
805 </dd><dt><i>apply=</i></dt> |
|
806 <dd> |
|
807 flag indicating, that the fix should be applied |
|
808 (boolean) |
|
809 </dd> |
|
810 </dl><dl> |
|
811 <dt>Returns:</dt> |
|
812 <dd> |
|
813 value indicating an applied/deferred fix (-1, 0, 1), |
|
814 a message for the fix (string) and an ID for a deferred |
|
815 fix (integer) |
|
816 </dd> |
|
817 </dl><a NAME="CodeStyleFixer.__fixE127" ID="CodeStyleFixer.__fixE127"></a> |
|
818 <h4>CodeStyleFixer.__fixE127</h4> |
|
819 <b>__fixE127</b>(<i>code, line, pos, apply=False</i>) |
|
820 <p> |
|
821 Private method to fix over/under indented lines. |
|
822 </p><p> |
|
823 Codes: E127, E128 |
|
824 </p><dl> |
|
825 <dt><i>code</i></dt> |
|
826 <dd> |
|
827 code of the issue (string) |
|
828 </dd><dt><i>line</i></dt> |
|
829 <dd> |
|
830 line number of the issue (integer) |
|
831 </dd><dt><i>pos</i></dt> |
|
832 <dd> |
|
833 position inside line (integer) |
|
834 </dd><dt><i>apply=</i></dt> |
|
835 <dd> |
|
836 flag indicating, that the fix should be applied |
|
837 (boolean) |
|
838 </dd> |
|
839 </dl><dl> |
|
840 <dt>Returns:</dt> |
|
841 <dd> |
|
842 value indicating an applied/deferred fix (-1, 0, 1), |
|
843 a message for the fix (string) and an ID for a deferred |
|
844 fix (integer) |
|
845 </dd> |
|
846 </dl><a NAME="CodeStyleFixer.__fixE201" ID="CodeStyleFixer.__fixE201"></a> |
|
847 <h4>CodeStyleFixer.__fixE201</h4> |
|
848 <b>__fixE201</b>(<i>code, line, pos</i>) |
|
849 <p> |
|
850 Private method to fix extraneous whitespace. |
|
851 </p><p> |
|
852 Codes: E201, E202, E203, E211 |
|
853 </p><dl> |
|
854 <dt><i>code</i></dt> |
|
855 <dd> |
|
856 code of the issue (string) |
|
857 </dd><dt><i>line</i></dt> |
|
858 <dd> |
|
859 line number of the issue (integer) |
|
860 </dd><dt><i>pos</i></dt> |
|
861 <dd> |
|
862 position inside line (integer) |
|
863 </dd> |
|
864 </dl><dl> |
|
865 <dt>Returns:</dt> |
|
866 <dd> |
|
867 value indicating an applied/deferred fix (-1, 0, 1), |
|
868 a message for the fix (string) and an ID for a deferred |
|
869 fix (integer) |
|
870 </dd> |
|
871 </dl><a NAME="CodeStyleFixer.__fixE221" ID="CodeStyleFixer.__fixE221"></a> |
|
872 <h4>CodeStyleFixer.__fixE221</h4> |
|
873 <b>__fixE221</b>(<i>code, line, pos</i>) |
|
874 <p> |
|
875 Private method to fix extraneous whitespace around operator or |
|
876 keyword. |
|
877 </p><p> |
|
878 Codes: E221, E222, E223, E224, E225, E226, E227, E228, E241, |
|
879 E242, E271, E272, E273, E274). |
|
880 </p><dl> |
|
881 <dt><i>code</i></dt> |
|
882 <dd> |
|
883 code of the issue (string) |
|
884 </dd><dt><i>line</i></dt> |
|
885 <dd> |
|
886 line number of the issue (integer) |
|
887 </dd><dt><i>pos</i></dt> |
|
888 <dd> |
|
889 position inside line (integer) |
|
890 </dd> |
|
891 </dl><dl> |
|
892 <dt>Returns:</dt> |
|
893 <dd> |
|
894 value indicating an applied/deferred fix (-1, 0, 1), |
|
895 a message for the fix (string) and an ID for a deferred |
|
896 fix (integer) |
|
897 </dd> |
|
898 </dl><a NAME="CodeStyleFixer.__fixE231" ID="CodeStyleFixer.__fixE231"></a> |
|
899 <h4>CodeStyleFixer.__fixE231</h4> |
|
900 <b>__fixE231</b>(<i>code, line, pos</i>) |
|
901 <p> |
|
902 Private method to fix missing whitespace after ',;:'. |
|
903 </p><p> |
|
904 Codes: E231 |
|
905 </p><dl> |
|
906 <dt><i>code</i></dt> |
|
907 <dd> |
|
908 code of the issue (string) |
|
909 </dd><dt><i>line</i></dt> |
|
910 <dd> |
|
911 line number of the issue (integer) |
|
912 </dd><dt><i>pos</i></dt> |
|
913 <dd> |
|
914 position inside line (integer) |
|
915 </dd> |
|
916 </dl><dl> |
|
917 <dt>Returns:</dt> |
|
918 <dd> |
|
919 value indicating an applied/deferred fix (-1, 0, 1), |
|
920 a message for the fix (string) and an ID for a deferred |
|
921 fix (integer) |
|
922 </dd> |
|
923 </dl><a NAME="CodeStyleFixer.__fixE251" ID="CodeStyleFixer.__fixE251"></a> |
|
924 <h4>CodeStyleFixer.__fixE251</h4> |
|
925 <b>__fixE251</b>(<i>code, line, pos</i>) |
|
926 <p> |
|
927 Private method to fix extraneous whitespace around keyword and |
|
928 default parameter equals. |
|
929 </p><p> |
|
930 Codes: E251 |
|
931 </p><dl> |
|
932 <dt><i>code</i></dt> |
|
933 <dd> |
|
934 code of the issue (string) |
|
935 </dd><dt><i>line</i></dt> |
|
936 <dd> |
|
937 line number of the issue (integer) |
|
938 </dd><dt><i>pos</i></dt> |
|
939 <dd> |
|
940 position inside line (integer) |
|
941 </dd> |
|
942 </dl><dl> |
|
943 <dt>Returns:</dt> |
|
944 <dd> |
|
945 value indicating an applied/deferred fix (-1, 0, 1), |
|
946 a message for the fix (string) and an ID for a deferred |
|
947 fix (integer) |
|
948 </dd> |
|
949 </dl><a NAME="CodeStyleFixer.__fixE261" ID="CodeStyleFixer.__fixE261"></a> |
|
950 <h4>CodeStyleFixer.__fixE261</h4> |
|
951 <b>__fixE261</b>(<i>code, line, pos</i>) |
|
952 <p> |
|
953 Private method to fix whitespace before or after inline comment. |
|
954 </p><p> |
|
955 Codes: E261, E262 |
|
956 </p><dl> |
|
957 <dt><i>code</i></dt> |
|
958 <dd> |
|
959 code of the issue (string) |
|
960 </dd><dt><i>line</i></dt> |
|
961 <dd> |
|
962 line number of the issue (integer) |
|
963 </dd><dt><i>pos</i></dt> |
|
964 <dd> |
|
965 position inside line (integer) |
|
966 </dd> |
|
967 </dl><dl> |
|
968 <dt>Returns:</dt> |
|
969 <dd> |
|
970 value indicating an applied/deferred fix (-1, 0, 1), |
|
971 a message for the fix (string) and an ID for a deferred |
|
972 fix (integer) |
|
973 </dd> |
|
974 </dl><a NAME="CodeStyleFixer.__fixE301" ID="CodeStyleFixer.__fixE301"></a> |
|
975 <h4>CodeStyleFixer.__fixE301</h4> |
|
976 <b>__fixE301</b>(<i>code, line, pos, apply=False</i>) |
|
977 <p> |
|
978 Private method to fix the need for one blank line. |
|
979 </p><p> |
|
980 Codes: E301 |
|
981 </p><dl> |
|
982 <dt><i>code</i></dt> |
|
983 <dd> |
|
984 code of the issue (string) |
|
985 </dd><dt><i>line</i></dt> |
|
986 <dd> |
|
987 line number of the issue (integer) |
|
988 </dd><dt><i>pos</i></dt> |
|
989 <dd> |
|
990 position inside line (integer) |
|
991 </dd><dt><i>apply=</i></dt> |
|
992 <dd> |
|
993 flag indicating, that the fix should be applied |
|
994 (boolean) |
|
995 </dd> |
|
996 </dl><dl> |
|
997 <dt>Returns:</dt> |
|
998 <dd> |
|
999 value indicating an applied/deferred fix (-1, 0, 1), |
|
1000 a message for the fix (string) and an ID for a deferred |
|
1001 fix (integer) |
|
1002 </dd> |
|
1003 </dl><a NAME="CodeStyleFixer.__fixE302" ID="CodeStyleFixer.__fixE302"></a> |
|
1004 <h4>CodeStyleFixer.__fixE302</h4> |
|
1005 <b>__fixE302</b>(<i>code, line, pos, apply=False</i>) |
|
1006 <p> |
|
1007 Private method to fix the need for two blank lines. |
|
1008 </p><p> |
|
1009 Codes: E302 |
|
1010 </p><dl> |
|
1011 <dt><i>code</i></dt> |
|
1012 <dd> |
|
1013 code of the issue (string) |
|
1014 </dd><dt><i>line</i></dt> |
|
1015 <dd> |
|
1016 line number of the issue (integer) |
|
1017 </dd><dt><i>pos</i></dt> |
|
1018 <dd> |
|
1019 position inside line (integer) |
|
1020 </dd><dt><i>apply=</i></dt> |
|
1021 <dd> |
|
1022 flag indicating, that the fix should be applied |
|
1023 (boolean) |
|
1024 </dd> |
|
1025 </dl><dl> |
|
1026 <dt>Returns:</dt> |
|
1027 <dd> |
|
1028 value indicating an applied/deferred fix (-1, 0, 1), |
|
1029 a message for the fix (string) and an ID for a deferred |
|
1030 fix (integer) |
|
1031 </dd> |
|
1032 </dl><a NAME="CodeStyleFixer.__fixE303" ID="CodeStyleFixer.__fixE303"></a> |
|
1033 <h4>CodeStyleFixer.__fixE303</h4> |
|
1034 <b>__fixE303</b>(<i>code, line, pos, apply=False</i>) |
|
1035 <p> |
|
1036 Private method to fix superfluous blank lines. |
|
1037 </p><p> |
|
1038 Codes: E303 |
|
1039 </p><dl> |
|
1040 <dt><i>code</i></dt> |
|
1041 <dd> |
|
1042 code of the issue (string) |
|
1043 </dd><dt><i>line</i></dt> |
|
1044 <dd> |
|
1045 line number of the issue (integer) |
|
1046 </dd><dt><i>pos</i></dt> |
|
1047 <dd> |
|
1048 position inside line (integer) |
|
1049 </dd><dt><i>apply=</i></dt> |
|
1050 <dd> |
|
1051 flag indicating, that the fix should be applied |
|
1052 (boolean) |
|
1053 </dd> |
|
1054 </dl><dl> |
|
1055 <dt>Returns:</dt> |
|
1056 <dd> |
|
1057 value indicating an applied/deferred fix (-1, 0, 1), |
|
1058 a message for the fix (string) and an ID for a deferred |
|
1059 fix (integer) |
|
1060 </dd> |
|
1061 </dl><a NAME="CodeStyleFixer.__fixE304" ID="CodeStyleFixer.__fixE304"></a> |
|
1062 <h4>CodeStyleFixer.__fixE304</h4> |
|
1063 <b>__fixE304</b>(<i>code, line, pos, apply=False</i>) |
|
1064 <p> |
|
1065 Private method to fix superfluous blank lines after a function |
|
1066 decorator. |
|
1067 </p><p> |
|
1068 Codes: E304 |
|
1069 </p><dl> |
|
1070 <dt><i>code</i></dt> |
|
1071 <dd> |
|
1072 code of the issue (string) |
|
1073 </dd><dt><i>line</i></dt> |
|
1074 <dd> |
|
1075 line number of the issue (integer) |
|
1076 </dd><dt><i>pos</i></dt> |
|
1077 <dd> |
|
1078 position inside line (integer) |
|
1079 </dd><dt><i>apply=</i></dt> |
|
1080 <dd> |
|
1081 flag indicating, that the fix should be applied |
|
1082 (boolean) |
|
1083 </dd> |
|
1084 </dl><dl> |
|
1085 <dt>Returns:</dt> |
|
1086 <dd> |
|
1087 value indicating an applied/deferred fix (-1, 0, 1), |
|
1088 a message for the fix (string) and an ID for a deferred |
|
1089 fix (integer) |
|
1090 </dd> |
|
1091 </dl><a NAME="CodeStyleFixer.__fixE401" ID="CodeStyleFixer.__fixE401"></a> |
|
1092 <h4>CodeStyleFixer.__fixE401</h4> |
|
1093 <b>__fixE401</b>(<i>code, line, pos, apply=False</i>) |
|
1094 <p> |
|
1095 Private method to fix multiple imports on one line. |
|
1096 </p><p> |
|
1097 Codes: E401 |
|
1098 </p><dl> |
|
1099 <dt><i>code</i></dt> |
|
1100 <dd> |
|
1101 code of the issue (string) |
|
1102 </dd><dt><i>line</i></dt> |
|
1103 <dd> |
|
1104 line number of the issue (integer) |
|
1105 </dd><dt><i>pos</i></dt> |
|
1106 <dd> |
|
1107 position inside line (integer) |
|
1108 </dd><dt><i>apply=</i></dt> |
|
1109 <dd> |
|
1110 flag indicating, that the fix should be applied |
|
1111 (boolean) |
|
1112 </dd> |
|
1113 </dl><dl> |
|
1114 <dt>Returns:</dt> |
|
1115 <dd> |
|
1116 value indicating an applied/deferred fix (-1, 0, 1), |
|
1117 a message for the fix (string) and an ID for a deferred |
|
1118 fix (integer) |
|
1119 </dd> |
|
1120 </dl><a NAME="CodeStyleFixer.__fixE501" ID="CodeStyleFixer.__fixE501"></a> |
|
1121 <h4>CodeStyleFixer.__fixE501</h4> |
|
1122 <b>__fixE501</b>(<i>code, line, pos, apply=False</i>) |
|
1123 <p> |
|
1124 Private method to fix the long lines by breaking them. |
|
1125 </p><p> |
|
1126 Codes: E501 |
|
1127 </p><dl> |
|
1128 <dt><i>code</i></dt> |
|
1129 <dd> |
|
1130 code of the issue (string) |
|
1131 </dd><dt><i>line</i></dt> |
|
1132 <dd> |
|
1133 line number of the issue (integer) |
|
1134 </dd><dt><i>pos</i></dt> |
|
1135 <dd> |
|
1136 position inside line (integer) |
|
1137 </dd><dt><i>apply=</i></dt> |
|
1138 <dd> |
|
1139 flag indicating, that the fix should be applied |
|
1140 (boolean) |
|
1141 </dd> |
|
1142 </dl><dl> |
|
1143 <dt>Returns:</dt> |
|
1144 <dd> |
|
1145 value indicating an applied/deferred fix (-1, 0, 1), |
|
1146 a message for the fix (string) and an ID for a deferred |
|
1147 fix (integer) |
|
1148 </dd> |
|
1149 </dl><a NAME="CodeStyleFixer.__fixE502" ID="CodeStyleFixer.__fixE502"></a> |
|
1150 <h4>CodeStyleFixer.__fixE502</h4> |
|
1151 <b>__fixE502</b>(<i>code, line, pos</i>) |
|
1152 <p> |
|
1153 Private method to fix redundant backslash within brackets. |
|
1154 </p><p> |
|
1155 Codes: E502 |
|
1156 </p><dl> |
|
1157 <dt><i>code</i></dt> |
|
1158 <dd> |
|
1159 code of the issue (string) |
|
1160 </dd><dt><i>line</i></dt> |
|
1161 <dd> |
|
1162 line number of the issue (integer) |
|
1163 </dd><dt><i>pos</i></dt> |
|
1164 <dd> |
|
1165 position inside line (integer) |
|
1166 </dd> |
|
1167 </dl><dl> |
|
1168 <dt>Returns:</dt> |
|
1169 <dd> |
|
1170 value indicating an applied/deferred fix (-1, 0, 1), |
|
1171 a message for the fix (string) and an ID for a deferred |
|
1172 fix (integer) |
|
1173 </dd> |
|
1174 </dl><a NAME="CodeStyleFixer.__fixE701" ID="CodeStyleFixer.__fixE701"></a> |
|
1175 <h4>CodeStyleFixer.__fixE701</h4> |
|
1176 <b>__fixE701</b>(<i>code, line, pos, apply=False</i>) |
|
1177 <p> |
|
1178 Private method to fix colon-separated compound statements. |
|
1179 </p><p> |
|
1180 Codes: E701 |
|
1181 </p><dl> |
|
1182 <dt><i>code</i></dt> |
|
1183 <dd> |
|
1184 code of the issue (string) |
|
1185 </dd><dt><i>line</i></dt> |
|
1186 <dd> |
|
1187 line number of the issue (integer) |
|
1188 </dd><dt><i>pos</i></dt> |
|
1189 <dd> |
|
1190 position inside line (integer) |
|
1191 </dd><dt><i>apply=</i></dt> |
|
1192 <dd> |
|
1193 flag indicating, that the fix should be applied |
|
1194 (boolean) |
|
1195 </dd> |
|
1196 </dl><dl> |
|
1197 <dt>Returns:</dt> |
|
1198 <dd> |
|
1199 value indicating an applied/deferred fix (-1, 0, 1), |
|
1200 a message for the fix (string) and an ID for a deferred |
|
1201 fix (integer) |
|
1202 </dd> |
|
1203 </dl><a NAME="CodeStyleFixer.__fixE702" ID="CodeStyleFixer.__fixE702"></a> |
|
1204 <h4>CodeStyleFixer.__fixE702</h4> |
|
1205 <b>__fixE702</b>(<i>code, line, pos, apply=False</i>) |
|
1206 <p> |
|
1207 Private method to fix semicolon-separated compound statements. |
|
1208 </p><p> |
|
1209 Codes: E702, E703 |
|
1210 </p><dl> |
|
1211 <dt><i>code</i></dt> |
|
1212 <dd> |
|
1213 code of the issue (string) |
|
1214 </dd><dt><i>line</i></dt> |
|
1215 <dd> |
|
1216 line number of the issue (integer) |
|
1217 </dd><dt><i>pos</i></dt> |
|
1218 <dd> |
|
1219 position inside line (integer) |
|
1220 </dd><dt><i>apply=</i></dt> |
|
1221 <dd> |
|
1222 flag indicating, that the fix should be applied |
|
1223 (boolean) |
|
1224 </dd> |
|
1225 </dl><dl> |
|
1226 <dt>Returns:</dt> |
|
1227 <dd> |
|
1228 value indicating an applied/deferred fix (-1, 0, 1), |
|
1229 a message for the fix (string) and an ID for a deferred |
|
1230 fix (integer) |
|
1231 </dd> |
|
1232 </dl><a NAME="CodeStyleFixer.__fixE711" ID="CodeStyleFixer.__fixE711"></a> |
|
1233 <h4>CodeStyleFixer.__fixE711</h4> |
|
1234 <b>__fixE711</b>(<i>code, line, pos</i>) |
|
1235 <p> |
|
1236 Private method to fix comparison with None. |
|
1237 </p><p> |
|
1238 Codes: E711, E712 |
|
1239 </p><dl> |
|
1240 <dt><i>code</i></dt> |
|
1241 <dd> |
|
1242 code of the issue (string) |
|
1243 </dd><dt><i>line</i></dt> |
|
1244 <dd> |
|
1245 line number of the issue (integer) |
|
1246 </dd><dt><i>pos</i></dt> |
|
1247 <dd> |
|
1248 position inside line (integer) |
|
1249 </dd> |
|
1250 </dl><dl> |
|
1251 <dt>Returns:</dt> |
|
1252 <dd> |
|
1253 value indicating an applied/deferred fix (-1, 0, 1), |
|
1254 a message for the fix (string) and an ID for a deferred |
|
1255 fix (integer) |
|
1256 </dd> |
|
1257 </dl><a NAME="CodeStyleFixer.__fixN804" ID="CodeStyleFixer.__fixN804"></a> |
|
1258 <h4>CodeStyleFixer.__fixN804</h4> |
|
1259 <b>__fixN804</b>(<i>code, line, pos, apply=False</i>) |
|
1260 <p> |
|
1261 Private method to fix a wrong first argument of normal and |
|
1262 class methods. |
|
1263 </p><p> |
|
1264 Codes: N804, N805 |
|
1265 </p><dl> |
|
1266 <dt><i>code</i></dt> |
|
1267 <dd> |
|
1268 code of the issue (string) |
|
1269 </dd><dt><i>line</i></dt> |
|
1270 <dd> |
|
1271 line number of the issue (integer) |
|
1272 </dd><dt><i>pos</i></dt> |
|
1273 <dd> |
|
1274 position inside line (integer) |
|
1275 </dd><dt><i>apply=</i></dt> |
|
1276 <dd> |
|
1277 flag indicating, that the fix should be applied |
|
1278 (boolean) |
|
1279 </dd> |
|
1280 </dl><dl> |
|
1281 <dt>Returns:</dt> |
|
1282 <dd> |
|
1283 value indicating an applied/deferred fix (-1, 0, 1), |
|
1284 a message for the fix (string) and an ID for a deferred |
|
1285 fix (integer) |
|
1286 </dd> |
|
1287 </dl><a NAME="CodeStyleFixer.__fixN806" ID="CodeStyleFixer.__fixN806"></a> |
|
1288 <h4>CodeStyleFixer.__fixN806</h4> |
|
1289 <b>__fixN806</b>(<i>code, line, pos, apply=False</i>) |
|
1290 <p> |
|
1291 Private method to fix a wrong first argument of static methods. |
|
1292 </p><p> |
|
1293 Codes: N806 |
|
1294 </p><dl> |
|
1295 <dt><i>code</i></dt> |
|
1296 <dd> |
|
1297 code of the issue (string) |
|
1298 </dd><dt><i>line</i></dt> |
|
1299 <dd> |
|
1300 line number of the issue (integer) |
|
1301 </dd><dt><i>pos</i></dt> |
|
1302 <dd> |
|
1303 position inside line (integer) |
|
1304 </dd><dt><i>apply=</i></dt> |
|
1305 <dd> |
|
1306 flag indicating, that the fix should be applied |
|
1307 (boolean) |
|
1308 </dd> |
|
1309 </dl><dl> |
|
1310 <dt>Returns:</dt> |
|
1311 <dd> |
|
1312 value indicating an applied/deferred fix (-1, 0, 1), |
|
1313 a message for the fix (string) and an ID for a deferred |
|
1314 fix (integer) |
|
1315 </dd> |
|
1316 </dl><a NAME="CodeStyleFixer.__fixReindent" ID="CodeStyleFixer.__fixReindent"></a> |
|
1317 <h4>CodeStyleFixer.__fixReindent</h4> |
|
1318 <b>__fixReindent</b>(<i>line, pos, logical</i>) |
|
1319 <p> |
|
1320 Private method to fix a badly indented line. |
|
1321 </p><p> |
|
1322 This is done by adding or removing from its initial indent only. |
|
1323 </p><dl> |
|
1324 <dt><i>line</i></dt> |
|
1325 <dd> |
|
1326 line number of the issue (integer) |
|
1327 </dd><dt><i>pos</i></dt> |
|
1328 <dd> |
|
1329 position inside line (integer) |
|
1330 </dd><dt><i>logical</i></dt> |
|
1331 <dd> |
|
1332 logical line structure |
|
1333 </dd> |
|
1334 </dl><dl> |
|
1335 <dt>Returns:</dt> |
|
1336 <dd> |
|
1337 flag indicating a change was done (boolean) |
|
1338 </dd> |
|
1339 </dl><a NAME="CodeStyleFixer.__fixW291" ID="CodeStyleFixer.__fixW291"></a> |
|
1340 <h4>CodeStyleFixer.__fixW291</h4> |
|
1341 <b>__fixW291</b>(<i>code, line, pos</i>) |
|
1342 <p> |
|
1343 Private method to fix trailing whitespace. |
|
1344 </p><p> |
|
1345 Codes: W291, W293 |
|
1346 </p><dl> |
|
1347 <dt><i>code</i></dt> |
|
1348 <dd> |
|
1349 code of the issue (string) |
|
1350 </dd><dt><i>line</i></dt> |
|
1351 <dd> |
|
1352 line number of the issue (integer) |
|
1353 </dd><dt><i>pos</i></dt> |
|
1354 <dd> |
|
1355 position inside line (integer) |
|
1356 </dd> |
|
1357 </dl><dl> |
|
1358 <dt>Returns:</dt> |
|
1359 <dd> |
|
1360 value indicating an applied/deferred fix (-1, 0, 1), |
|
1361 a message for the fix (string) and an ID for a deferred |
|
1362 fix (integer) |
|
1363 </dd> |
|
1364 </dl><a NAME="CodeStyleFixer.__fixW292" ID="CodeStyleFixer.__fixW292"></a> |
|
1365 <h4>CodeStyleFixer.__fixW292</h4> |
|
1366 <b>__fixW292</b>(<i>code, line, pos</i>) |
|
1367 <p> |
|
1368 Private method to fix a missing newline at the end of file. |
|
1369 </p><p> |
|
1370 Codes: W292 |
|
1371 </p><dl> |
|
1372 <dt><i>code</i></dt> |
|
1373 <dd> |
|
1374 code of the issue (string) |
|
1375 </dd><dt><i>line</i></dt> |
|
1376 <dd> |
|
1377 line number of the issue (integer) |
|
1378 </dd><dt><i>pos</i></dt> |
|
1379 <dd> |
|
1380 position inside line (integer) |
|
1381 </dd> |
|
1382 </dl><dl> |
|
1383 <dt>Returns:</dt> |
|
1384 <dd> |
|
1385 value indicating an applied/deferred fix (-1, 0, 1), |
|
1386 a message for the fix (string) and an ID for a deferred |
|
1387 fix (integer) |
|
1388 </dd> |
|
1389 </dl><a NAME="CodeStyleFixer.__fixW391" ID="CodeStyleFixer.__fixW391"></a> |
|
1390 <h4>CodeStyleFixer.__fixW391</h4> |
|
1391 <b>__fixW391</b>(<i>code, line, pos</i>) |
|
1392 <p> |
|
1393 Private method to fix trailing blank lines. |
|
1394 </p><p> |
|
1395 Codes: W391 |
|
1396 </p><dl> |
|
1397 <dt><i>code</i></dt> |
|
1398 <dd> |
|
1399 code of the issue (string) |
|
1400 </dd><dt><i>line</i></dt> |
|
1401 <dd> |
|
1402 line number of the issue (integer) |
|
1403 </dd><dt><i>pos</i></dt> |
|
1404 <dd> |
|
1405 position inside line (integer) |
|
1406 </dd> |
|
1407 </dl><dl> |
|
1408 <dt>Returns:</dt> |
|
1409 <dd> |
|
1410 value indicating an applied/deferred fix (-1, 0, 1), |
|
1411 a message for the fix (string) and an ID for a deferred |
|
1412 fix (integer) |
|
1413 </dd> |
|
1414 </dl><a NAME="CodeStyleFixer.__fixW603" ID="CodeStyleFixer.__fixW603"></a> |
|
1415 <h4>CodeStyleFixer.__fixW603</h4> |
|
1416 <b>__fixW603</b>(<i>code, line, pos</i>) |
|
1417 <p> |
|
1418 Private method to fix the not equal notation. |
|
1419 </p><p> |
|
1420 Codes: W603 |
|
1421 </p><dl> |
|
1422 <dt><i>code</i></dt> |
|
1423 <dd> |
|
1424 code of the issue (string) |
|
1425 </dd><dt><i>line</i></dt> |
|
1426 <dd> |
|
1427 line number of the issue (integer) |
|
1428 </dd><dt><i>pos</i></dt> |
|
1429 <dd> |
|
1430 position inside line (integer) |
|
1431 </dd> |
|
1432 </dl><dl> |
|
1433 <dt>Returns:</dt> |
|
1434 <dd> |
|
1435 value indicating an applied/deferred fix (-1, 0, 1), |
|
1436 a message for the fix (string) and an ID for a deferred |
|
1437 fix (integer) |
|
1438 </dd> |
|
1439 </dl><a NAME="CodeStyleFixer.__fixWhitespace" ID="CodeStyleFixer.__fixWhitespace"></a> |
|
1440 <h4>CodeStyleFixer.__fixWhitespace</h4> |
|
1441 <b>__fixWhitespace</b>(<i>line, offset, replacement</i>) |
|
1442 <p> |
|
1443 Private method to correct whitespace at the given offset. |
|
1444 </p><dl> |
|
1445 <dt><i>line</i></dt> |
|
1446 <dd> |
|
1447 line to be corrected (string) |
|
1448 </dd><dt><i>offset</i></dt> |
|
1449 <dd> |
|
1450 offset within line (integer) |
|
1451 </dd><dt><i>replacement</i></dt> |
|
1452 <dd> |
|
1453 replacement string (string) |
|
1454 </dd> |
|
1455 </dl><dl> |
|
1456 <dt>Returns:</dt> |
|
1457 <dd> |
|
1458 corrected line |
|
1459 </dd> |
|
1460 </dl><a NAME="CodeStyleFixer.__getID" ID="CodeStyleFixer.__getID"></a> |
|
1461 <h4>CodeStyleFixer.__getID</h4> |
|
1462 <b>__getID</b>(<i></i>) |
|
1463 <p> |
|
1464 Private method to get the ID for a deferred fix. |
|
1465 </p><dl> |
|
1466 <dt>Returns:</dt> |
|
1467 <dd> |
|
1468 ID for a deferred fix (integer) |
|
1469 </dd> |
|
1470 </dl><a NAME="CodeStyleFixer.__getIndent" ID="CodeStyleFixer.__getIndent"></a> |
|
1471 <h4>CodeStyleFixer.__getIndent</h4> |
|
1472 <b>__getIndent</b>(<i>line</i>) |
|
1473 <p> |
|
1474 Private method to get the indentation string. |
|
1475 </p><dl> |
|
1476 <dt><i>line</i></dt> |
|
1477 <dd> |
|
1478 line to determine the indentation string from (string) |
|
1479 </dd> |
|
1480 </dl><dl> |
|
1481 <dt>Returns:</dt> |
|
1482 <dd> |
|
1483 indentation string (string) |
|
1484 </dd> |
|
1485 </dl><a NAME="CodeStyleFixer.__getIndentWord" ID="CodeStyleFixer.__getIndentWord"></a> |
|
1486 <h4>CodeStyleFixer.__getIndentWord</h4> |
|
1487 <b>__getIndentWord</b>(<i></i>) |
|
1488 <p> |
|
1489 Private method to determine the indentation type. |
|
1490 </p><dl> |
|
1491 <dt>Returns:</dt> |
|
1492 <dd> |
|
1493 string to be used for an indentation (string) |
|
1494 </dd> |
|
1495 </dl><a NAME="CodeStyleFixer.__getLogical" ID="CodeStyleFixer.__getLogical"></a> |
|
1496 <h4>CodeStyleFixer.__getLogical</h4> |
|
1497 <b>__getLogical</b>(<i>line, pos</i>) |
|
1498 <p> |
|
1499 Private method to get the logical line corresponding to the given |
|
1500 position. |
|
1501 </p><dl> |
|
1502 <dt><i>line</i></dt> |
|
1503 <dd> |
|
1504 line number of the issue (integer) |
|
1505 </dd><dt><i>pos</i></dt> |
|
1506 <dd> |
|
1507 position inside line (integer) |
|
1508 </dd> |
|
1509 </dl><dl> |
|
1510 <dt>Returns:</dt> |
|
1511 <dd> |
|
1512 tuple of a tuple of two integers giving the start of the |
|
1513 logical line, another tuple of two integers giving the end |
|
1514 of the logical line and a list of strings with the original |
|
1515 source lines |
|
1516 </dd> |
|
1517 </dl><a NAME="CodeStyleFixer.__multilineStringLines" ID="CodeStyleFixer.__multilineStringLines"></a> |
|
1518 <h4>CodeStyleFixer.__multilineStringLines</h4> |
|
1519 <b>__multilineStringLines</b>(<i></i>) |
|
1520 <p> |
|
1521 Private method to determine the line numbers that are within multi line |
|
1522 strings and these which are part of a documentation string. |
|
1523 </p><dl> |
|
1524 <dt>Returns:</dt> |
|
1525 <dd> |
|
1526 tuple of a set of line numbers belonging to a multi line |
|
1527 string and a set of line numbers belonging to a multi line |
|
1528 documentation string (tuple of two set of integer) |
|
1529 </dd> |
|
1530 </dl><a NAME="CodeStyleFixer.finalize" ID="CodeStyleFixer.finalize"></a> |
|
1531 <h4>CodeStyleFixer.finalize</h4> |
|
1532 <b>finalize</b>(<i></i>) |
|
1533 <p> |
|
1534 Public method to apply all deferred fixes. |
|
1535 </p><dl> |
|
1536 <dt>Returns:</dt> |
|
1537 <dd> |
|
1538 dictionary containing the fix results |
|
1539 </dd> |
|
1540 </dl><a NAME="CodeStyleFixer.fixIssue" ID="CodeStyleFixer.fixIssue"></a> |
|
1541 <h4>CodeStyleFixer.fixIssue</h4> |
|
1542 <b>fixIssue</b>(<i>line, pos, message</i>) |
|
1543 <p> |
|
1544 Public method to fix the fixable issues. |
|
1545 </p><dl> |
|
1546 <dt><i>line</i></dt> |
|
1547 <dd> |
|
1548 line number of issue (integer) |
|
1549 </dd><dt><i>pos</i></dt> |
|
1550 <dd> |
|
1551 character position of issue (integer) |
|
1552 </dd><dt><i>message</i></dt> |
|
1553 <dd> |
|
1554 message text (string) |
|
1555 </dd> |
|
1556 </dl><dl> |
|
1557 <dt>Returns:</dt> |
|
1558 <dd> |
|
1559 value indicating an applied/deferred fix (-1, 0, 1), |
|
1560 a message for the fix (string) and an ID for a deferred |
|
1561 fix (integer) |
|
1562 </dd> |
|
1563 </dl><a NAME="CodeStyleFixer.mutualStartswith" ID="CodeStyleFixer.mutualStartswith"></a> |
|
1564 <h4>CodeStyleFixer.mutualStartswith</h4> |
|
1565 <b>mutualStartswith</b>(<i>b</i>) |
|
1566 <p> |
|
1567 Local helper method to compare the beginnings of two strings |
|
1568 against each other. |
|
1569 </p><dl> |
|
1570 <dt>Returns:</dt> |
|
1571 <dd> |
|
1572 flag indicating that one string starts with the other |
|
1573 (boolean) |
|
1574 </dd> |
|
1575 </dl><a NAME="CodeStyleFixer.saveFile" ID="CodeStyleFixer.saveFile"></a> |
|
1576 <h4>CodeStyleFixer.saveFile</h4> |
|
1577 <b>saveFile</b>(<i>encoding</i>) |
|
1578 <p> |
|
1579 Public method to save the modified file. |
|
1580 </p><dl> |
|
1581 <dt><i>encoding</i></dt> |
|
1582 <dd> |
|
1583 encoding of the source file (string) |
|
1584 </dd> |
|
1585 </dl><dl> |
|
1586 <dt>Returns:</dt> |
|
1587 <dd> |
|
1588 error message on failure (tuple of str) |
|
1589 </dd> |
|
1590 </dl> |
|
1591 <div align="right"><a href="#top">Up</a></div> |
|
1592 <hr /><hr /> |
|
1593 <a NAME="IndentationWrapper" ID="IndentationWrapper"></a> |
|
1594 <h2>IndentationWrapper</h2> |
|
1595 <p> |
|
1596 Class used by fixers dealing with indentation. |
|
1597 </p><p> |
|
1598 Each instance operates on a single logical line. |
|
1599 </p> |
|
1600 <h3>Derived from</h3> |
|
1601 object |
|
1602 <h3>Class Attributes</h3> |
|
1603 <table> |
|
1604 <tr><td>SKIP_TOKENS</td></tr> |
|
1605 </table> |
|
1606 <h3>Class Methods</h3> |
|
1607 <table> |
|
1608 <tr><td>None</td></tr> |
|
1609 </table> |
|
1610 <h3>Methods</h3> |
|
1611 <table> |
|
1612 <tr> |
|
1613 <td><a href="#IndentationWrapper.__init__">IndentationWrapper</a></td> |
|
1614 <td>Constructor</td> |
|
1615 </tr><tr> |
|
1616 <td><a href="#IndentationWrapper.__buildTokensLogical">__buildTokensLogical</a></td> |
|
1617 <td>Private method to build a logical line from a list of tokens.</td> |
|
1618 </tr><tr> |
|
1619 <td><a href="#IndentationWrapper.pep8Expected">pep8Expected</a></td> |
|
1620 <td>Public method to replicate logic in pep8.py, to know what level to indent things to.</td> |
|
1621 </tr> |
|
1622 </table> |
|
1623 <h3>Static Methods</h3> |
|
1624 <table> |
|
1625 <tr><td>None</td></tr> |
|
1626 </table> |
|
1627 <a NAME="IndentationWrapper.__init__" ID="IndentationWrapper.__init__"></a> |
|
1628 <h4>IndentationWrapper (Constructor)</h4> |
|
1629 <b>IndentationWrapper</b>(<i>physical_lines</i>) |
|
1630 <p> |
|
1631 Constructor |
|
1632 </p><dl> |
|
1633 <dt><i>physical_lines</i></dt> |
|
1634 <dd> |
|
1635 list of physical lines to operate on |
|
1636 (list of strings) |
|
1637 </dd> |
|
1638 </dl><a NAME="IndentationWrapper.__buildTokensLogical" ID="IndentationWrapper.__buildTokensLogical"></a> |
|
1639 <h4>IndentationWrapper.__buildTokensLogical</h4> |
|
1640 <b>__buildTokensLogical</b>(<i>tokens</i>) |
|
1641 <p> |
|
1642 Private method to build a logical line from a list of tokens. |
|
1643 </p><dl> |
|
1644 <dt><i>tokens</i></dt> |
|
1645 <dd> |
|
1646 list of tokens as generated by tokenize.generate_tokens |
|
1647 </dd> |
|
1648 </dl><dl> |
|
1649 <dt>Returns:</dt> |
|
1650 <dd> |
|
1651 logical line (string) |
|
1652 </dd> |
|
1653 </dl><a NAME="IndentationWrapper.pep8Expected" ID="IndentationWrapper.pep8Expected"></a> |
|
1654 <h4>IndentationWrapper.pep8Expected</h4> |
|
1655 <b>pep8Expected</b>(<i></i>) |
|
1656 <p> |
|
1657 Public method to replicate logic in pep8.py, to know what level to |
|
1658 indent things to. |
|
1659 </p><dl> |
|
1660 <dt>Returns:</dt> |
|
1661 <dd> |
|
1662 list of lists, where each list represents valid indent levels |
|
1663 for the line in question, relative from the initial indent. However, |
|
1664 the first entry is the indent level which was expected. |
|
1665 </dd> |
|
1666 </dl> |
|
1667 <div align="right"><a href="#top">Up</a></div> |
|
1668 <hr /><hr /> |
|
1669 <a NAME="LineShortener" ID="LineShortener"></a> |
|
1670 <h2>LineShortener</h2> |
|
1671 <p> |
|
1672 Class used to shorten lines to a given maximum of characters. |
|
1673 </p> |
|
1674 <h3>Derived from</h3> |
|
1675 object |
|
1676 <h3>Class Attributes</h3> |
|
1677 <table> |
|
1678 <tr><td>None</td></tr> |
|
1679 </table> |
|
1680 <h3>Class Methods</h3> |
|
1681 <table> |
|
1682 <tr><td>None</td></tr> |
|
1683 </table> |
|
1684 <h3>Methods</h3> |
|
1685 <table> |
|
1686 <tr> |
|
1687 <td><a href="#LineShortener.__init__">LineShortener</a></td> |
|
1688 <td>Constructor</td> |
|
1689 </tr><tr> |
|
1690 <td><a href="#LineShortener.__breakMultiline">__breakMultiline</a></td> |
|
1691 <td>Private method to break multi line strings.</td> |
|
1692 </tr><tr> |
|
1693 <td><a href="#LineShortener.__checkSyntax">__checkSyntax</a></td> |
|
1694 <td>Private method to check the syntax of the given code fragment.</td> |
|
1695 </tr><tr> |
|
1696 <td><a href="#LineShortener.__countUnbalancedBrackets">__countUnbalancedBrackets</a></td> |
|
1697 <td>Private method to determine the number of unmatched open/close brackets.</td> |
|
1698 </tr><tr> |
|
1699 <td><a href="#LineShortener.__getIndent">__getIndent</a></td> |
|
1700 <td>Private method to get the indentation string.</td> |
|
1701 </tr><tr> |
|
1702 <td><a href="#LineShortener.__isProbablyInsideStringOrComment">__isProbablyInsideStringOrComment</a></td> |
|
1703 <td>Private method to check, if the given string might be inside a string or comment.</td> |
|
1704 </tr><tr> |
|
1705 <td><a href="#LineShortener.__lineShorteningRank">__lineShorteningRank</a></td> |
|
1706 <td>Private method to rank a candidate.</td> |
|
1707 </tr><tr> |
|
1708 <td><a href="#LineShortener.__normalizeMultiline">__normalizeMultiline</a></td> |
|
1709 <td>Private method to remove multiline-related code that will cause syntax error.</td> |
|
1710 </tr><tr> |
|
1711 <td><a href="#LineShortener.__shortenComment">__shortenComment</a></td> |
|
1712 <td>Private method to shorten a comment line.</td> |
|
1713 </tr><tr> |
|
1714 <td><a href="#LineShortener.__shortenLine">__shortenLine</a></td> |
|
1715 <td>Private method to shorten a line of code at an operator.</td> |
|
1716 </tr><tr> |
|
1717 <td><a href="#LineShortener.shorten">shorten</a></td> |
|
1718 <td>Public method to shorten the line wrapped by the class instance.</td> |
|
1719 </tr> |
|
1720 </table> |
|
1721 <h3>Static Methods</h3> |
|
1722 <table> |
|
1723 <tr><td>None</td></tr> |
|
1724 </table> |
|
1725 <a NAME="LineShortener.__init__" ID="LineShortener.__init__"></a> |
|
1726 <h4>LineShortener (Constructor)</h4> |
|
1727 <b>LineShortener</b>(<i>curLine, prevLine, nextLine, maxLength=79, eol="\n", indentWord=" ", isDocString=False</i>) |
|
1728 <p> |
|
1729 Constructor |
|
1730 </p><dl> |
|
1731 <dt><i>curLine</i></dt> |
|
1732 <dd> |
|
1733 text to work on (string) |
|
1734 </dd><dt><i>prevLine</i></dt> |
|
1735 <dd> |
|
1736 line before the text to work on (string) |
|
1737 </dd><dt><i>nextLine</i></dt> |
|
1738 <dd> |
|
1739 line after the text to work on (string) |
|
1740 </dd><dt><i>maxLength=</i></dt> |
|
1741 <dd> |
|
1742 maximum allowed line length (integer) |
|
1743 </dd><dt><i>eol=</i></dt> |
|
1744 <dd> |
|
1745 eond-of-line marker (string) |
|
1746 </dd><dt><i>indentWord=</i></dt> |
|
1747 <dd> |
|
1748 string used for indentation (string) |
|
1749 </dd><dt><i>isDocString=</i></dt> |
|
1750 <dd> |
|
1751 flag indicating that the line belongs to |
|
1752 a documentation string (boolean) |
|
1753 </dd> |
|
1754 </dl><a NAME="LineShortener.__breakMultiline" ID="LineShortener.__breakMultiline"></a> |
|
1755 <h4>LineShortener.__breakMultiline</h4> |
|
1756 <b>__breakMultiline</b>(<i></i>) |
|
1757 <p> |
|
1758 Private method to break multi line strings. |
|
1759 </p><dl> |
|
1760 <dt>Returns:</dt> |
|
1761 <dd> |
|
1762 tuple of the shortened line and the changed next line |
|
1763 (string, string) |
|
1764 </dd> |
|
1765 </dl><a NAME="LineShortener.__checkSyntax" ID="LineShortener.__checkSyntax"></a> |
|
1766 <h4>LineShortener.__checkSyntax</h4> |
|
1767 <b>__checkSyntax</b>(<i>code</i>) |
|
1768 <p> |
|
1769 Private method to check the syntax of the given code fragment. |
|
1770 </p><dl> |
|
1771 <dt><i>code</i></dt> |
|
1772 <dd> |
|
1773 code fragment to check (string) |
|
1774 </dd> |
|
1775 </dl><dl> |
|
1776 <dt>Returns:</dt> |
|
1777 <dd> |
|
1778 flag indicating syntax is ok (boolean) |
|
1779 </dd> |
|
1780 </dl><a NAME="LineShortener.__countUnbalancedBrackets" ID="LineShortener.__countUnbalancedBrackets"></a> |
|
1781 <h4>LineShortener.__countUnbalancedBrackets</h4> |
|
1782 <b>__countUnbalancedBrackets</b>(<i>line</i>) |
|
1783 <p> |
|
1784 Private method to determine the number of unmatched open/close |
|
1785 brackets. |
|
1786 </p><dl> |
|
1787 <dt><i>line</i></dt> |
|
1788 <dd> |
|
1789 line to work at (string) |
|
1790 </dd> |
|
1791 </dl><dl> |
|
1792 <dt>Returns:</dt> |
|
1793 <dd> |
|
1794 number of unmatched open/close brackets (integer) |
|
1795 </dd> |
|
1796 </dl><a NAME="LineShortener.__getIndent" ID="LineShortener.__getIndent"></a> |
|
1797 <h4>LineShortener.__getIndent</h4> |
|
1798 <b>__getIndent</b>(<i>line</i>) |
|
1799 <p> |
|
1800 Private method to get the indentation string. |
|
1801 </p><dl> |
|
1802 <dt><i>line</i></dt> |
|
1803 <dd> |
|
1804 line to determine the indentation string from (string) |
|
1805 </dd> |
|
1806 </dl><dl> |
|
1807 <dt>Returns:</dt> |
|
1808 <dd> |
|
1809 indentation string (string) |
|
1810 </dd> |
|
1811 </dl><a NAME="LineShortener.__isProbablyInsideStringOrComment" ID="LineShortener.__isProbablyInsideStringOrComment"></a> |
|
1812 <h4>LineShortener.__isProbablyInsideStringOrComment</h4> |
|
1813 <b>__isProbablyInsideStringOrComment</b>(<i>line, index</i>) |
|
1814 <p> |
|
1815 Private method to check, if the given string might be inside a string |
|
1816 or comment. |
|
1817 </p><dl> |
|
1818 <dt><i>line</i></dt> |
|
1819 <dd> |
|
1820 line to check (string) |
|
1821 </dd><dt><i>index</i></dt> |
|
1822 <dd> |
|
1823 position inside line to check (integer) |
|
1824 </dd> |
|
1825 </dl><dl> |
|
1826 <dt>Returns:</dt> |
|
1827 <dd> |
|
1828 flag indicating the possibility of being inside a string |
|
1829 or comment |
|
1830 </dd> |
|
1831 </dl><a NAME="LineShortener.__lineShorteningRank" ID="LineShortener.__lineShorteningRank"></a> |
|
1832 <h4>LineShortener.__lineShorteningRank</h4> |
|
1833 <b>__lineShorteningRank</b>(<i>candidate</i>) |
|
1834 <p> |
|
1835 Private method to rank a candidate. |
|
1836 </p><dl> |
|
1837 <dt><i>candidate</i></dt> |
|
1838 <dd> |
|
1839 candidate line to rank (string) |
|
1840 </dd> |
|
1841 </dl><dl> |
|
1842 <dt>Returns:</dt> |
|
1843 <dd> |
|
1844 rank of the candidate (integer) |
|
1845 </dd> |
|
1846 </dl><a NAME="LineShortener.__normalizeMultiline" ID="LineShortener.__normalizeMultiline"></a> |
|
1847 <h4>LineShortener.__normalizeMultiline</h4> |
|
1848 <b>__normalizeMultiline</b>(<i>text</i>) |
|
1849 <p> |
|
1850 Private method to remove multiline-related code that will cause syntax |
|
1851 error. |
|
1852 </p><dl> |
|
1853 <dt><i>text</i></dt> |
|
1854 <dd> |
|
1855 code line to work on (string) |
|
1856 </dd> |
|
1857 </dl><dl> |
|
1858 <dt>Returns:</dt> |
|
1859 <dd> |
|
1860 normalized code line (string) |
|
1861 </dd> |
|
1862 </dl><a NAME="LineShortener.__shortenComment" ID="LineShortener.__shortenComment"></a> |
|
1863 <h4>LineShortener.__shortenComment</h4> |
|
1864 <b>__shortenComment</b>(<i>isLast</i>) |
|
1865 <p> |
|
1866 Private method to shorten a comment line. |
|
1867 </p><dl> |
|
1868 <dt><i>isLast</i></dt> |
|
1869 <dd> |
|
1870 flag indicating, that the line is the last comment line |
|
1871 (boolean) |
|
1872 </dd> |
|
1873 </dl><dl> |
|
1874 <dt>Returns:</dt> |
|
1875 <dd> |
|
1876 shortened comment line (string) |
|
1877 </dd> |
|
1878 </dl><a NAME="LineShortener.__shortenLine" ID="LineShortener.__shortenLine"></a> |
|
1879 <h4>LineShortener.__shortenLine</h4> |
|
1880 <b>__shortenLine</b>(<i>tokens, source, indent</i>) |
|
1881 <p> |
|
1882 Private method to shorten a line of code at an operator. |
|
1883 </p><dl> |
|
1884 <dt><i>tokens</i></dt> |
|
1885 <dd> |
|
1886 tokens of the line as generated by tokenize |
|
1887 (list of token) |
|
1888 </dd><dt><i>source</i></dt> |
|
1889 <dd> |
|
1890 code string to work at (string) |
|
1891 </dd><dt><i>indent</i></dt> |
|
1892 <dd> |
|
1893 indentation string of the code line (string) |
|
1894 </dd> |
|
1895 </dl><dl> |
|
1896 <dt>Returns:</dt> |
|
1897 <dd> |
|
1898 list of candidates (list of string) |
|
1899 </dd> |
|
1900 </dl><a NAME="LineShortener.shorten" ID="LineShortener.shorten"></a> |
|
1901 <h4>LineShortener.shorten</h4> |
|
1902 <b>shorten</b>(<i></i>) |
|
1903 <p> |
|
1904 Public method to shorten the line wrapped by the class instance. |
|
1905 </p><dl> |
|
1906 <dt>Returns:</dt> |
|
1907 <dd> |
|
1908 tuple of a flag indicating successful shortening, the |
|
1909 shortened line and the changed next line (boolean, string, string) |
|
1910 </dd> |
|
1911 </dl> |
|
1912 <div align="right"><a href="#top">Up</a></div> |
|
1913 <hr /><hr /> |
|
1914 <a NAME="Reindenter" ID="Reindenter"></a> |
|
1915 <h2>Reindenter</h2> |
|
1916 <p> |
|
1917 Class to reindent badly-indented code to uniformly use four-space |
|
1918 indentation. |
|
1919 </p><p> |
|
1920 Released to the public domain, by Tim Peters, 03 October 2000. |
|
1921 </p> |
|
1922 <h3>Derived from</h3> |
|
1923 object |
|
1924 <h3>Class Attributes</h3> |
|
1925 <table> |
|
1926 <tr><td>None</td></tr> |
|
1927 </table> |
|
1928 <h3>Class Methods</h3> |
|
1929 <table> |
|
1930 <tr><td>None</td></tr> |
|
1931 </table> |
|
1932 <h3>Methods</h3> |
|
1933 <table> |
|
1934 <tr> |
|
1935 <td><a href="#Reindenter.__init__">Reindenter</a></td> |
|
1936 <td>Constructor</td> |
|
1937 </tr><tr> |
|
1938 <td><a href="#Reindenter.__genStats">__genStats</a></td> |
|
1939 <td>Private method to generate the re-indent statistics.</td> |
|
1940 </tr><tr> |
|
1941 <td><a href="#Reindenter.__getlspace">__getlspace</a></td> |
|
1942 <td>Private method to count number of leading blanks.</td> |
|
1943 </tr><tr> |
|
1944 <td><a href="#Reindenter.fixedLine">fixedLine</a></td> |
|
1945 <td>Public method to get a fixed line.</td> |
|
1946 </tr><tr> |
|
1947 <td><a href="#Reindenter.getline">getline</a></td> |
|
1948 <td>Public method to get a line of text for tokenize.</td> |
|
1949 </tr><tr> |
|
1950 <td><a href="#Reindenter.run">run</a></td> |
|
1951 <td>Public method to run the re-indenter.</td> |
|
1952 </tr> |
|
1953 </table> |
|
1954 <h3>Static Methods</h3> |
|
1955 <table> |
|
1956 <tr><td>None</td></tr> |
|
1957 </table> |
|
1958 <a NAME="Reindenter.__init__" ID="Reindenter.__init__"></a> |
|
1959 <h4>Reindenter (Constructor)</h4> |
|
1960 <b>Reindenter</b>(<i>sourceLines</i>) |
|
1961 <p> |
|
1962 Constructor |
|
1963 </p><dl> |
|
1964 <dt><i>sourceLines</i></dt> |
|
1965 <dd> |
|
1966 list of source lines including eol marker |
|
1967 (list of string) |
|
1968 </dd> |
|
1969 </dl><a NAME="Reindenter.__genStats" ID="Reindenter.__genStats"></a> |
|
1970 <h4>Reindenter.__genStats</h4> |
|
1971 <b>__genStats</b>(<i>tokens</i>) |
|
1972 <p> |
|
1973 Private method to generate the re-indent statistics. |
|
1974 </p><dl> |
|
1975 <dt><i>tokens</i></dt> |
|
1976 <dd> |
|
1977 tokens generator (tokenize._tokenize) |
|
1978 </dd> |
|
1979 </dl><dl> |
|
1980 <dt>Returns:</dt> |
|
1981 <dd> |
|
1982 reference to the generated statistics |
|
1983 </dd> |
|
1984 </dl><a NAME="Reindenter.__getlspace" ID="Reindenter.__getlspace"></a> |
|
1985 <h4>Reindenter.__getlspace</h4> |
|
1986 <b>__getlspace</b>(<i>line</i>) |
|
1987 <p> |
|
1988 Private method to count number of leading blanks. |
|
1989 </p><dl> |
|
1990 <dt><i>line</i></dt> |
|
1991 <dd> |
|
1992 line to check (string) |
|
1993 </dd> |
|
1994 </dl><dl> |
|
1995 <dt>Returns:</dt> |
|
1996 <dd> |
|
1997 number of leading blanks (integer) |
|
1998 </dd> |
|
1999 </dl><a NAME="Reindenter.fixedLine" ID="Reindenter.fixedLine"></a> |
|
2000 <h4>Reindenter.fixedLine</h4> |
|
2001 <b>fixedLine</b>(<i>line</i>) |
|
2002 <p> |
|
2003 Public method to get a fixed line. |
|
2004 </p><dl> |
|
2005 <dt><i>line</i></dt> |
|
2006 <dd> |
|
2007 number of the line to retrieve (integer) |
|
2008 </dd> |
|
2009 </dl><dl> |
|
2010 <dt>Returns:</dt> |
|
2011 <dd> |
|
2012 fixed line (string) |
|
2013 </dd> |
|
2014 </dl><a NAME="Reindenter.getline" ID="Reindenter.getline"></a> |
|
2015 <h4>Reindenter.getline</h4> |
|
2016 <b>getline</b>(<i></i>) |
|
2017 <p> |
|
2018 Public method to get a line of text for tokenize. |
|
2019 </p><dl> |
|
2020 <dt>Returns:</dt> |
|
2021 <dd> |
|
2022 line of text (string) |
|
2023 </dd> |
|
2024 </dl><a NAME="Reindenter.run" ID="Reindenter.run"></a> |
|
2025 <h4>Reindenter.run</h4> |
|
2026 <b>run</b>(<i></i>) |
|
2027 <p> |
|
2028 Public method to run the re-indenter. |
|
2029 </p><dl> |
|
2030 <dt>Returns:</dt> |
|
2031 <dd> |
|
2032 flag indicating that a change was done (boolean) |
|
2033 </dd> |
|
2034 </dl> |
|
2035 <div align="right"><a href="#top">Up</a></div> |
|
2036 <hr /> |
|
2037 </body></html> |