eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer.html

branch
eric7
changeset 8372
e0227a7c850e
child 8596
d64760b2da50
equal deleted inserted replaced
8371:d6062691d424 8372:e0227a7c850e
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.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>
22 <a NAME="top" ID="top"></a>
23 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleFixer</h1>
24
25 <p>
26 Module implementing a class to fix certain code style issues.
27 </p>
28 <h3>Global Attributes</h3>
29
30 <table>
31 <tr><td>FixableCodeStyleIssues</td></tr>
32 </table>
33 <h3>Classes</h3>
34
35 <table>
36
37 <tr>
38 <td><a href="#CodeStyleFixer">CodeStyleFixer</a></td>
39 <td>Class implementing a fixer for certain code style issues.</td>
40 </tr>
41 <tr>
42 <td><a href="#IndentationWrapper">IndentationWrapper</a></td>
43 <td>Class used by fixers dealing with indentation.</td>
44 </tr>
45 <tr>
46 <td><a href="#LineShortener">LineShortener</a></td>
47 <td>Class used to shorten lines to a given maximum of characters.</td>
48 </tr>
49 <tr>
50 <td><a href="#Reindenter">Reindenter</a></td>
51 <td>Class to reindent badly-indented code to uniformly use four-space indentation.</td>
52 </tr>
53 </table>
54 <h3>Functions</h3>
55
56 <table>
57 <tr><td>None</td></tr>
58 </table>
59 <hr />
60 <hr />
61 <a NAME="CodeStyleFixer" ID="CodeStyleFixer"></a>
62 <h2>CodeStyleFixer</h2>
63
64 <p>
65 Class implementing a fixer for certain code style issues.
66 </p>
67 <h3>Derived from</h3>
68 None
69 <h3>Class Attributes</h3>
70
71 <table>
72 <tr><td>None</td></tr>
73 </table>
74 <h3>Class Methods</h3>
75
76 <table>
77 <tr><td>None</td></tr>
78 </table>
79 <h3>Methods</h3>
80
81 <table>
82
83 <tr>
84 <td><a href="#CodeStyleFixer.__init__">CodeStyleFixer</a></td>
85 <td>Constructor</td>
86 </tr>
87 <tr>
88 <td><a href="#CodeStyleFixer.__codeMatch">__codeMatch</a></td>
89 <td>Private method to check, if the code should be fixed.</td>
90 </tr>
91 <tr>
92 <td><a href="#CodeStyleFixer.__findLogical">__findLogical</a></td>
93 <td>Private method to extract the index of all the starts and ends of lines.</td>
94 </tr>
95 <tr>
96 <td><a href="#CodeStyleFixer.__fixBlankLinesBefore">__fixBlankLinesBefore</a></td>
97 <td>Private method to fix the need for blank lines before class, function and method definitions.</td>
98 </tr>
99 <tr>
100 <td><a href="#CodeStyleFixer.__fixD111">__fixD111</a></td>
101 <td>Private method to fix docstring enclosed in wrong quotes.</td>
102 </tr>
103 <tr>
104 <td><a href="#CodeStyleFixer.__fixD112">__fixD112</a></td>
105 <td>Private method to fix docstring 'r' in leading quotes.</td>
106 </tr>
107 <tr>
108 <td><a href="#CodeStyleFixer.__fixD121">__fixD121</a></td>
109 <td>Private method to fix a single line docstring on multiple lines.</td>
110 </tr>
111 <tr>
112 <td><a href="#CodeStyleFixer.__fixD131">__fixD131</a></td>
113 <td>Private method to fix a docstring summary not ending with a period.</td>
114 </tr>
115 <tr>
116 <td><a href="#CodeStyleFixer.__fixD141">__fixD141</a></td>
117 <td>Private method to fix a function/method docstring preceded by a blank line.</td>
118 </tr>
119 <tr>
120 <td><a href="#CodeStyleFixer.__fixD142">__fixD142</a></td>
121 <td>Private method to fix a class docstring not preceded by a blank line.</td>
122 </tr>
123 <tr>
124 <td><a href="#CodeStyleFixer.__fixD143">__fixD143</a></td>
125 <td>Private method to fix a class docstring not followed by a blank line.</td>
126 </tr>
127 <tr>
128 <td><a href="#CodeStyleFixer.__fixD144">__fixD144</a></td>
129 <td>Private method to fix a docstring summary not followed by a blank line.</td>
130 </tr>
131 <tr>
132 <td><a href="#CodeStyleFixer.__fixD145">__fixD145</a></td>
133 <td>Private method to fix the last paragraph of a multi-line docstring not followed by a blank line.</td>
134 </tr>
135 <tr>
136 <td><a href="#CodeStyleFixer.__fixD221">__fixD221</a></td>
137 <td>Private method to fix leading and trailing quotes of docstring not on separate lines.</td>
138 </tr>
139 <tr>
140 <td><a href="#CodeStyleFixer.__fixD242">__fixD242</a></td>
141 <td>Private method to fix a class or function/method docstring preceded by a blank line.</td>
142 </tr>
143 <tr>
144 <td><a href="#CodeStyleFixer.__fixD243">__fixD243</a></td>
145 <td>Private method to fix a class or function/method docstring followed by a blank line.</td>
146 </tr>
147 <tr>
148 <td><a href="#CodeStyleFixer.__fixD247">__fixD247</a></td>
149 <td>Private method to fix a last paragraph of a docstring followed by a blank line.</td>
150 </tr>
151 <tr>
152 <td><a href="#CodeStyleFixer.__fixE101">__fixE101</a></td>
153 <td>Private method to fix obsolete tab usage and indentation errors.</td>
154 </tr>
155 <tr>
156 <td><a href="#CodeStyleFixer.__fixE121">__fixE121</a></td>
157 <td>Private method to fix the indentation of continuation lines and closing brackets.</td>
158 </tr>
159 <tr>
160 <td><a href="#CodeStyleFixer.__fixE122">__fixE122</a></td>
161 <td>Private method to fix a missing indentation of continuation lines.</td>
162 </tr>
163 <tr>
164 <td><a href="#CodeStyleFixer.__fixE123">__fixE123</a></td>
165 <td>Private method to fix the indentation of a closing bracket lines.</td>
166 </tr>
167 <tr>
168 <td><a href="#CodeStyleFixer.__fixE125">__fixE125</a></td>
169 <td>Private method to fix the indentation of continuation lines not distinguishable from next logical line.</td>
170 </tr>
171 <tr>
172 <td><a href="#CodeStyleFixer.__fixE126">__fixE126</a></td>
173 <td>Private method to fix over-indented/under-indented hanging indentation.</td>
174 </tr>
175 <tr>
176 <td><a href="#CodeStyleFixer.__fixE127">__fixE127</a></td>
177 <td>Private method to fix over/under indented lines.</td>
178 </tr>
179 <tr>
180 <td><a href="#CodeStyleFixer.__fixE201">__fixE201</a></td>
181 <td>Private method to fix extraneous whitespace.</td>
182 </tr>
183 <tr>
184 <td><a href="#CodeStyleFixer.__fixE221">__fixE221</a></td>
185 <td>Private method to fix extraneous whitespace around operator or keyword.</td>
186 </tr>
187 <tr>
188 <td><a href="#CodeStyleFixer.__fixE225">__fixE225</a></td>
189 <td>Private method to fix extraneous whitespaces around operator.</td>
190 </tr>
191 <tr>
192 <td><a href="#CodeStyleFixer.__fixE231">__fixE231</a></td>
193 <td>Private method to fix missing whitespace after ',;:'.</td>
194 </tr>
195 <tr>
196 <td><a href="#CodeStyleFixer.__fixE251">__fixE251</a></td>
197 <td>Private method to fix extraneous whitespace around keyword and default parameter equals.</td>
198 </tr>
199 <tr>
200 <td><a href="#CodeStyleFixer.__fixE261">__fixE261</a></td>
201 <td>Private method to fix whitespace before or after inline comment.</td>
202 </tr>
203 <tr>
204 <td><a href="#CodeStyleFixer.__fixE304">__fixE304</a></td>
205 <td>Private method to fix superfluous blank lines after a function decorator.</td>
206 </tr>
207 <tr>
208 <td><a href="#CodeStyleFixer.__fixE401">__fixE401</a></td>
209 <td>Private method to fix multiple imports on one line.</td>
210 </tr>
211 <tr>
212 <td><a href="#CodeStyleFixer.__fixE501">__fixE501</a></td>
213 <td>Private method to fix the long lines by breaking them.</td>
214 </tr>
215 <tr>
216 <td><a href="#CodeStyleFixer.__fixE502">__fixE502</a></td>
217 <td>Private method to fix redundant backslash within brackets.</td>
218 </tr>
219 <tr>
220 <td><a href="#CodeStyleFixer.__fixE701">__fixE701</a></td>
221 <td>Private method to fix colon-separated compound statements.</td>
222 </tr>
223 <tr>
224 <td><a href="#CodeStyleFixer.__fixE702">__fixE702</a></td>
225 <td>Private method to fix semicolon-separated compound statements.</td>
226 </tr>
227 <tr>
228 <td><a href="#CodeStyleFixer.__fixE711">__fixE711</a></td>
229 <td>Private method to fix comparison with None.</td>
230 </tr>
231 <tr>
232 <td><a href="#CodeStyleFixer.__fixN804">__fixN804</a></td>
233 <td>Private method to fix a wrong first argument of normal and class methods.</td>
234 </tr>
235 <tr>
236 <td><a href="#CodeStyleFixer.__fixN806">__fixN806</a></td>
237 <td>Private method to fix a wrong first argument of static methods.</td>
238 </tr>
239 <tr>
240 <td><a href="#CodeStyleFixer.__fixReindent">__fixReindent</a></td>
241 <td>Private method to fix a badly indented line.</td>
242 </tr>
243 <tr>
244 <td><a href="#CodeStyleFixer.__fixW291">__fixW291</a></td>
245 <td>Private method to fix trailing whitespace.</td>
246 </tr>
247 <tr>
248 <td><a href="#CodeStyleFixer.__fixW292">__fixW292</a></td>
249 <td>Private method to fix a missing newline at the end of file.</td>
250 </tr>
251 <tr>
252 <td><a href="#CodeStyleFixer.__fixW391">__fixW391</a></td>
253 <td>Private method to fix trailing blank lines.</td>
254 </tr>
255 <tr>
256 <td><a href="#CodeStyleFixer.__fixW603">__fixW603</a></td>
257 <td>Private method to fix the not equal notation.</td>
258 </tr>
259 <tr>
260 <td><a href="#CodeStyleFixer.__fixWhitespace">__fixWhitespace</a></td>
261 <td>Private method to correct whitespace at the given offset.</td>
262 </tr>
263 <tr>
264 <td><a href="#CodeStyleFixer.__getID">__getID</a></td>
265 <td>Private method to get the ID for a deferred fix.</td>
266 </tr>
267 <tr>
268 <td><a href="#CodeStyleFixer.__getIndent">__getIndent</a></td>
269 <td>Private method to get the indentation string.</td>
270 </tr>
271 <tr>
272 <td><a href="#CodeStyleFixer.__getIndentWord">__getIndentWord</a></td>
273 <td>Private method to determine the indentation type.</td>
274 </tr>
275 <tr>
276 <td><a href="#CodeStyleFixer.__getLogical">__getLogical</a></td>
277 <td>Private method to get the logical line corresponding to the given position.</td>
278 </tr>
279 <tr>
280 <td><a href="#CodeStyleFixer.__multilineStringLines">__multilineStringLines</a></td>
281 <td>Private method to determine the line numbers that are within multi line strings and these which are part of a documentation string.</td>
282 </tr>
283 <tr>
284 <td><a href="#CodeStyleFixer.finalize">finalize</a></td>
285 <td>Public method to apply all deferred fixes.</td>
286 </tr>
287 <tr>
288 <td><a href="#CodeStyleFixer.fixIssue">fixIssue</a></td>
289 <td>Public method to fix the fixable issues.</td>
290 </tr>
291 <tr>
292 <td><a href="#CodeStyleFixer.mutualStartswith">mutualStartswith</a></td>
293 <td>Local helper method to compare the beginnings of two strings against each other.</td>
294 </tr>
295 <tr>
296 <td><a href="#CodeStyleFixer.saveFile">saveFile</a></td>
297 <td>Public method to save the modified file.</td>
298 </tr>
299 </table>
300 <h3>Static Methods</h3>
301
302 <table>
303 <tr><td>None</td></tr>
304 </table>
305
306 <a NAME="CodeStyleFixer.__init__" ID="CodeStyleFixer.__init__"></a>
307 <h4>CodeStyleFixer (Constructor)</h4>
308 <b>CodeStyleFixer</b>(<i>filename, sourceLines, fixCodes, noFixCodes, maxLineLength, blankLines, inPlace, eol, backup=False</i>)
309
310 <p>
311 Constructor
312 </p>
313 <dl>
314
315 <dt><i>filename</i> (str)</dt>
316 <dd>
317 name of the file to be fixed
318 </dd>
319 <dt><i>sourceLines</i> (list of str)</dt>
320 <dd>
321 list of source lines including eol marker
322 </dd>
323 <dt><i>fixCodes</i> (str)</dt>
324 <dd>
325 list of codes to be fixed as a comma separated
326 string
327 </dd>
328 <dt><i>noFixCodes</i> (str)</dt>
329 <dd>
330 list of codes not to be fixed as a comma
331 separated string
332 </dd>
333 <dt><i>maxLineLength</i> (int)</dt>
334 <dd>
335 maximum allowed line length
336 </dd>
337 <dt><i>blankLines</i> (tuple of (int, int))</dt>
338 <dd>
339 tuple containg the number of blank lines before
340 a top level class or function and before a method or nested class
341 or function
342 </dd>
343 <dt><i>inPlace</i> (bool)</dt>
344 <dd>
345 flag indicating to modify the file in place
346 </dd>
347 <dt><i>eol</i> (str)</dt>
348 <dd>
349 end of line character(s)
350 </dd>
351 <dt><i>backup</i> (bool)</dt>
352 <dd>
353 flag indicating to create a backup before fixing
354 anything
355 </dd>
356 </dl>
357 <a NAME="CodeStyleFixer.__codeMatch" ID="CodeStyleFixer.__codeMatch"></a>
358 <h4>CodeStyleFixer.__codeMatch</h4>
359 <b>__codeMatch</b>(<i>code</i>)
360
361 <p>
362 Private method to check, if the code should be fixed.
363 </p>
364 <dl>
365
366 <dt><i>code</i></dt>
367 <dd>
368 to check (string)
369 </dd>
370 </dl>
371 <dl>
372 <dt>Return:</dt>
373 <dd>
374 flag indicating it should be fixed (boolean)
375 </dd>
376 </dl>
377 <a NAME="CodeStyleFixer.__findLogical" ID="CodeStyleFixer.__findLogical"></a>
378 <h4>CodeStyleFixer.__findLogical</h4>
379 <b>__findLogical</b>(<i></i>)
380
381 <p>
382 Private method to extract the index of all the starts and ends of
383 lines.
384 </p>
385 <dl>
386 <dt>Return:</dt>
387 <dd>
388 tuple containing two lists of integer with start and end tuples
389 of lines
390 </dd>
391 </dl>
392 <a NAME="CodeStyleFixer.__fixBlankLinesBefore" ID="CodeStyleFixer.__fixBlankLinesBefore"></a>
393 <h4>CodeStyleFixer.__fixBlankLinesBefore</h4>
394 <b>__fixBlankLinesBefore</b>(<i>code, line, pos, apply=False</i>)
395
396 <p>
397 Private method to fix the need for blank lines before class, function
398 and method definitions.
399 </p>
400 <p>
401 Codes: E301, E302, E303, E305, E306, E307, E308
402 </p>
403 <dl>
404
405 <dt><i>code</i> (str)</dt>
406 <dd>
407 code of the issue
408 </dd>
409 <dt><i>line</i> (int)</dt>
410 <dd>
411 line number of the issue
412 </dd>
413 <dt><i>pos</i> (int)</dt>
414 <dd>
415 position inside line
416 </dd>
417 <dt><i>apply</i> (bool)</dt>
418 <dd>
419 flag indicating, that the fix should be applied
420 </dd>
421 </dl>
422 <dl>
423 <dt>Return:</dt>
424 <dd>
425 value indicating an applied/deferred fix (-1, 0, 1),
426 a message code for the fix, a list of arguments for the
427 message and an ID for a deferred fix
428 </dd>
429 </dl>
430 <dl>
431 <dt>Return Type:</dt>
432 <dd>
433 tuple of (int, str, list or int, int)
434 </dd>
435 </dl>
436 <a NAME="CodeStyleFixer.__fixD111" ID="CodeStyleFixer.__fixD111"></a>
437 <h4>CodeStyleFixer.__fixD111</h4>
438 <b>__fixD111</b>(<i>code, line, pos</i>)
439
440 <p>
441 Private method to fix docstring enclosed in wrong quotes.
442 </p>
443 <p>
444 Codes: D111
445 </p>
446 <dl>
447
448 <dt><i>code</i> (str)</dt>
449 <dd>
450 code of the issue
451 </dd>
452 <dt><i>line</i> (int)</dt>
453 <dd>
454 line number of the issue
455 </dd>
456 <dt><i>pos</i> (int)</dt>
457 <dd>
458 position inside line
459 </dd>
460 </dl>
461 <dl>
462 <dt>Return:</dt>
463 <dd>
464 value indicating an applied/deferred fix (-1, 0, 1),
465 a message code for the fix, a list of arguments for the
466 message and an ID for a deferred fix
467 </dd>
468 </dl>
469 <dl>
470 <dt>Return Type:</dt>
471 <dd>
472 tuple of (int, str, list or int, int)
473 </dd>
474 </dl>
475 <a NAME="CodeStyleFixer.__fixD112" ID="CodeStyleFixer.__fixD112"></a>
476 <h4>CodeStyleFixer.__fixD112</h4>
477 <b>__fixD112</b>(<i>code, line, pos</i>)
478
479 <p>
480 Private method to fix docstring 'r' in leading quotes.
481 </p>
482 <p>
483 Codes: D112
484 </p>
485 <dl>
486
487 <dt><i>code</i> (str)</dt>
488 <dd>
489 code of the issue
490 </dd>
491 <dt><i>line</i> (int)</dt>
492 <dd>
493 line number of the issue
494 </dd>
495 <dt><i>pos</i> (int)</dt>
496 <dd>
497 position inside line
498 </dd>
499 </dl>
500 <dl>
501 <dt>Return:</dt>
502 <dd>
503 value indicating an applied/deferred fix (-1, 0, 1),
504 a message code for the fix, a list of arguments for the
505 message and an ID for a deferred fix
506 </dd>
507 </dl>
508 <dl>
509 <dt>Return Type:</dt>
510 <dd>
511 tuple of (int, str, list or int, int)
512 </dd>
513 </dl>
514 <a NAME="CodeStyleFixer.__fixD121" ID="CodeStyleFixer.__fixD121"></a>
515 <h4>CodeStyleFixer.__fixD121</h4>
516 <b>__fixD121</b>(<i>code, line, pos, apply=False</i>)
517
518 <p>
519 Private method to fix a single line docstring on multiple lines.
520 </p>
521 <p>
522 Codes: D121
523 </p>
524 <dl>
525
526 <dt><i>code</i> (str)</dt>
527 <dd>
528 code of the issue
529 </dd>
530 <dt><i>line</i> (int)</dt>
531 <dd>
532 line number of the issue
533 </dd>
534 <dt><i>pos</i> (int)</dt>
535 <dd>
536 position inside line
537 </dd>
538 <dt><i>apply</i> (bool)</dt>
539 <dd>
540 flag indicating, that the fix should be applied
541 </dd>
542 </dl>
543 <dl>
544 <dt>Return:</dt>
545 <dd>
546 value indicating an applied/deferred fix (-1, 0, 1),
547 a message code for the fix, a list of arguments for the
548 message and an ID for a deferred fix
549 </dd>
550 </dl>
551 <dl>
552 <dt>Return Type:</dt>
553 <dd>
554 tuple of (int, str, list or int, int)
555 </dd>
556 </dl>
557 <a NAME="CodeStyleFixer.__fixD131" ID="CodeStyleFixer.__fixD131"></a>
558 <h4>CodeStyleFixer.__fixD131</h4>
559 <b>__fixD131</b>(<i>code, line, pos</i>)
560
561 <p>
562 Private method to fix a docstring summary not ending with a
563 period.
564 </p>
565 <p>
566 Codes: D131
567 </p>
568 <dl>
569
570 <dt><i>code</i> (str)</dt>
571 <dd>
572 code of the issue
573 </dd>
574 <dt><i>line</i> (int)</dt>
575 <dd>
576 line number of the issue
577 </dd>
578 <dt><i>pos</i> (int)</dt>
579 <dd>
580 position inside line
581 </dd>
582 </dl>
583 <dl>
584 <dt>Return:</dt>
585 <dd>
586 value indicating an applied/deferred fix (-1, 0, 1),
587 a message code for the fix, a list of arguments for the
588 message and an ID for a deferred fix
589 </dd>
590 </dl>
591 <dl>
592 <dt>Return Type:</dt>
593 <dd>
594 tuple of (int, str, list or int, int)
595 </dd>
596 </dl>
597 <a NAME="CodeStyleFixer.__fixD141" ID="CodeStyleFixer.__fixD141"></a>
598 <h4>CodeStyleFixer.__fixD141</h4>
599 <b>__fixD141</b>(<i>code, line, pos, apply=False</i>)
600
601 <p>
602 Private method to fix a function/method docstring preceded by a
603 blank line.
604 </p>
605 <p>
606 Codes: D141
607 </p>
608 <dl>
609
610 <dt><i>code</i> (str)</dt>
611 <dd>
612 code of the issue
613 </dd>
614 <dt><i>line</i> (int)</dt>
615 <dd>
616 line number of the issue
617 </dd>
618 <dt><i>pos</i> (int)</dt>
619 <dd>
620 position inside line
621 </dd>
622 <dt><i>apply</i> (bool)</dt>
623 <dd>
624 flag indicating, that the fix should be applied
625 </dd>
626 </dl>
627 <dl>
628 <dt>Return:</dt>
629 <dd>
630 value indicating an applied/deferred fix (-1, 0, 1),
631 a message code for the fix, a list of arguments for the
632 message and an ID for a deferred fix
633 </dd>
634 </dl>
635 <dl>
636 <dt>Return Type:</dt>
637 <dd>
638 tuple of (int, str, list or int, int)
639 </dd>
640 </dl>
641 <a NAME="CodeStyleFixer.__fixD142" ID="CodeStyleFixer.__fixD142"></a>
642 <h4>CodeStyleFixer.__fixD142</h4>
643 <b>__fixD142</b>(<i>code, line, pos, apply=False</i>)
644
645 <p>
646 Private method to fix a class docstring not preceded by a
647 blank line.
648 </p>
649 <p>
650 Codes: D142
651 </p>
652 <dl>
653
654 <dt><i>code</i> (str)</dt>
655 <dd>
656 code of the issue
657 </dd>
658 <dt><i>line</i> (int)</dt>
659 <dd>
660 line number of the issue
661 </dd>
662 <dt><i>pos</i> (int)</dt>
663 <dd>
664 position inside line
665 </dd>
666 <dt><i>apply</i> (bool)</dt>
667 <dd>
668 flag indicating, that the fix should be applied
669 </dd>
670 </dl>
671 <dl>
672 <dt>Return:</dt>
673 <dd>
674 value indicating an applied/deferred fix (-1, 0, 1),
675 a message code for the fix, a list of arguments for the
676 message and an ID for a deferred fix
677 </dd>
678 </dl>
679 <dl>
680 <dt>Return Type:</dt>
681 <dd>
682 tuple of (int, str, list or int, int)
683 </dd>
684 </dl>
685 <a NAME="CodeStyleFixer.__fixD143" ID="CodeStyleFixer.__fixD143"></a>
686 <h4>CodeStyleFixer.__fixD143</h4>
687 <b>__fixD143</b>(<i>code, line, pos, apply=False</i>)
688
689 <p>
690 Private method to fix a class docstring not followed by a
691 blank line.
692 </p>
693 <p>
694 Codes: D143
695 </p>
696 <dl>
697
698 <dt><i>code</i> (str)</dt>
699 <dd>
700 code of the issue
701 </dd>
702 <dt><i>line</i> (int)</dt>
703 <dd>
704 line number of the issue
705 </dd>
706 <dt><i>pos</i> (int)</dt>
707 <dd>
708 position inside line
709 </dd>
710 <dt><i>apply</i> (bool)</dt>
711 <dd>
712 flag indicating, that the fix should be applied
713 </dd>
714 </dl>
715 <dl>
716 <dt>Return:</dt>
717 <dd>
718 value indicating an applied/deferred fix (-1, 0, 1),
719 a message code for the fix, a list of arguments for the
720 message and an ID for a deferred fix
721 </dd>
722 </dl>
723 <dl>
724 <dt>Return Type:</dt>
725 <dd>
726 tuple of (int, str, list or int, int)
727 </dd>
728 </dl>
729 <a NAME="CodeStyleFixer.__fixD144" ID="CodeStyleFixer.__fixD144"></a>
730 <h4>CodeStyleFixer.__fixD144</h4>
731 <b>__fixD144</b>(<i>code, line, pos, apply=False</i>)
732
733 <p>
734 Private method to fix a docstring summary not followed by a
735 blank line.
736 </p>
737 <p>
738 Codes: D144
739 </p>
740 <dl>
741
742 <dt><i>code</i> (str)</dt>
743 <dd>
744 code of the issue
745 </dd>
746 <dt><i>line</i> (int)</dt>
747 <dd>
748 line number of the issue
749 </dd>
750 <dt><i>pos</i> (int)</dt>
751 <dd>
752 position inside line
753 </dd>
754 <dt><i>apply</i> (bool)</dt>
755 <dd>
756 flag indicating, that the fix should be applied
757 </dd>
758 </dl>
759 <dl>
760 <dt>Return:</dt>
761 <dd>
762 value indicating an applied/deferred fix (-1, 0, 1),
763 a message code for the fix, a list of arguments for the
764 message and an ID for a deferred fix
765 </dd>
766 </dl>
767 <dl>
768 <dt>Return Type:</dt>
769 <dd>
770 tuple of (int, str, list or int, int)
771 </dd>
772 </dl>
773 <a NAME="CodeStyleFixer.__fixD145" ID="CodeStyleFixer.__fixD145"></a>
774 <h4>CodeStyleFixer.__fixD145</h4>
775 <b>__fixD145</b>(<i>code, line, pos, apply=False</i>)
776
777 <p>
778 Private method to fix the last paragraph of a multi-line docstring
779 not followed by a blank line.
780 </p>
781 <p>
782 Codes: D143
783 </p>
784 <dl>
785
786 <dt><i>code</i> (str)</dt>
787 <dd>
788 code of the issue
789 </dd>
790 <dt><i>line</i> (int)</dt>
791 <dd>
792 line number of the issue
793 </dd>
794 <dt><i>pos</i> (int)</dt>
795 <dd>
796 position inside line
797 </dd>
798 <dt><i>apply</i> (bool)</dt>
799 <dd>
800 flag indicating, that the fix should be applied
801 </dd>
802 </dl>
803 <dl>
804 <dt>Return:</dt>
805 <dd>
806 value indicating an applied/deferred fix (-1, 0, 1),
807 a message code for the fix, a list of arguments for the
808 message and an ID for a deferred fix
809 </dd>
810 </dl>
811 <dl>
812 <dt>Return Type:</dt>
813 <dd>
814 tuple of (int, str, list or int, int)
815 </dd>
816 </dl>
817 <a NAME="CodeStyleFixer.__fixD221" ID="CodeStyleFixer.__fixD221"></a>
818 <h4>CodeStyleFixer.__fixD221</h4>
819 <b>__fixD221</b>(<i>code, line, pos, apply=False</i>)
820
821 <p>
822 Private method to fix leading and trailing quotes of docstring
823 not on separate lines.
824 </p>
825 <p>
826 Codes: D221, D222
827 </p>
828 <dl>
829
830 <dt><i>code</i> (str)</dt>
831 <dd>
832 code of the issue
833 </dd>
834 <dt><i>line</i> (int)</dt>
835 <dd>
836 line number of the issue
837 </dd>
838 <dt><i>pos</i> (int)</dt>
839 <dd>
840 position inside line
841 </dd>
842 <dt><i>apply</i> (bool)</dt>
843 <dd>
844 flag indicating, that the fix should be applied
845 </dd>
846 </dl>
847 <dl>
848 <dt>Return:</dt>
849 <dd>
850 value indicating an applied/deferred fix (-1, 0, 1),
851 a message code for the fix, a list of arguments for the
852 message and an ID for a deferred fix
853 </dd>
854 </dl>
855 <dl>
856 <dt>Return Type:</dt>
857 <dd>
858 tuple of (int, str, list or int, int)
859 </dd>
860 </dl>
861 <a NAME="CodeStyleFixer.__fixD242" ID="CodeStyleFixer.__fixD242"></a>
862 <h4>CodeStyleFixer.__fixD242</h4>
863 <b>__fixD242</b>(<i>code, line, pos, apply=False</i>)
864
865 <p>
866 Private method to fix a class or function/method docstring preceded
867 by a blank line.
868 </p>
869 <p>
870 Codes: D242, D244
871 </p>
872 <dl>
873
874 <dt><i>code</i> (str)</dt>
875 <dd>
876 code of the issue
877 </dd>
878 <dt><i>line</i> (int)</dt>
879 <dd>
880 line number of the issue
881 </dd>
882 <dt><i>pos</i> (int)</dt>
883 <dd>
884 position inside line
885 </dd>
886 <dt><i>apply</i> (bool)</dt>
887 <dd>
888 flag indicating, that the fix should be applied
889 </dd>
890 </dl>
891 <dl>
892 <dt>Return:</dt>
893 <dd>
894 value indicating an applied/deferred fix (-1, 0, 1),
895 a message code for the fix, a list of arguments for the
896 message and an ID for a deferred fix
897 </dd>
898 </dl>
899 <dl>
900 <dt>Return Type:</dt>
901 <dd>
902 tuple of (int, str, list or int, int)
903 </dd>
904 </dl>
905 <a NAME="CodeStyleFixer.__fixD243" ID="CodeStyleFixer.__fixD243"></a>
906 <h4>CodeStyleFixer.__fixD243</h4>
907 <b>__fixD243</b>(<i>code, line, pos, apply=False</i>)
908
909 <p>
910 Private method to fix a class or function/method docstring followed
911 by a blank line.
912 </p>
913 <p>
914 Codes: D243, D245
915 </p>
916 <dl>
917
918 <dt><i>code</i> (str)</dt>
919 <dd>
920 code of the issue
921 </dd>
922 <dt><i>line</i> (int)</dt>
923 <dd>
924 line number of the issue
925 </dd>
926 <dt><i>pos</i> (int)</dt>
927 <dd>
928 position inside line
929 </dd>
930 <dt><i>apply</i> (bool)</dt>
931 <dd>
932 flag indicating, that the fix should be applied
933 </dd>
934 </dl>
935 <dl>
936 <dt>Return:</dt>
937 <dd>
938 value indicating an applied/deferred fix (-1, 0, 1),
939 a message code for the fix, a list of arguments for the
940 message and an ID for a deferred fix
941 </dd>
942 </dl>
943 <dl>
944 <dt>Return Type:</dt>
945 <dd>
946 tuple of (int, str, list or int, int)
947 </dd>
948 </dl>
949 <a NAME="CodeStyleFixer.__fixD247" ID="CodeStyleFixer.__fixD247"></a>
950 <h4>CodeStyleFixer.__fixD247</h4>
951 <b>__fixD247</b>(<i>code, line, pos, apply=False</i>)
952
953 <p>
954 Private method to fix a last paragraph of a docstring followed
955 by a blank line.
956 </p>
957 <p>
958 Codes: D247
959 </p>
960 <dl>
961
962 <dt><i>code</i> (str)</dt>
963 <dd>
964 code of the issue
965 </dd>
966 <dt><i>line</i> (int)</dt>
967 <dd>
968 line number of the issue
969 </dd>
970 <dt><i>pos</i> (int)</dt>
971 <dd>
972 position inside line
973 </dd>
974 <dt><i>apply</i> (bool)</dt>
975 <dd>
976 flag indicating, that the fix should be applied
977 </dd>
978 </dl>
979 <dl>
980 <dt>Return:</dt>
981 <dd>
982 value indicating an applied/deferred fix (-1, 0, 1),
983 a message code for the fix, a list of arguments for the
984 message and an ID for a deferred fix
985 </dd>
986 </dl>
987 <dl>
988 <dt>Return Type:</dt>
989 <dd>
990 tuple of (int, str, list or int, int)
991 </dd>
992 </dl>
993 <a NAME="CodeStyleFixer.__fixE101" ID="CodeStyleFixer.__fixE101"></a>
994 <h4>CodeStyleFixer.__fixE101</h4>
995 <b>__fixE101</b>(<i>code, line, pos</i>)
996
997 <p>
998 Private method to fix obsolete tab usage and indentation errors.
999 </p>
1000 <p>
1001 Codes: E101, E111, W191
1002 </p>
1003 <dl>
1004
1005 <dt><i>code</i> (str)</dt>
1006 <dd>
1007 code of the issue
1008 </dd>
1009 <dt><i>line</i> (int)</dt>
1010 <dd>
1011 line number of the issue
1012 </dd>
1013 <dt><i>pos</i> (int)</dt>
1014 <dd>
1015 position inside line
1016 </dd>
1017 </dl>
1018 <dl>
1019 <dt>Return:</dt>
1020 <dd>
1021 value indicating an applied/deferred fix (-1, 0, 1),
1022 a message code for the fix, a list of arguments for the
1023 message and an ID for a deferred fix
1024 </dd>
1025 </dl>
1026 <dl>
1027 <dt>Return Type:</dt>
1028 <dd>
1029 tuple of (int, str, list or int, int)
1030 </dd>
1031 </dl>
1032 <a NAME="CodeStyleFixer.__fixE121" ID="CodeStyleFixer.__fixE121"></a>
1033 <h4>CodeStyleFixer.__fixE121</h4>
1034 <b>__fixE121</b>(<i>code, line, pos, apply=False</i>)
1035
1036 <p>
1037 Private method to fix the indentation of continuation lines and
1038 closing brackets.
1039 </p>
1040 <p>
1041 Codes: E121, E124
1042 </p>
1043 <dl>
1044
1045 <dt><i>code</i> (str)</dt>
1046 <dd>
1047 code of the issue
1048 </dd>
1049 <dt><i>line</i> (int)</dt>
1050 <dd>
1051 line number of the issue
1052 </dd>
1053 <dt><i>pos</i> (int)</dt>
1054 <dd>
1055 position inside line
1056 </dd>
1057 <dt><i>apply</i> (bool)</dt>
1058 <dd>
1059 flag indicating, that the fix should be applied
1060 </dd>
1061 </dl>
1062 <dl>
1063 <dt>Return:</dt>
1064 <dd>
1065 value indicating an applied/deferred fix (-1, 0, 1),
1066 a message code for the fix, a list of arguments for the
1067 message and an ID for a deferred fix
1068 </dd>
1069 </dl>
1070 <dl>
1071 <dt>Return Type:</dt>
1072 <dd>
1073 tuple of (int, str, list or int, int)
1074 </dd>
1075 </dl>
1076 <a NAME="CodeStyleFixer.__fixE122" ID="CodeStyleFixer.__fixE122"></a>
1077 <h4>CodeStyleFixer.__fixE122</h4>
1078 <b>__fixE122</b>(<i>code, line, pos, apply=False</i>)
1079
1080 <p>
1081 Private method to fix a missing indentation of continuation lines.
1082 </p>
1083 <p>
1084 Codes: E122
1085 </p>
1086 <dl>
1087
1088 <dt><i>code</i> (str)</dt>
1089 <dd>
1090 code of the issue
1091 </dd>
1092 <dt><i>line</i> (int)</dt>
1093 <dd>
1094 line number of the issue
1095 </dd>
1096 <dt><i>pos</i> (int)</dt>
1097 <dd>
1098 position inside line
1099 </dd>
1100 <dt><i>apply</i> (bool)</dt>
1101 <dd>
1102 flag indicating, that the fix should be applied
1103 </dd>
1104 </dl>
1105 <dl>
1106 <dt>Return:</dt>
1107 <dd>
1108 value indicating an applied/deferred fix (-1, 0, 1),
1109 a message code for the fix, a list of arguments for the
1110 message and an ID for a deferred fix
1111 </dd>
1112 </dl>
1113 <dl>
1114 <dt>Return Type:</dt>
1115 <dd>
1116 tuple of (int, str, list or int, int)
1117 </dd>
1118 </dl>
1119 <a NAME="CodeStyleFixer.__fixE123" ID="CodeStyleFixer.__fixE123"></a>
1120 <h4>CodeStyleFixer.__fixE123</h4>
1121 <b>__fixE123</b>(<i>code, line, pos, apply=False</i>)
1122
1123 <p>
1124 Private method to fix the indentation of a closing bracket lines.
1125 </p>
1126 <p>
1127 Codes: E123
1128 </p>
1129 <dl>
1130
1131 <dt><i>code</i> (str)</dt>
1132 <dd>
1133 code of the issue
1134 </dd>
1135 <dt><i>line</i> (int)</dt>
1136 <dd>
1137 line number of the issue
1138 </dd>
1139 <dt><i>pos</i> (int)</dt>
1140 <dd>
1141 position inside line
1142 </dd>
1143 <dt><i>apply</i> (bool)</dt>
1144 <dd>
1145 flag indicating, that the fix should be applied
1146 </dd>
1147 </dl>
1148 <dl>
1149 <dt>Return:</dt>
1150 <dd>
1151 value indicating an applied/deferred fix (-1, 0, 1),
1152 a message code for the fix, a list of arguments for the
1153 message and an ID for a deferred fix
1154 </dd>
1155 </dl>
1156 <dl>
1157 <dt>Return Type:</dt>
1158 <dd>
1159 tuple of (int, str, list or int, int)
1160 </dd>
1161 </dl>
1162 <a NAME="CodeStyleFixer.__fixE125" ID="CodeStyleFixer.__fixE125"></a>
1163 <h4>CodeStyleFixer.__fixE125</h4>
1164 <b>__fixE125</b>(<i>code, line, pos, apply=False</i>)
1165
1166 <p>
1167 Private method to fix the indentation of continuation lines not
1168 distinguishable from next logical line.
1169 </p>
1170 <p>
1171 Codes: E125
1172 </p>
1173 <dl>
1174
1175 <dt><i>code</i> (str)</dt>
1176 <dd>
1177 code of the issue
1178 </dd>
1179 <dt><i>line</i> (int)</dt>
1180 <dd>
1181 line number of the issue
1182 </dd>
1183 <dt><i>pos</i> (int)</dt>
1184 <dd>
1185 position inside line
1186 </dd>
1187 <dt><i>apply</i> (bool)</dt>
1188 <dd>
1189 flag indicating, that the fix should be applied
1190 </dd>
1191 </dl>
1192 <dl>
1193 <dt>Return:</dt>
1194 <dd>
1195 value indicating an applied/deferred fix (-1, 0, 1),
1196 a message code for the fix, a list of arguments for the
1197 message and an ID for a deferred fix
1198 </dd>
1199 </dl>
1200 <dl>
1201 <dt>Return Type:</dt>
1202 <dd>
1203 tuple of (int, str, list or int, int)
1204 </dd>
1205 </dl>
1206 <a NAME="CodeStyleFixer.__fixE126" ID="CodeStyleFixer.__fixE126"></a>
1207 <h4>CodeStyleFixer.__fixE126</h4>
1208 <b>__fixE126</b>(<i>code, line, pos, apply=False</i>)
1209
1210 <p>
1211 Private method to fix over-indented/under-indented hanging
1212 indentation.
1213 </p>
1214 <p>
1215 Codes: E126, E133
1216 </p>
1217 <dl>
1218
1219 <dt><i>code</i> (str)</dt>
1220 <dd>
1221 code of the issue
1222 </dd>
1223 <dt><i>line</i> (int)</dt>
1224 <dd>
1225 line number of the issue
1226 </dd>
1227 <dt><i>pos</i> (int)</dt>
1228 <dd>
1229 position inside line
1230 </dd>
1231 <dt><i>apply</i> (bool)</dt>
1232 <dd>
1233 flag indicating, that the fix should be applied
1234 </dd>
1235 </dl>
1236 <dl>
1237 <dt>Return:</dt>
1238 <dd>
1239 value indicating an applied/deferred fix (-1, 0, 1),
1240 a message code for the fix, a list of arguments for the
1241 message and an ID for a deferred fix
1242 </dd>
1243 </dl>
1244 <dl>
1245 <dt>Return Type:</dt>
1246 <dd>
1247 tuple of (int, str, list or int, int)
1248 </dd>
1249 </dl>
1250 <a NAME="CodeStyleFixer.__fixE127" ID="CodeStyleFixer.__fixE127"></a>
1251 <h4>CodeStyleFixer.__fixE127</h4>
1252 <b>__fixE127</b>(<i>code, line, pos, apply=False</i>)
1253
1254 <p>
1255 Private method to fix over/under indented lines.
1256 </p>
1257 <p>
1258 Codes: E127, E128
1259 </p>
1260 <dl>
1261
1262 <dt><i>code</i> (str)</dt>
1263 <dd>
1264 code of the issue
1265 </dd>
1266 <dt><i>line</i> (int)</dt>
1267 <dd>
1268 line number of the issue
1269 </dd>
1270 <dt><i>pos</i> (int)</dt>
1271 <dd>
1272 position inside line
1273 </dd>
1274 <dt><i>apply</i> (bool)</dt>
1275 <dd>
1276 flag indicating, that the fix should be applied
1277 </dd>
1278 </dl>
1279 <dl>
1280 <dt>Return:</dt>
1281 <dd>
1282 value indicating an applied/deferred fix (-1, 0, 1),
1283 a message code for the fix, a list of arguments for the
1284 message and an ID for a deferred fix
1285 </dd>
1286 </dl>
1287 <dl>
1288 <dt>Return Type:</dt>
1289 <dd>
1290 tuple of (int, str, list or int, int)
1291 </dd>
1292 </dl>
1293 <a NAME="CodeStyleFixer.__fixE201" ID="CodeStyleFixer.__fixE201"></a>
1294 <h4>CodeStyleFixer.__fixE201</h4>
1295 <b>__fixE201</b>(<i>code, line, pos</i>)
1296
1297 <p>
1298 Private method to fix extraneous whitespace.
1299 </p>
1300 <p>
1301 Codes: E201, E202, E203, E211
1302 </p>
1303 <dl>
1304
1305 <dt><i>code</i> (str)</dt>
1306 <dd>
1307 code of the issue
1308 </dd>
1309 <dt><i>line</i> (int)</dt>
1310 <dd>
1311 line number of the issue
1312 </dd>
1313 <dt><i>pos</i> (int)</dt>
1314 <dd>
1315 position inside line
1316 </dd>
1317 </dl>
1318 <dl>
1319 <dt>Return:</dt>
1320 <dd>
1321 value indicating an applied/deferred fix (-1, 0, 1),
1322 a message code for the fix, a list of arguments for the
1323 message and an ID for a deferred fix
1324 </dd>
1325 </dl>
1326 <dl>
1327 <dt>Return Type:</dt>
1328 <dd>
1329 tuple of (int, str, list or int, int)
1330 </dd>
1331 </dl>
1332 <a NAME="CodeStyleFixer.__fixE221" ID="CodeStyleFixer.__fixE221"></a>
1333 <h4>CodeStyleFixer.__fixE221</h4>
1334 <b>__fixE221</b>(<i>code, line, pos</i>)
1335
1336 <p>
1337 Private method to fix extraneous whitespace around operator or
1338 keyword.
1339 </p>
1340 <p>
1341 Codes: E221, E222, E223, E224, E241, E242, E271, E272, E273, E274
1342 </p>
1343 <dl>
1344
1345 <dt><i>code</i> (str)</dt>
1346 <dd>
1347 code of the issue
1348 </dd>
1349 <dt><i>line</i> (int)</dt>
1350 <dd>
1351 line number of the issue
1352 </dd>
1353 <dt><i>pos</i> (int)</dt>
1354 <dd>
1355 position inside line
1356 </dd>
1357 </dl>
1358 <dl>
1359 <dt>Return:</dt>
1360 <dd>
1361 value indicating an applied/deferred fix (-1, 0, 1),
1362 a message code for the fix, a list of arguments for the
1363 message and an ID for a deferred fix
1364 </dd>
1365 </dl>
1366 <dl>
1367 <dt>Return Type:</dt>
1368 <dd>
1369 tuple of (int, str, list or int, int)
1370 </dd>
1371 </dl>
1372 <a NAME="CodeStyleFixer.__fixE225" ID="CodeStyleFixer.__fixE225"></a>
1373 <h4>CodeStyleFixer.__fixE225</h4>
1374 <b>__fixE225</b>(<i>code, line, pos</i>)
1375
1376 <p>
1377 Private method to fix extraneous whitespaces around operator.
1378 </p>
1379 <p>
1380 Codes: E225, E226, E227, E228
1381 </p>
1382 <dl>
1383
1384 <dt><i>code</i> (str)</dt>
1385 <dd>
1386 code of the issue
1387 </dd>
1388 <dt><i>line</i> (int)</dt>
1389 <dd>
1390 line number of the issue
1391 </dd>
1392 <dt><i>pos</i> (int)</dt>
1393 <dd>
1394 position inside line
1395 </dd>
1396 </dl>
1397 <dl>
1398 <dt>Return:</dt>
1399 <dd>
1400 value indicating an applied/deferred fix (-1, 0, 1),
1401 a message code for the fix, a list of arguments for the
1402 message and an ID for a deferred fix
1403 </dd>
1404 </dl>
1405 <dl>
1406 <dt>Return Type:</dt>
1407 <dd>
1408 tuple of (int, str, list or int, int)
1409 </dd>
1410 </dl>
1411 <a NAME="CodeStyleFixer.__fixE231" ID="CodeStyleFixer.__fixE231"></a>
1412 <h4>CodeStyleFixer.__fixE231</h4>
1413 <b>__fixE231</b>(<i>code, line, pos</i>)
1414
1415 <p>
1416 Private method to fix missing whitespace after ',;:'.
1417 </p>
1418 <p>
1419 Codes: E231
1420 </p>
1421 <dl>
1422
1423 <dt><i>code</i> (str)</dt>
1424 <dd>
1425 code of the issue
1426 </dd>
1427 <dt><i>line</i> (int)</dt>
1428 <dd>
1429 line number of the issue
1430 </dd>
1431 <dt><i>pos</i> (int)</dt>
1432 <dd>
1433 position inside line
1434 </dd>
1435 </dl>
1436 <dl>
1437 <dt>Return:</dt>
1438 <dd>
1439 value indicating an applied/deferred fix (-1, 0, 1),
1440 a message code for the fix, a list of arguments for the
1441 message and an ID for a deferred fix
1442 </dd>
1443 </dl>
1444 <dl>
1445 <dt>Return Type:</dt>
1446 <dd>
1447 tuple of (int, str, list or int, int)
1448 </dd>
1449 </dl>
1450 <a NAME="CodeStyleFixer.__fixE251" ID="CodeStyleFixer.__fixE251"></a>
1451 <h4>CodeStyleFixer.__fixE251</h4>
1452 <b>__fixE251</b>(<i>code, line, pos</i>)
1453
1454 <p>
1455 Private method to fix extraneous whitespace around keyword and
1456 default parameter equals.
1457 </p>
1458 <p>
1459 Codes: E251
1460 </p>
1461 <dl>
1462
1463 <dt><i>code</i> (str)</dt>
1464 <dd>
1465 code of the issue
1466 </dd>
1467 <dt><i>line</i> (int)</dt>
1468 <dd>
1469 line number of the issue
1470 </dd>
1471 <dt><i>pos</i> (int)</dt>
1472 <dd>
1473 position inside line
1474 </dd>
1475 </dl>
1476 <dl>
1477 <dt>Return:</dt>
1478 <dd>
1479 value indicating an applied/deferred fix (-1, 0, 1),
1480 a message code for the fix, a list of arguments for the
1481 message and an ID for a deferred fix
1482 </dd>
1483 </dl>
1484 <dl>
1485 <dt>Return Type:</dt>
1486 <dd>
1487 tuple of (int, str, list or int, int)
1488 </dd>
1489 </dl>
1490 <a NAME="CodeStyleFixer.__fixE261" ID="CodeStyleFixer.__fixE261"></a>
1491 <h4>CodeStyleFixer.__fixE261</h4>
1492 <b>__fixE261</b>(<i>code, line, pos</i>)
1493
1494 <p>
1495 Private method to fix whitespace before or after inline comment.
1496 </p>
1497 <p>
1498 Codes: E261, E262
1499 </p>
1500 <dl>
1501
1502 <dt><i>code</i> (str)</dt>
1503 <dd>
1504 code of the issue
1505 </dd>
1506 <dt><i>line</i> (int)</dt>
1507 <dd>
1508 line number of the issue
1509 </dd>
1510 <dt><i>pos</i> (int)</dt>
1511 <dd>
1512 position inside line
1513 </dd>
1514 </dl>
1515 <dl>
1516 <dt>Return:</dt>
1517 <dd>
1518 value indicating an applied/deferred fix (-1, 0, 1),
1519 a message code for the fix, a list of arguments for the
1520 message and an ID for a deferred fix
1521 </dd>
1522 </dl>
1523 <dl>
1524 <dt>Return Type:</dt>
1525 <dd>
1526 tuple of (int, str, list or int, int)
1527 </dd>
1528 </dl>
1529 <a NAME="CodeStyleFixer.__fixE304" ID="CodeStyleFixer.__fixE304"></a>
1530 <h4>CodeStyleFixer.__fixE304</h4>
1531 <b>__fixE304</b>(<i>code, line, pos, apply=False</i>)
1532
1533 <p>
1534 Private method to fix superfluous blank lines after a function
1535 decorator.
1536 </p>
1537 <p>
1538 Codes: E304
1539 </p>
1540 <dl>
1541
1542 <dt><i>code</i> (str)</dt>
1543 <dd>
1544 code of the issue
1545 </dd>
1546 <dt><i>line</i> (int)</dt>
1547 <dd>
1548 line number of the issue
1549 </dd>
1550 <dt><i>pos</i> (int)</dt>
1551 <dd>
1552 position inside line
1553 </dd>
1554 <dt><i>apply</i> (bool)</dt>
1555 <dd>
1556 flag indicating, that the fix should be applied
1557 </dd>
1558 </dl>
1559 <dl>
1560 <dt>Return:</dt>
1561 <dd>
1562 value indicating an applied/deferred fix (-1, 0, 1),
1563 a message code for the fix, a list of arguments for the
1564 message and an ID for a deferred fix
1565 </dd>
1566 </dl>
1567 <dl>
1568 <dt>Return Type:</dt>
1569 <dd>
1570 tuple of (int, str, list or int, int)
1571 </dd>
1572 </dl>
1573 <a NAME="CodeStyleFixer.__fixE401" ID="CodeStyleFixer.__fixE401"></a>
1574 <h4>CodeStyleFixer.__fixE401</h4>
1575 <b>__fixE401</b>(<i>code, line, pos, apply=False</i>)
1576
1577 <p>
1578 Private method to fix multiple imports on one line.
1579 </p>
1580 <p>
1581 Codes: E401
1582 </p>
1583 <dl>
1584
1585 <dt><i>code</i> (str)</dt>
1586 <dd>
1587 code of the issue
1588 </dd>
1589 <dt><i>line</i> (int)</dt>
1590 <dd>
1591 line number of the issue
1592 </dd>
1593 <dt><i>pos</i> (int)</dt>
1594 <dd>
1595 position inside line
1596 </dd>
1597 <dt><i>apply</i> (bool)</dt>
1598 <dd>
1599 flag indicating, that the fix should be applied
1600 </dd>
1601 </dl>
1602 <dl>
1603 <dt>Return:</dt>
1604 <dd>
1605 value indicating an applied/deferred fix (-1, 0, 1),
1606 a message code for the fix, a list of arguments for the
1607 message and an ID for a deferred fix
1608 </dd>
1609 </dl>
1610 <dl>
1611 <dt>Return Type:</dt>
1612 <dd>
1613 tuple of (int, str, list or int, int)
1614 </dd>
1615 </dl>
1616 <a NAME="CodeStyleFixer.__fixE501" ID="CodeStyleFixer.__fixE501"></a>
1617 <h4>CodeStyleFixer.__fixE501</h4>
1618 <b>__fixE501</b>(<i>code, line, pos, apply=False</i>)
1619
1620 <p>
1621 Private method to fix the long lines by breaking them.
1622 </p>
1623 <p>
1624 Codes: E501
1625 </p>
1626 <dl>
1627
1628 <dt><i>code</i> (str)</dt>
1629 <dd>
1630 code of the issue
1631 </dd>
1632 <dt><i>line</i> (int)</dt>
1633 <dd>
1634 line number of the issue
1635 </dd>
1636 <dt><i>pos</i> (int)</dt>
1637 <dd>
1638 position inside line
1639 </dd>
1640 <dt><i>apply</i> (bool)</dt>
1641 <dd>
1642 flag indicating, that the fix should be applied
1643 </dd>
1644 </dl>
1645 <dl>
1646 <dt>Return:</dt>
1647 <dd>
1648 value indicating an applied/deferred fix (-1, 0, 1),
1649 a message code for the fix, a list of arguments for the
1650 message and an ID for a deferred fix
1651 </dd>
1652 </dl>
1653 <dl>
1654 <dt>Return Type:</dt>
1655 <dd>
1656 tuple of (int, str, list or int, int)
1657 </dd>
1658 </dl>
1659 <a NAME="CodeStyleFixer.__fixE502" ID="CodeStyleFixer.__fixE502"></a>
1660 <h4>CodeStyleFixer.__fixE502</h4>
1661 <b>__fixE502</b>(<i>code, line, pos</i>)
1662
1663 <p>
1664 Private method to fix redundant backslash within brackets.
1665 </p>
1666 <p>
1667 Codes: E502
1668 </p>
1669 <dl>
1670
1671 <dt><i>code</i> (str)</dt>
1672 <dd>
1673 code of the issue
1674 </dd>
1675 <dt><i>line</i> (int)</dt>
1676 <dd>
1677 line number of the issue
1678 </dd>
1679 <dt><i>pos</i> (int)</dt>
1680 <dd>
1681 position inside line
1682 </dd>
1683 </dl>
1684 <dl>
1685 <dt>Return:</dt>
1686 <dd>
1687 value indicating an applied/deferred fix (-1, 0, 1),
1688 a message code for the fix, a list of arguments for the
1689 message and an ID for a deferred fix
1690 </dd>
1691 </dl>
1692 <dl>
1693 <dt>Return Type:</dt>
1694 <dd>
1695 tuple of (int, str, list or int, int)
1696 </dd>
1697 </dl>
1698 <a NAME="CodeStyleFixer.__fixE701" ID="CodeStyleFixer.__fixE701"></a>
1699 <h4>CodeStyleFixer.__fixE701</h4>
1700 <b>__fixE701</b>(<i>code, line, pos, apply=False</i>)
1701
1702 <p>
1703 Private method to fix colon-separated compound statements.
1704 </p>
1705 <p>
1706 Codes: E701
1707 </p>
1708 <dl>
1709
1710 <dt><i>code</i> (str)</dt>
1711 <dd>
1712 code of the issue
1713 </dd>
1714 <dt><i>line</i> (int)</dt>
1715 <dd>
1716 line number of the issue
1717 </dd>
1718 <dt><i>pos</i> (int)</dt>
1719 <dd>
1720 position inside line
1721 </dd>
1722 <dt><i>apply</i> (bool)</dt>
1723 <dd>
1724 flag indicating, that the fix should be applied
1725 </dd>
1726 </dl>
1727 <dl>
1728 <dt>Return:</dt>
1729 <dd>
1730 value indicating an applied/deferred fix (-1, 0, 1),
1731 a message code for the fix, a list of arguments for the
1732 message and an ID for a deferred fix
1733 </dd>
1734 </dl>
1735 <dl>
1736 <dt>Return Type:</dt>
1737 <dd>
1738 tuple of (int, str, list or int, int)
1739 </dd>
1740 </dl>
1741 <a NAME="CodeStyleFixer.__fixE702" ID="CodeStyleFixer.__fixE702"></a>
1742 <h4>CodeStyleFixer.__fixE702</h4>
1743 <b>__fixE702</b>(<i>code, line, pos, apply=False</i>)
1744
1745 <p>
1746 Private method to fix semicolon-separated compound statements.
1747 </p>
1748 <p>
1749 Codes: E702, E703
1750 </p>
1751 <dl>
1752
1753 <dt><i>code</i> (str)</dt>
1754 <dd>
1755 code of the issue
1756 </dd>
1757 <dt><i>line</i> (int)</dt>
1758 <dd>
1759 line number of the issue
1760 </dd>
1761 <dt><i>pos</i> (int)</dt>
1762 <dd>
1763 position inside line
1764 </dd>
1765 <dt><i>apply</i> (bool)</dt>
1766 <dd>
1767 flag indicating, that the fix should be applied
1768 </dd>
1769 </dl>
1770 <dl>
1771 <dt>Return:</dt>
1772 <dd>
1773 value indicating an applied/deferred fix (-1, 0, 1),
1774 a message code for the fix, a list of arguments for the
1775 message and an ID for a deferred fix
1776 </dd>
1777 </dl>
1778 <dl>
1779 <dt>Return Type:</dt>
1780 <dd>
1781 tuple of (int, str, list or int, int)
1782 </dd>
1783 </dl>
1784 <a NAME="CodeStyleFixer.__fixE711" ID="CodeStyleFixer.__fixE711"></a>
1785 <h4>CodeStyleFixer.__fixE711</h4>
1786 <b>__fixE711</b>(<i>code, line, pos</i>)
1787
1788 <p>
1789 Private method to fix comparison with None.
1790 </p>
1791 <p>
1792 Codes: E711, E712
1793 </p>
1794 <dl>
1795
1796 <dt><i>code</i> (str)</dt>
1797 <dd>
1798 code of the issue
1799 </dd>
1800 <dt><i>line</i> (int)</dt>
1801 <dd>
1802 line number of the issue
1803 </dd>
1804 <dt><i>pos</i> (int)</dt>
1805 <dd>
1806 position inside line
1807 </dd>
1808 </dl>
1809 <dl>
1810 <dt>Return:</dt>
1811 <dd>
1812 value indicating an applied/deferred fix (-1, 0, 1),
1813 a message code for the fix, a list of arguments for the
1814 message and an ID for a deferred fix
1815 </dd>
1816 </dl>
1817 <dl>
1818 <dt>Return Type:</dt>
1819 <dd>
1820 tuple of (int, str, list or int, int)
1821 </dd>
1822 </dl>
1823 <a NAME="CodeStyleFixer.__fixN804" ID="CodeStyleFixer.__fixN804"></a>
1824 <h4>CodeStyleFixer.__fixN804</h4>
1825 <b>__fixN804</b>(<i>code, line, pos, apply=False</i>)
1826
1827 <p>
1828 Private method to fix a wrong first argument of normal and
1829 class methods.
1830 </p>
1831 <p>
1832 Codes: N804, N805
1833 </p>
1834 <dl>
1835
1836 <dt><i>code</i> (str)</dt>
1837 <dd>
1838 code of the issue
1839 </dd>
1840 <dt><i>line</i> (int)</dt>
1841 <dd>
1842 line number of the issue
1843 </dd>
1844 <dt><i>pos</i> (int)</dt>
1845 <dd>
1846 position inside line
1847 </dd>
1848 <dt><i>apply</i> (bool)</dt>
1849 <dd>
1850 flag indicating, that the fix should be applied
1851 </dd>
1852 </dl>
1853 <dl>
1854 <dt>Return:</dt>
1855 <dd>
1856 value indicating an applied/deferred fix (-1, 0, 1),
1857 a message code for the fix, a list of arguments for the
1858 message and an ID for a deferred fix
1859 </dd>
1860 </dl>
1861 <dl>
1862 <dt>Return Type:</dt>
1863 <dd>
1864 tuple of (int, str, list or int, int)
1865 </dd>
1866 </dl>
1867 <a NAME="CodeStyleFixer.__fixN806" ID="CodeStyleFixer.__fixN806"></a>
1868 <h4>CodeStyleFixer.__fixN806</h4>
1869 <b>__fixN806</b>(<i>code, line, pos, apply=False</i>)
1870
1871 <p>
1872 Private method to fix a wrong first argument of static methods.
1873 </p>
1874 <p>
1875 Codes: N806
1876 </p>
1877 <dl>
1878
1879 <dt><i>code</i> (str)</dt>
1880 <dd>
1881 code of the issue
1882 </dd>
1883 <dt><i>line</i> (int)</dt>
1884 <dd>
1885 line number of the issue
1886 </dd>
1887 <dt><i>pos</i> (int)</dt>
1888 <dd>
1889 position inside line
1890 </dd>
1891 <dt><i>apply</i> (bool)</dt>
1892 <dd>
1893 flag indicating, that the fix should be applied
1894 </dd>
1895 </dl>
1896 <dl>
1897 <dt>Return:</dt>
1898 <dd>
1899 value indicating an applied/deferred fix (-1, 0, 1),
1900 a message code for the fix, a list of arguments for the
1901 message and an ID for a deferred fix
1902 </dd>
1903 </dl>
1904 <dl>
1905 <dt>Return Type:</dt>
1906 <dd>
1907 tuple of (int, str, list or int, int)
1908 </dd>
1909 </dl>
1910 <a NAME="CodeStyleFixer.__fixReindent" ID="CodeStyleFixer.__fixReindent"></a>
1911 <h4>CodeStyleFixer.__fixReindent</h4>
1912 <b>__fixReindent</b>(<i>line, pos, logical</i>)
1913
1914 <p>
1915 Private method to fix a badly indented line.
1916 </p>
1917 <p>
1918 This is done by adding or removing from its initial indent only.
1919 </p>
1920 <dl>
1921
1922 <dt><i>line</i></dt>
1923 <dd>
1924 line number of the issue (integer)
1925 </dd>
1926 <dt><i>pos</i></dt>
1927 <dd>
1928 position inside line (integer)
1929 </dd>
1930 <dt><i>logical</i></dt>
1931 <dd>
1932 logical line structure
1933 </dd>
1934 </dl>
1935 <dl>
1936 <dt>Return:</dt>
1937 <dd>
1938 flag indicating a change was done (boolean)
1939 </dd>
1940 </dl>
1941 <dl>
1942
1943 <dt>Raises <b>ValueError</b>:</dt>
1944 <dd>
1945 raised to indicate a bad 'logical' parameter
1946 </dd>
1947 </dl>
1948 <a NAME="CodeStyleFixer.__fixW291" ID="CodeStyleFixer.__fixW291"></a>
1949 <h4>CodeStyleFixer.__fixW291</h4>
1950 <b>__fixW291</b>(<i>code, line, pos</i>)
1951
1952 <p>
1953 Private method to fix trailing whitespace.
1954 </p>
1955 <p>
1956 Codes: W291, W293
1957 </p>
1958 <dl>
1959
1960 <dt><i>code</i> (str)</dt>
1961 <dd>
1962 code of the issue
1963 </dd>
1964 <dt><i>line</i> (int)</dt>
1965 <dd>
1966 line number of the issue
1967 </dd>
1968 <dt><i>pos</i> (int)</dt>
1969 <dd>
1970 position inside line
1971 </dd>
1972 </dl>
1973 <dl>
1974 <dt>Return:</dt>
1975 <dd>
1976 value indicating an applied/deferred fix (-1, 0, 1),
1977 a message code for the fix, a list of arguments for the
1978 message and an ID for a deferred fix
1979 </dd>
1980 </dl>
1981 <dl>
1982 <dt>Return Type:</dt>
1983 <dd>
1984 tuple of (int, str, list or int, int)
1985 </dd>
1986 </dl>
1987 <a NAME="CodeStyleFixer.__fixW292" ID="CodeStyleFixer.__fixW292"></a>
1988 <h4>CodeStyleFixer.__fixW292</h4>
1989 <b>__fixW292</b>(<i>code, line, pos</i>)
1990
1991 <p>
1992 Private method to fix a missing newline at the end of file.
1993 </p>
1994 <p>
1995 Codes: W292
1996 </p>
1997 <dl>
1998
1999 <dt><i>code</i> (str)</dt>
2000 <dd>
2001 code of the issue
2002 </dd>
2003 <dt><i>line</i> (int)</dt>
2004 <dd>
2005 line number of the issue
2006 </dd>
2007 <dt><i>pos</i> (int)</dt>
2008 <dd>
2009 position inside line
2010 </dd>
2011 </dl>
2012 <dl>
2013 <dt>Return:</dt>
2014 <dd>
2015 value indicating an applied/deferred fix (-1, 0, 1),
2016 a message code for the fix, a list of arguments for the
2017 message and an ID for a deferred fix
2018 </dd>
2019 </dl>
2020 <dl>
2021 <dt>Return Type:</dt>
2022 <dd>
2023 tuple of (int, str, list or int, int)
2024 </dd>
2025 </dl>
2026 <a NAME="CodeStyleFixer.__fixW391" ID="CodeStyleFixer.__fixW391"></a>
2027 <h4>CodeStyleFixer.__fixW391</h4>
2028 <b>__fixW391</b>(<i>code, line, pos</i>)
2029
2030 <p>
2031 Private method to fix trailing blank lines.
2032 </p>
2033 <p>
2034 Codes: W391
2035 </p>
2036 <dl>
2037
2038 <dt><i>code</i> (str)</dt>
2039 <dd>
2040 code of the issue
2041 </dd>
2042 <dt><i>line</i> (int)</dt>
2043 <dd>
2044 line number of the issue
2045 </dd>
2046 <dt><i>pos</i> (int)</dt>
2047 <dd>
2048 position inside line
2049 </dd>
2050 </dl>
2051 <dl>
2052 <dt>Return:</dt>
2053 <dd>
2054 value indicating an applied/deferred fix (-1, 0, 1),
2055 a message code for the fix, a list of arguments for the
2056 message and an ID for a deferred fix
2057 </dd>
2058 </dl>
2059 <dl>
2060 <dt>Return Type:</dt>
2061 <dd>
2062 tuple of (int, str, list or int, int)
2063 </dd>
2064 </dl>
2065 <a NAME="CodeStyleFixer.__fixW603" ID="CodeStyleFixer.__fixW603"></a>
2066 <h4>CodeStyleFixer.__fixW603</h4>
2067 <b>__fixW603</b>(<i>code, line, pos</i>)
2068
2069 <p>
2070 Private method to fix the not equal notation.
2071 </p>
2072 <p>
2073 Codes: W603
2074 </p>
2075 <dl>
2076
2077 <dt><i>code</i> (str)</dt>
2078 <dd>
2079 code of the issue
2080 </dd>
2081 <dt><i>line</i> (int)</dt>
2082 <dd>
2083 line number of the issue
2084 </dd>
2085 <dt><i>pos</i> (int)</dt>
2086 <dd>
2087 position inside line
2088 </dd>
2089 </dl>
2090 <dl>
2091 <dt>Return:</dt>
2092 <dd>
2093 value indicating an applied/deferred fix (-1, 0, 1),
2094 a message code for the fix, a list of arguments for the
2095 message and an ID for a deferred fix
2096 </dd>
2097 </dl>
2098 <dl>
2099 <dt>Return Type:</dt>
2100 <dd>
2101 tuple of (int, str, list or int, int)
2102 </dd>
2103 </dl>
2104 <a NAME="CodeStyleFixer.__fixWhitespace" ID="CodeStyleFixer.__fixWhitespace"></a>
2105 <h4>CodeStyleFixer.__fixWhitespace</h4>
2106 <b>__fixWhitespace</b>(<i>line, offset, replacement</i>)
2107
2108 <p>
2109 Private method to correct whitespace at the given offset.
2110 </p>
2111 <dl>
2112
2113 <dt><i>line</i></dt>
2114 <dd>
2115 line to be corrected (string)
2116 </dd>
2117 <dt><i>offset</i></dt>
2118 <dd>
2119 offset within line (integer)
2120 </dd>
2121 <dt><i>replacement</i></dt>
2122 <dd>
2123 replacement string (string)
2124 </dd>
2125 </dl>
2126 <dl>
2127 <dt>Return:</dt>
2128 <dd>
2129 corrected line
2130 </dd>
2131 </dl>
2132 <a NAME="CodeStyleFixer.__getID" ID="CodeStyleFixer.__getID"></a>
2133 <h4>CodeStyleFixer.__getID</h4>
2134 <b>__getID</b>(<i></i>)
2135
2136 <p>
2137 Private method to get the ID for a deferred fix.
2138 </p>
2139 <dl>
2140 <dt>Return:</dt>
2141 <dd>
2142 ID for a deferred fix (integer)
2143 </dd>
2144 </dl>
2145 <a NAME="CodeStyleFixer.__getIndent" ID="CodeStyleFixer.__getIndent"></a>
2146 <h4>CodeStyleFixer.__getIndent</h4>
2147 <b>__getIndent</b>(<i>line</i>)
2148
2149 <p>
2150 Private method to get the indentation string.
2151 </p>
2152 <dl>
2153
2154 <dt><i>line</i></dt>
2155 <dd>
2156 line to determine the indentation string from (string)
2157 </dd>
2158 </dl>
2159 <dl>
2160 <dt>Return:</dt>
2161 <dd>
2162 indentation string (string)
2163 </dd>
2164 </dl>
2165 <a NAME="CodeStyleFixer.__getIndentWord" ID="CodeStyleFixer.__getIndentWord"></a>
2166 <h4>CodeStyleFixer.__getIndentWord</h4>
2167 <b>__getIndentWord</b>(<i></i>)
2168
2169 <p>
2170 Private method to determine the indentation type.
2171 </p>
2172 <dl>
2173 <dt>Return:</dt>
2174 <dd>
2175 string to be used for an indentation (string)
2176 </dd>
2177 </dl>
2178 <a NAME="CodeStyleFixer.__getLogical" ID="CodeStyleFixer.__getLogical"></a>
2179 <h4>CodeStyleFixer.__getLogical</h4>
2180 <b>__getLogical</b>(<i>line, pos</i>)
2181
2182 <p>
2183 Private method to get the logical line corresponding to the given
2184 position.
2185 </p>
2186 <dl>
2187
2188 <dt><i>line</i></dt>
2189 <dd>
2190 line number of the issue (integer)
2191 </dd>
2192 <dt><i>pos</i></dt>
2193 <dd>
2194 position inside line (integer)
2195 </dd>
2196 </dl>
2197 <dl>
2198 <dt>Return:</dt>
2199 <dd>
2200 tuple of a tuple of two integers giving the start of the
2201 logical line, another tuple of two integers giving the end
2202 of the logical line and a list of strings with the original
2203 source lines
2204 </dd>
2205 </dl>
2206 <a NAME="CodeStyleFixer.__multilineStringLines" ID="CodeStyleFixer.__multilineStringLines"></a>
2207 <h4>CodeStyleFixer.__multilineStringLines</h4>
2208 <b>__multilineStringLines</b>(<i></i>)
2209
2210 <p>
2211 Private method to determine the line numbers that are within multi line
2212 strings and these which are part of a documentation string.
2213 </p>
2214 <dl>
2215 <dt>Return:</dt>
2216 <dd>
2217 tuple of a set of line numbers belonging to a multi line
2218 string and a set of line numbers belonging to a multi line
2219 documentation string (tuple of two set of integer)
2220 </dd>
2221 </dl>
2222 <a NAME="CodeStyleFixer.finalize" ID="CodeStyleFixer.finalize"></a>
2223 <h4>CodeStyleFixer.finalize</h4>
2224 <b>finalize</b>(<i></i>)
2225
2226 <p>
2227 Public method to apply all deferred fixes.
2228 </p>
2229 <dl>
2230 <dt>Return:</dt>
2231 <dd>
2232 dictionary containing the fix results
2233 </dd>
2234 </dl>
2235 <a NAME="CodeStyleFixer.fixIssue" ID="CodeStyleFixer.fixIssue"></a>
2236 <h4>CodeStyleFixer.fixIssue</h4>
2237 <b>fixIssue</b>(<i>line, pos, code</i>)
2238
2239 <p>
2240 Public method to fix the fixable issues.
2241 </p>
2242 <dl>
2243
2244 <dt><i>line</i> (int)</dt>
2245 <dd>
2246 line number of the issue
2247 </dd>
2248 <dt><i>pos</i> (int)</dt>
2249 <dd>
2250 position inside line
2251 </dd>
2252 <dt><i>code</i> (str)</dt>
2253 <dd>
2254 code of the issue
2255 </dd>
2256 </dl>
2257 <dl>
2258 <dt>Return:</dt>
2259 <dd>
2260 value indicating an applied/deferred fix (-1, 0, 1),
2261 a message code for the fix, arguments list for the message
2262 and an ID for a deferred fix
2263 </dd>
2264 </dl>
2265 <dl>
2266 <dt>Return Type:</dt>
2267 <dd>
2268 tuple of (int, str, list, int)
2269 </dd>
2270 </dl>
2271 <a NAME="CodeStyleFixer.mutualStartswith" ID="CodeStyleFixer.mutualStartswith"></a>
2272 <h4>CodeStyleFixer.mutualStartswith</h4>
2273 <b>mutualStartswith</b>(<i>b</i>)
2274
2275 <p>
2276 Local helper method to compare the beginnings of two strings
2277 against each other.
2278 </p>
2279 <dl>
2280 <dt>Return:</dt>
2281 <dd>
2282 flag indicating that one string starts with the other
2283 (boolean)
2284 </dd>
2285 </dl>
2286 <a NAME="CodeStyleFixer.saveFile" ID="CodeStyleFixer.saveFile"></a>
2287 <h4>CodeStyleFixer.saveFile</h4>
2288 <b>saveFile</b>(<i>encoding</i>)
2289
2290 <p>
2291 Public method to save the modified file.
2292 </p>
2293 <dl>
2294
2295 <dt><i>encoding</i></dt>
2296 <dd>
2297 encoding of the source file (string)
2298 </dd>
2299 </dl>
2300 <dl>
2301 <dt>Return:</dt>
2302 <dd>
2303 error message on failure (tuple of str)
2304 </dd>
2305 </dl>
2306 <div align="right"><a href="#top">Up</a></div>
2307 <hr />
2308 <hr />
2309 <a NAME="IndentationWrapper" ID="IndentationWrapper"></a>
2310 <h2>IndentationWrapper</h2>
2311
2312 <p>
2313 Class used by fixers dealing with indentation.
2314 </p>
2315 <p>
2316 Each instance operates on a single logical line.
2317 </p>
2318 <h3>Derived from</h3>
2319 None
2320 <h3>Class Attributes</h3>
2321
2322 <table>
2323 <tr><td>SKIP_TOKENS</td></tr>
2324 </table>
2325 <h3>Class Methods</h3>
2326
2327 <table>
2328 <tr><td>None</td></tr>
2329 </table>
2330 <h3>Methods</h3>
2331
2332 <table>
2333
2334 <tr>
2335 <td><a href="#IndentationWrapper.__init__">IndentationWrapper</a></td>
2336 <td>Constructor</td>
2337 </tr>
2338 <tr>
2339 <td><a href="#IndentationWrapper.__buildTokensLogical">__buildTokensLogical</a></td>
2340 <td>Private method to build a logical line from a list of tokens.</td>
2341 </tr>
2342 <tr>
2343 <td><a href="#IndentationWrapper.pep8Expected">pep8Expected</a></td>
2344 <td>Public method to replicate logic in pycodestyle.py, to know what level to indent things to.</td>
2345 </tr>
2346 </table>
2347 <h3>Static Methods</h3>
2348
2349 <table>
2350 <tr><td>None</td></tr>
2351 </table>
2352
2353 <a NAME="IndentationWrapper.__init__" ID="IndentationWrapper.__init__"></a>
2354 <h4>IndentationWrapper (Constructor)</h4>
2355 <b>IndentationWrapper</b>(<i>physical_lines</i>)
2356
2357 <p>
2358 Constructor
2359 </p>
2360 <dl>
2361
2362 <dt><i>physical_lines</i></dt>
2363 <dd>
2364 list of physical lines to operate on
2365 (list of strings)
2366 </dd>
2367 </dl>
2368 <a NAME="IndentationWrapper.__buildTokensLogical" ID="IndentationWrapper.__buildTokensLogical"></a>
2369 <h4>IndentationWrapper.__buildTokensLogical</h4>
2370 <b>__buildTokensLogical</b>(<i>tokens</i>)
2371
2372 <p>
2373 Private method to build a logical line from a list of tokens.
2374 </p>
2375 <dl>
2376
2377 <dt><i>tokens</i></dt>
2378 <dd>
2379 list of tokens as generated by tokenize.generate_tokens
2380 </dd>
2381 </dl>
2382 <dl>
2383 <dt>Return:</dt>
2384 <dd>
2385 logical line (string)
2386 </dd>
2387 </dl>
2388 <a NAME="IndentationWrapper.pep8Expected" ID="IndentationWrapper.pep8Expected"></a>
2389 <h4>IndentationWrapper.pep8Expected</h4>
2390 <b>pep8Expected</b>(<i></i>)
2391
2392 <p>
2393 Public method to replicate logic in pycodestyle.py, to know what level
2394 to indent things to.
2395 </p>
2396 <dl>
2397 <dt>Return:</dt>
2398 <dd>
2399 list of lists, where each list represents valid indent levels
2400 for the line in question, relative from the initial indent. However,
2401 the first entry is the indent level which was expected.
2402 </dd>
2403 </dl>
2404 <div align="right"><a href="#top">Up</a></div>
2405 <hr />
2406 <hr />
2407 <a NAME="LineShortener" ID="LineShortener"></a>
2408 <h2>LineShortener</h2>
2409
2410 <p>
2411 Class used to shorten lines to a given maximum of characters.
2412 </p>
2413 <h3>Derived from</h3>
2414 None
2415 <h3>Class Attributes</h3>
2416
2417 <table>
2418 <tr><td>None</td></tr>
2419 </table>
2420 <h3>Class Methods</h3>
2421
2422 <table>
2423 <tr><td>None</td></tr>
2424 </table>
2425 <h3>Methods</h3>
2426
2427 <table>
2428
2429 <tr>
2430 <td><a href="#LineShortener.__init__">LineShortener</a></td>
2431 <td>Constructor</td>
2432 </tr>
2433 <tr>
2434 <td><a href="#LineShortener.__breakMultiline">__breakMultiline</a></td>
2435 <td>Private method to break multi line strings.</td>
2436 </tr>
2437 <tr>
2438 <td><a href="#LineShortener.__checkSyntax">__checkSyntax</a></td>
2439 <td>Private method to check the syntax of the given code fragment.</td>
2440 </tr>
2441 <tr>
2442 <td><a href="#LineShortener.__countUnbalancedBrackets">__countUnbalancedBrackets</a></td>
2443 <td>Private method to determine the number of unmatched open/close brackets.</td>
2444 </tr>
2445 <tr>
2446 <td><a href="#LineShortener.__getIndent">__getIndent</a></td>
2447 <td>Private method to get the indentation string.</td>
2448 </tr>
2449 <tr>
2450 <td><a href="#LineShortener.__isProbablyInsideStringOrComment">__isProbablyInsideStringOrComment</a></td>
2451 <td>Private method to check, if the given string might be inside a string or comment.</td>
2452 </tr>
2453 <tr>
2454 <td><a href="#LineShortener.__lineShorteningRank">__lineShorteningRank</a></td>
2455 <td>Private method to rank a candidate.</td>
2456 </tr>
2457 <tr>
2458 <td><a href="#LineShortener.__normalizeMultiline">__normalizeMultiline</a></td>
2459 <td>Private method to remove multiline-related code that will cause syntax error.</td>
2460 </tr>
2461 <tr>
2462 <td><a href="#LineShortener.__shortenComment">__shortenComment</a></td>
2463 <td>Private method to shorten a comment line.</td>
2464 </tr>
2465 <tr>
2466 <td><a href="#LineShortener.__shortenLine">__shortenLine</a></td>
2467 <td>Private method to shorten a line of code at an operator.</td>
2468 </tr>
2469 <tr>
2470 <td><a href="#LineShortener.shorten">shorten</a></td>
2471 <td>Public method to shorten the line wrapped by the class instance.</td>
2472 </tr>
2473 </table>
2474 <h3>Static Methods</h3>
2475
2476 <table>
2477 <tr><td>None</td></tr>
2478 </table>
2479
2480 <a NAME="LineShortener.__init__" ID="LineShortener.__init__"></a>
2481 <h4>LineShortener (Constructor)</h4>
2482 <b>LineShortener</b>(<i>curLine, prevLine, nextLine, maxLength=79, eol="\n", indentWord=" ", isDocString=False</i>)
2483
2484 <p>
2485 Constructor
2486 </p>
2487 <dl>
2488
2489 <dt><i>curLine</i></dt>
2490 <dd>
2491 text to work on (string)
2492 </dd>
2493 <dt><i>prevLine</i></dt>
2494 <dd>
2495 line before the text to work on (string)
2496 </dd>
2497 <dt><i>nextLine</i></dt>
2498 <dd>
2499 line after the text to work on (string)
2500 </dd>
2501 <dt><i>maxLength</i></dt>
2502 <dd>
2503 maximum allowed line length (integer)
2504 </dd>
2505 <dt><i>eol</i></dt>
2506 <dd>
2507 eond-of-line marker (string)
2508 </dd>
2509 <dt><i>indentWord</i></dt>
2510 <dd>
2511 string used for indentation (string)
2512 </dd>
2513 <dt><i>isDocString</i></dt>
2514 <dd>
2515 flag indicating that the line belongs to
2516 a documentation string (boolean)
2517 </dd>
2518 </dl>
2519 <a NAME="LineShortener.__breakMultiline" ID="LineShortener.__breakMultiline"></a>
2520 <h4>LineShortener.__breakMultiline</h4>
2521 <b>__breakMultiline</b>(<i></i>)
2522
2523 <p>
2524 Private method to break multi line strings.
2525 </p>
2526 <dl>
2527 <dt>Return:</dt>
2528 <dd>
2529 tuple of the shortened line and the changed next line
2530 (string, string)
2531 </dd>
2532 </dl>
2533 <a NAME="LineShortener.__checkSyntax" ID="LineShortener.__checkSyntax"></a>
2534 <h4>LineShortener.__checkSyntax</h4>
2535 <b>__checkSyntax</b>(<i>code</i>)
2536
2537 <p>
2538 Private method to check the syntax of the given code fragment.
2539 </p>
2540 <dl>
2541
2542 <dt><i>code</i></dt>
2543 <dd>
2544 code fragment to check (string)
2545 </dd>
2546 </dl>
2547 <dl>
2548 <dt>Return:</dt>
2549 <dd>
2550 flag indicating syntax is ok (boolean)
2551 </dd>
2552 </dl>
2553 <a NAME="LineShortener.__countUnbalancedBrackets" ID="LineShortener.__countUnbalancedBrackets"></a>
2554 <h4>LineShortener.__countUnbalancedBrackets</h4>
2555 <b>__countUnbalancedBrackets</b>(<i>line</i>)
2556
2557 <p>
2558 Private method to determine the number of unmatched open/close
2559 brackets.
2560 </p>
2561 <dl>
2562
2563 <dt><i>line</i></dt>
2564 <dd>
2565 line to work at (string)
2566 </dd>
2567 </dl>
2568 <dl>
2569 <dt>Return:</dt>
2570 <dd>
2571 number of unmatched open/close brackets (integer)
2572 </dd>
2573 </dl>
2574 <a NAME="LineShortener.__getIndent" ID="LineShortener.__getIndent"></a>
2575 <h4>LineShortener.__getIndent</h4>
2576 <b>__getIndent</b>(<i>line</i>)
2577
2578 <p>
2579 Private method to get the indentation string.
2580 </p>
2581 <dl>
2582
2583 <dt><i>line</i></dt>
2584 <dd>
2585 line to determine the indentation string from (string)
2586 </dd>
2587 </dl>
2588 <dl>
2589 <dt>Return:</dt>
2590 <dd>
2591 indentation string (string)
2592 </dd>
2593 </dl>
2594 <a NAME="LineShortener.__isProbablyInsideStringOrComment" ID="LineShortener.__isProbablyInsideStringOrComment"></a>
2595 <h4>LineShortener.__isProbablyInsideStringOrComment</h4>
2596 <b>__isProbablyInsideStringOrComment</b>(<i>line, index</i>)
2597
2598 <p>
2599 Private method to check, if the given string might be inside a string
2600 or comment.
2601 </p>
2602 <dl>
2603
2604 <dt><i>line</i></dt>
2605 <dd>
2606 line to check (string)
2607 </dd>
2608 <dt><i>index</i></dt>
2609 <dd>
2610 position inside line to check (integer)
2611 </dd>
2612 </dl>
2613 <dl>
2614 <dt>Return:</dt>
2615 <dd>
2616 flag indicating the possibility of being inside a string
2617 or comment
2618 </dd>
2619 </dl>
2620 <a NAME="LineShortener.__lineShorteningRank" ID="LineShortener.__lineShorteningRank"></a>
2621 <h4>LineShortener.__lineShorteningRank</h4>
2622 <b>__lineShorteningRank</b>(<i>candidate</i>)
2623
2624 <p>
2625 Private method to rank a candidate.
2626 </p>
2627 <dl>
2628
2629 <dt><i>candidate</i></dt>
2630 <dd>
2631 candidate line to rank (string)
2632 </dd>
2633 </dl>
2634 <dl>
2635 <dt>Return:</dt>
2636 <dd>
2637 rank of the candidate (integer)
2638 </dd>
2639 </dl>
2640 <a NAME="LineShortener.__normalizeMultiline" ID="LineShortener.__normalizeMultiline"></a>
2641 <h4>LineShortener.__normalizeMultiline</h4>
2642 <b>__normalizeMultiline</b>(<i>text</i>)
2643
2644 <p>
2645 Private method to remove multiline-related code that will cause syntax
2646 error.
2647 </p>
2648 <dl>
2649
2650 <dt><i>text</i></dt>
2651 <dd>
2652 code line to work on (string)
2653 </dd>
2654 </dl>
2655 <dl>
2656 <dt>Return:</dt>
2657 <dd>
2658 normalized code line (string)
2659 </dd>
2660 </dl>
2661 <a NAME="LineShortener.__shortenComment" ID="LineShortener.__shortenComment"></a>
2662 <h4>LineShortener.__shortenComment</h4>
2663 <b>__shortenComment</b>(<i>isLast</i>)
2664
2665 <p>
2666 Private method to shorten a comment line.
2667 </p>
2668 <dl>
2669
2670 <dt><i>isLast</i></dt>
2671 <dd>
2672 flag indicating, that the line is the last comment line
2673 (boolean)
2674 </dd>
2675 </dl>
2676 <dl>
2677 <dt>Return:</dt>
2678 <dd>
2679 shortened comment line (string)
2680 </dd>
2681 </dl>
2682 <a NAME="LineShortener.__shortenLine" ID="LineShortener.__shortenLine"></a>
2683 <h4>LineShortener.__shortenLine</h4>
2684 <b>__shortenLine</b>(<i>tokens, source, indent</i>)
2685
2686 <p>
2687 Private method to shorten a line of code at an operator.
2688 </p>
2689 <dl>
2690
2691 <dt><i>tokens</i></dt>
2692 <dd>
2693 tokens of the line as generated by tokenize
2694 (list of token)
2695 </dd>
2696 <dt><i>source</i></dt>
2697 <dd>
2698 code string to work at (string)
2699 </dd>
2700 <dt><i>indent</i></dt>
2701 <dd>
2702 indentation string of the code line (string)
2703 </dd>
2704 </dl>
2705 <dl>
2706 <dt>Return:</dt>
2707 <dd>
2708 list of candidates (list of string)
2709 </dd>
2710 </dl>
2711 <a NAME="LineShortener.shorten" ID="LineShortener.shorten"></a>
2712 <h4>LineShortener.shorten</h4>
2713 <b>shorten</b>(<i></i>)
2714
2715 <p>
2716 Public method to shorten the line wrapped by the class instance.
2717 </p>
2718 <dl>
2719 <dt>Return:</dt>
2720 <dd>
2721 tuple of a flag indicating successful shortening, the
2722 shortened line and the changed next line (boolean, string, string)
2723 </dd>
2724 </dl>
2725 <div align="right"><a href="#top">Up</a></div>
2726 <hr />
2727 <hr />
2728 <a NAME="Reindenter" ID="Reindenter"></a>
2729 <h2>Reindenter</h2>
2730
2731 <p>
2732 Class to reindent badly-indented code to uniformly use four-space
2733 indentation.
2734 </p>
2735 <p>
2736 Released to the public domain, by Tim Peters, 03 October 2000.
2737 </p>
2738 <h3>Derived from</h3>
2739 None
2740 <h3>Class Attributes</h3>
2741
2742 <table>
2743 <tr><td>None</td></tr>
2744 </table>
2745 <h3>Class Methods</h3>
2746
2747 <table>
2748 <tr><td>None</td></tr>
2749 </table>
2750 <h3>Methods</h3>
2751
2752 <table>
2753
2754 <tr>
2755 <td><a href="#Reindenter.__init__">Reindenter</a></td>
2756 <td>Constructor</td>
2757 </tr>
2758 <tr>
2759 <td><a href="#Reindenter.__genStats">__genStats</a></td>
2760 <td>Private method to generate the re-indent statistics.</td>
2761 </tr>
2762 <tr>
2763 <td><a href="#Reindenter.__getlspace">__getlspace</a></td>
2764 <td>Private method to count number of leading blanks.</td>
2765 </tr>
2766 <tr>
2767 <td><a href="#Reindenter.fixedLine">fixedLine</a></td>
2768 <td>Public method to get a fixed line.</td>
2769 </tr>
2770 <tr>
2771 <td><a href="#Reindenter.getline">getline</a></td>
2772 <td>Public method to get a line of text for tokenize.</td>
2773 </tr>
2774 <tr>
2775 <td><a href="#Reindenter.run">run</a></td>
2776 <td>Public method to run the re-indenter.</td>
2777 </tr>
2778 </table>
2779 <h3>Static Methods</h3>
2780
2781 <table>
2782 <tr><td>None</td></tr>
2783 </table>
2784
2785 <a NAME="Reindenter.__init__" ID="Reindenter.__init__"></a>
2786 <h4>Reindenter (Constructor)</h4>
2787 <b>Reindenter</b>(<i>sourceLines</i>)
2788
2789 <p>
2790 Constructor
2791 </p>
2792 <dl>
2793
2794 <dt><i>sourceLines</i></dt>
2795 <dd>
2796 list of source lines including eol marker
2797 (list of string)
2798 </dd>
2799 </dl>
2800 <a NAME="Reindenter.__genStats" ID="Reindenter.__genStats"></a>
2801 <h4>Reindenter.__genStats</h4>
2802 <b>__genStats</b>(<i>tokens</i>)
2803
2804 <p>
2805 Private method to generate the re-indent statistics.
2806 </p>
2807 <dl>
2808
2809 <dt><i>tokens</i></dt>
2810 <dd>
2811 tokens generator (tokenize._tokenize)
2812 </dd>
2813 </dl>
2814 <dl>
2815 <dt>Return:</dt>
2816 <dd>
2817 reference to the generated statistics
2818 </dd>
2819 </dl>
2820 <a NAME="Reindenter.__getlspace" ID="Reindenter.__getlspace"></a>
2821 <h4>Reindenter.__getlspace</h4>
2822 <b>__getlspace</b>(<i>line</i>)
2823
2824 <p>
2825 Private method to count number of leading blanks.
2826 </p>
2827 <dl>
2828
2829 <dt><i>line</i></dt>
2830 <dd>
2831 line to check (string)
2832 </dd>
2833 </dl>
2834 <dl>
2835 <dt>Return:</dt>
2836 <dd>
2837 number of leading blanks (integer)
2838 </dd>
2839 </dl>
2840 <a NAME="Reindenter.fixedLine" ID="Reindenter.fixedLine"></a>
2841 <h4>Reindenter.fixedLine</h4>
2842 <b>fixedLine</b>(<i>line</i>)
2843
2844 <p>
2845 Public method to get a fixed line.
2846 </p>
2847 <dl>
2848
2849 <dt><i>line</i></dt>
2850 <dd>
2851 number of the line to retrieve (integer)
2852 </dd>
2853 </dl>
2854 <dl>
2855 <dt>Return:</dt>
2856 <dd>
2857 fixed line (string)
2858 </dd>
2859 </dl>
2860 <a NAME="Reindenter.getline" ID="Reindenter.getline"></a>
2861 <h4>Reindenter.getline</h4>
2862 <b>getline</b>(<i></i>)
2863
2864 <p>
2865 Public method to get a line of text for tokenize.
2866 </p>
2867 <dl>
2868 <dt>Return:</dt>
2869 <dd>
2870 line of text (string)
2871 </dd>
2872 </dl>
2873 <a NAME="Reindenter.run" ID="Reindenter.run"></a>
2874 <h4>Reindenter.run</h4>
2875 <b>run</b>(<i></i>)
2876
2877 <p>
2878 Public method to run the re-indenter.
2879 </p>
2880 <dl>
2881 <dt>Return:</dt>
2882 <dd>
2883 flag indicating that a change was done (boolean)
2884 </dd>
2885 </dl>
2886 <div align="right"><a href="#top">Up</a></div>
2887 <hr />
2888 </body></html>

eric ide

mercurial