Documentation/Source/eric5.UtilitiesPython2.py2flakes.checker.html

changeset 802
e8882d16384c
child 1228
7afaf2fca55b
child 1278
fb0460fd00b9
equal deleted inserted replaced
801:16f9875e278b 802:e8882d16384c
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
4 <html><head>
5 <title>eric5.UtilitiesPython2.py2flakes.checker</title>
6 <style>
7 body {
8 background: #EDECE6;
9 margin: 0em 1em 10em 1em;
10 color: black;
11 }
12
13 h1 { color: white; background: #85774A; }
14 h2 { color: white; background: #85774A; }
15 h3 { color: white; background: #9D936E; }
16 h4 { color: white; background: #9D936E; }
17
18 a { color: #BA6D36; }
19
20 </style>
21 </head>
22 <body><a NAME="top" ID="top"></a>
23 <h1>eric5.UtilitiesPython2.py2flakes.checker</h1>
24
25 <h3>Global Attributes</h3>
26 <table>
27 <tr><td>_MAGIC_GLOBALS</td></tr>
28 </table>
29 <h3>Classes</h3>
30 <table>
31 <tr>
32 <td><a href="#Argument">Argument</a></td>
33 <td>Represents binding a name as an argument.</td>
34 </tr><tr>
35 <td><a href="#Assignment">Assignment</a></td>
36 <td>Represents binding a name with an explicit assignment.</td>
37 </tr><tr>
38 <td><a href="#Binding">Binding</a></td>
39 <td>Represents the binding of a value to a name.</td>
40 </tr><tr>
41 <td><a href="#Checker">Checker</a></td>
42 <td>Class to check the cleanliness and sanity of Python code.</td>
43 </tr><tr>
44 <td><a href="#ClassScope">ClassScope</a></td>
45 <td>Class representing a name scope for a class.</td>
46 </tr><tr>
47 <td><a href="#ExportBinding">ExportBinding</a></td>
48 <td>A binding created by an __all__ assignment.</td>
49 </tr><tr>
50 <td><a href="#FunctionDefinition">FunctionDefinition</a></td>
51 <td>Represents a function definition.</td>
52 </tr><tr>
53 <td><a href="#FunctionScope">FunctionScope</a></td>
54 <td>Class representing a name scope for a function.</td>
55 </tr><tr>
56 <td><a href="#Importation">Importation</a></td>
57 <td>A binding created by an import statement.</td>
58 </tr><tr>
59 <td><a href="#ModuleScope">ModuleScope</a></td>
60 <td>Class representing a name scope for a module.</td>
61 </tr><tr>
62 <td><a href="#Scope">Scope</a></td>
63 <td>Class defining the scope base class.</td>
64 </tr><tr>
65 <td><a href="#UnBinding">UnBinding</a></td>
66 <td>Created by the 'del' operator.</td>
67 </tr>
68 </table>
69 <h3>Functions</h3>
70 <table>
71 <tr><td>None</td></tr>
72 </table>
73 <hr /><hr />
74 <a NAME="Argument" ID="Argument"></a>
75 <h2>Argument</h2>
76 <p>
77 Represents binding a name as an argument.
78 </p>
79 <h3>Derived from</h3>
80 Binding
81 <h3>Class Attributes</h3>
82 <table>
83 <tr><td>None</td></tr>
84 </table>
85 <h3>Methods</h3>
86 <table>
87 <tr><td>None</td></tr>
88 </table>
89
90 <div align="right"><a href="#top">Up</a></div>
91 <hr /><hr />
92 <a NAME="Assignment" ID="Assignment"></a>
93 <h2>Assignment</h2>
94 <p>
95 Represents binding a name with an explicit assignment.
96 </p><p>
97 The checker will raise warnings for any Assignment that isn't used. Also,
98 the checker does not consider assignments in tuple/list unpacking to be
99 Assignments, rather it treats them as simple Bindings.
100 </p>
101 <h3>Derived from</h3>
102 Binding
103 <h3>Class Attributes</h3>
104 <table>
105 <tr><td>None</td></tr>
106 </table>
107 <h3>Methods</h3>
108 <table>
109 <tr><td>None</td></tr>
110 </table>
111
112 <div align="right"><a href="#top">Up</a></div>
113 <hr /><hr />
114 <a NAME="Binding" ID="Binding"></a>
115 <h2>Binding</h2>
116 <p>
117 Represents the binding of a value to a name.
118 </p><p>
119 The checker uses this to keep track of which names have been bound and
120 which names have not. See L{Assignment} for a special type of binding that
121 is checked with stricter rules.
122 </p>
123 <h3>Derived from</h3>
124 object
125 <h3>Class Attributes</h3>
126 <table>
127 <tr><td>None</td></tr>
128 </table>
129 <h3>Methods</h3>
130 <table>
131 <tr>
132 <td><a href="#Binding.__init__">Binding</a></td>
133 <td></td>
134 </tr><tr>
135 <td><a href="#Binding.__repr__">__repr__</a></td>
136 <td></td>
137 </tr><tr>
138 <td><a href="#Binding.__str__">__str__</a></td>
139 <td></td>
140 </tr>
141 </table>
142 <a NAME="Binding.__init__" ID="Binding.__init__"></a>
143 <h4>Binding (Constructor)</h4>
144 <b>Binding</b>(<i>name, source</i>)
145 <a NAME="Binding.__repr__" ID="Binding.__repr__"></a>
146 <h4>Binding.__repr__</h4>
147 <b>__repr__</b>(<i></i>)
148 <a NAME="Binding.__str__" ID="Binding.__str__"></a>
149 <h4>Binding.__str__</h4>
150 <b>__str__</b>(<i></i>)
151
152 <div align="right"><a href="#top">Up</a></div>
153 <hr /><hr />
154 <a NAME="Checker" ID="Checker"></a>
155 <h2>Checker</h2>
156 <p>
157 Class to check the cleanliness and sanity of Python code.
158 </p>
159 <h3>Derived from</h3>
160 object
161 <h3>Class Attributes</h3>
162 <table>
163 <tr><td>ASSLIST</td></tr><tr><td>AUGASSIGN</td></tr><tr><td>CONST</td></tr><tr><td>FLOORDIV</td></tr><tr><td>GENEXPRINNER</td></tr><tr><td>IFEXP</td></tr><tr><td>RETURN</td></tr><tr><td>RIGHTSHIFT</td></tr><tr><td>STMT</td></tr><tr><td>SUBSCRIPT</td></tr><tr><td>nodeDepth</td></tr><tr><td>scope</td></tr><tr><td>traceTree</td></tr>
164 </table>
165 <h3>Methods</h3>
166 <table>
167 <tr>
168 <td><a href="#Checker.__init__">Checker</a></td>
169 <td>Constructor</td>
170 </tr><tr>
171 <td><a href="#Checker.ASSIGN">ASSIGN</a></td>
172 <td></td>
173 </tr><tr>
174 <td><a href="#Checker.ASSNAME">ASSNAME</a></td>
175 <td></td>
176 </tr><tr>
177 <td><a href="#Checker.CLASS">CLASS</a></td>
178 <td>Check names used in a class definition, including its decorators, base classes, and the body of its definition.</td>
179 </tr><tr>
180 <td><a href="#Checker.FOR">FOR</a></td>
181 <td>Process bindings for loop variables.</td>
182 </tr><tr>
183 <td><a href="#Checker.FROM">FROM</a></td>
184 <td></td>
185 </tr><tr>
186 <td><a href="#Checker.FUNCTION">FUNCTION</a></td>
187 <td></td>
188 </tr><tr>
189 <td><a href="#Checker.GLOBAL">GLOBAL</a></td>
190 <td>Keep track of globals declarations.</td>
191 </tr><tr>
192 <td><a href="#Checker.IMPORT">IMPORT</a></td>
193 <td></td>
194 </tr><tr>
195 <td><a href="#Checker.LAMBDA">LAMBDA</a></td>
196 <td></td>
197 </tr><tr>
198 <td><a href="#Checker.LISTCOMP">LISTCOMP</a></td>
199 <td></td>
200 </tr><tr>
201 <td><a href="#Checker.NAME">NAME</a></td>
202 <td>Locate the name in locals / function / globals scopes.</td>
203 </tr><tr>
204 <td><a href="#Checker.WITH">WITH</a></td>
205 <td>Handle 'with' by checking the target of the statement (which can be an identifier, a list or tuple of targets, an attribute, etc) for undefined names and defining any it adds to the scope and by continuing to process the suite within the statement.</td>
206 </tr><tr>
207 <td><a href="#Checker._runDeferred">_runDeferred</a></td>
208 <td>Run the callables in C{deferred} using their associated scope stack.</td>
209 </tr><tr>
210 <td><a href="#Checker.addArgs">addArgs</a></td>
211 <td></td>
212 </tr><tr>
213 <td><a href="#Checker.addBinding">addBinding</a></td>
214 <td>Called when a binding is altered.</td>
215 </tr><tr>
216 <td><a href="#Checker.checkUnusedAssignments">checkUnusedAssignments</a></td>
217 <td>Check to see if any assignments have not been used.</td>
218 </tr><tr>
219 <td><a href="#Checker.check_dead_scopes">check_dead_scopes</a></td>
220 <td>Look at scopes which have been fully examined and report names in them which were imported but unused.</td>
221 </tr><tr>
222 <td><a href="#Checker.collectLoopVars">collectLoopVars</a></td>
223 <td></td>
224 </tr><tr>
225 <td><a href="#Checker.deferAssignment">deferAssignment</a></td>
226 <td>Schedule an assignment handler to be called just after deferred function handlers.</td>
227 </tr><tr>
228 <td><a href="#Checker.deferFunction">deferFunction</a></td>
229 <td>Schedule a function handler to be called just before completion.</td>
230 </tr><tr>
231 <td><a href="#Checker.handleChildren">handleChildren</a></td>
232 <td></td>
233 </tr><tr>
234 <td><a href="#Checker.handleNode">handleNode</a></td>
235 <td></td>
236 </tr><tr>
237 <td><a href="#Checker.ignore">ignore</a></td>
238 <td></td>
239 </tr><tr>
240 <td><a href="#Checker.popScope">popScope</a></td>
241 <td></td>
242 </tr><tr>
243 <td><a href="#Checker.pushClassScope">pushClassScope</a></td>
244 <td></td>
245 </tr><tr>
246 <td><a href="#Checker.pushFunctionScope">pushFunctionScope</a></td>
247 <td></td>
248 </tr><tr>
249 <td><a href="#Checker.report">report</a></td>
250 <td></td>
251 </tr><tr>
252 <td><a href="#Checker.runFunction">runFunction</a></td>
253 <td></td>
254 </tr><tr>
255 <td><a href="#Checker.scope">scope</a></td>
256 <td></td>
257 </tr>
258 </table>
259 <a NAME="Checker.__init__" ID="Checker.__init__"></a>
260 <h4>Checker (Constructor)</h4>
261 <b>Checker</b>(<i>module, filename='(none)'</i>)
262 <p>
263 Constructor
264 </p><dl>
265 <dt><i>module</i></dt>
266 <dd>
267 parsed module tree or module source code
268 </dd><dt><i>filename</i></dt>
269 <dd>
270 name of the module file (string)
271 </dd>
272 </dl><a NAME="Checker.ASSIGN" ID="Checker.ASSIGN"></a>
273 <h4>Checker.ASSIGN</h4>
274 <b>ASSIGN</b>(<i>node</i>)
275 <a NAME="Checker.ASSNAME" ID="Checker.ASSNAME"></a>
276 <h4>Checker.ASSNAME</h4>
277 <b>ASSNAME</b>(<i>node</i>)
278 <a NAME="Checker.CLASS" ID="Checker.CLASS"></a>
279 <h4>Checker.CLASS</h4>
280 <b>CLASS</b>(<i>node</i>)
281 <p>
282 Check names used in a class definition, including its decorators, base
283 classes, and the body of its definition. Additionally, add its name to
284 the current scope.
285 </p><a NAME="Checker.FOR" ID="Checker.FOR"></a>
286 <h4>Checker.FOR</h4>
287 <b>FOR</b>(<i>node</i>)
288 <p>
289 Process bindings for loop variables.
290 </p><a NAME="Checker.FROM" ID="Checker.FROM"></a>
291 <h4>Checker.FROM</h4>
292 <b>FROM</b>(<i>node</i>)
293 <a NAME="Checker.FUNCTION" ID="Checker.FUNCTION"></a>
294 <h4>Checker.FUNCTION</h4>
295 <b>FUNCTION</b>(<i>node</i>)
296 <a NAME="Checker.GLOBAL" ID="Checker.GLOBAL"></a>
297 <h4>Checker.GLOBAL</h4>
298 <b>GLOBAL</b>(<i>node</i>)
299 <p>
300 Keep track of globals declarations.
301 </p><a NAME="Checker.IMPORT" ID="Checker.IMPORT"></a>
302 <h4>Checker.IMPORT</h4>
303 <b>IMPORT</b>(<i>node</i>)
304 <a NAME="Checker.LAMBDA" ID="Checker.LAMBDA"></a>
305 <h4>Checker.LAMBDA</h4>
306 <b>LAMBDA</b>(<i>node</i>)
307 <a NAME="Checker.LISTCOMP" ID="Checker.LISTCOMP"></a>
308 <h4>Checker.LISTCOMP</h4>
309 <b>LISTCOMP</b>(<i>node</i>)
310 <a NAME="Checker.NAME" ID="Checker.NAME"></a>
311 <h4>Checker.NAME</h4>
312 <b>NAME</b>(<i>node</i>)
313 <p>
314 Locate the name in locals / function / globals scopes.
315 </p><a NAME="Checker.WITH" ID="Checker.WITH"></a>
316 <h4>Checker.WITH</h4>
317 <b>WITH</b>(<i>node</i>)
318 <p>
319 Handle 'with' by checking the target of the statement (which can be an
320 identifier, a list or tuple of targets, an attribute, etc) for
321 undefined names and defining any it adds to the scope and by continuing
322 to process the suite within the statement.
323 </p><a NAME="Checker._runDeferred" ID="Checker._runDeferred"></a>
324 <h4>Checker._runDeferred</h4>
325 <b>_runDeferred</b>(<i>deferred</i>)
326 <p>
327 Run the callables in C{deferred} using their associated scope stack.
328 </p><a NAME="Checker.addArgs" ID="Checker.addArgs"></a>
329 <h4>Checker.addArgs</h4>
330 <b>addArgs</b>(<i></i>)
331 <a NAME="Checker.addBinding" ID="Checker.addBinding"></a>
332 <h4>Checker.addBinding</h4>
333 <b>addBinding</b>(<i>lineno, value, reportRedef=True</i>)
334 <p>
335 Called when a binding is altered.
336 </p><dl>
337 <dt><i>lineno</i></dt>
338 <dd>
339 line of the statement responsible for the change (integer)
340 </dd><dt><i>value</i></dt>
341 <dd>
342 the optional new value, a Binding instance, associated
343 with the binding; if None, the binding is deleted if it exists
344 </dd><dt><i>reportRedef</i></dt>
345 <dd>
346 flag indicating if rebinding while unused will be
347 reported (boolean)
348 </dd>
349 </dl><a NAME="Checker.checkUnusedAssignments" ID="Checker.checkUnusedAssignments"></a>
350 <h4>Checker.checkUnusedAssignments</h4>
351 <b>checkUnusedAssignments</b>(<i></i>)
352 <p>
353 Check to see if any assignments have not been used.
354 </p><a NAME="Checker.check_dead_scopes" ID="Checker.check_dead_scopes"></a>
355 <h4>Checker.check_dead_scopes</h4>
356 <b>check_dead_scopes</b>(<i></i>)
357 <p>
358 Look at scopes which have been fully examined and report names in them
359 which were imported but unused.
360 </p><a NAME="Checker.collectLoopVars" ID="Checker.collectLoopVars"></a>
361 <h4>Checker.collectLoopVars</h4>
362 <b>collectLoopVars</b>(<i></i>)
363 <a NAME="Checker.deferAssignment" ID="Checker.deferAssignment"></a>
364 <h4>Checker.deferAssignment</h4>
365 <b>deferAssignment</b>(<i>callable</i>)
366 <p>
367 Schedule an assignment handler to be called just after deferred
368 function handlers.
369 </p><a NAME="Checker.deferFunction" ID="Checker.deferFunction"></a>
370 <h4>Checker.deferFunction</h4>
371 <b>deferFunction</b>(<i>callable</i>)
372 <p>
373 Schedule a function handler to be called just before completion.
374 </p><p>
375 This is used for handling function bodies, which must be deferred
376 because code later in the file might modify the global scope. When
377 `callable` is called, the scope at the time this is called will be
378 restored, however it will contain any new bindings added to it.
379 </p><a NAME="Checker.handleChildren" ID="Checker.handleChildren"></a>
380 <h4>Checker.handleChildren</h4>
381 <b>handleChildren</b>(<i>tree</i>)
382 <a NAME="Checker.handleNode" ID="Checker.handleNode"></a>
383 <h4>Checker.handleNode</h4>
384 <b>handleNode</b>(<i>node, parent</i>)
385 <a NAME="Checker.ignore" ID="Checker.ignore"></a>
386 <h4>Checker.ignore</h4>
387 <b>ignore</b>(<i>node</i>)
388 <a NAME="Checker.popScope" ID="Checker.popScope"></a>
389 <h4>Checker.popScope</h4>
390 <b>popScope</b>(<i></i>)
391 <a NAME="Checker.pushClassScope" ID="Checker.pushClassScope"></a>
392 <h4>Checker.pushClassScope</h4>
393 <b>pushClassScope</b>(<i></i>)
394 <a NAME="Checker.pushFunctionScope" ID="Checker.pushFunctionScope"></a>
395 <h4>Checker.pushFunctionScope</h4>
396 <b>pushFunctionScope</b>(<i></i>)
397 <a NAME="Checker.report" ID="Checker.report"></a>
398 <h4>Checker.report</h4>
399 <b>report</b>(<i>messageClass, *args, **kwargs</i>)
400 <a NAME="Checker.runFunction" ID="Checker.runFunction"></a>
401 <h4>Checker.runFunction</h4>
402 <b>runFunction</b>(<i></i>)
403 <a NAME="Checker.scope" ID="Checker.scope"></a>
404 <h4>Checker.scope</h4>
405 <b>scope</b>(<i></i>)
406
407 <div align="right"><a href="#top">Up</a></div>
408 <hr /><hr />
409 <a NAME="ClassScope" ID="ClassScope"></a>
410 <h2>ClassScope</h2>
411 <p>
412 Class representing a name scope for a class.
413 </p>
414 <h3>Derived from</h3>
415 Scope
416 <h3>Class Attributes</h3>
417 <table>
418 <tr><td>None</td></tr>
419 </table>
420 <h3>Methods</h3>
421 <table>
422 <tr><td>None</td></tr>
423 </table>
424
425 <div align="right"><a href="#top">Up</a></div>
426 <hr /><hr />
427 <a NAME="ExportBinding" ID="ExportBinding"></a>
428 <h2>ExportBinding</h2>
429 <p>
430 A binding created by an __all__ assignment. If the names in the list
431 can be determined statically, they will be treated as names for export and
432 additional checking applied to them.
433 </p><p>
434 The only __all__ assignment that can be recognized is one which takes
435 the value of a literal list containing literal strings. For example::
436 </p><p>
437 __all__ = ["foo", "bar"]
438 </p><p>
439 Names which are imported and not otherwise used but appear in the value of
440 __all__ will not have an unused import warning reported for them.
441 </p>
442 <h3>Derived from</h3>
443 Binding
444 <h3>Class Attributes</h3>
445 <table>
446 <tr><td>None</td></tr>
447 </table>
448 <h3>Methods</h3>
449 <table>
450 <tr>
451 <td><a href="#ExportBinding.names">names</a></td>
452 <td>Return a list of the names referenced by this binding.</td>
453 </tr>
454 </table>
455 <a NAME="ExportBinding.names" ID="ExportBinding.names"></a>
456 <h4>ExportBinding.names</h4>
457 <b>names</b>(<i></i>)
458 <p>
459 Return a list of the names referenced by this binding.
460 </p>
461 <div align="right"><a href="#top">Up</a></div>
462 <hr /><hr />
463 <a NAME="FunctionDefinition" ID="FunctionDefinition"></a>
464 <h2>FunctionDefinition</h2>
465 <p>
466 Represents a function definition.
467 </p>
468 <h3>Derived from</h3>
469 Binding
470 <h3>Class Attributes</h3>
471 <table>
472 <tr><td>None</td></tr>
473 </table>
474 <h3>Methods</h3>
475 <table>
476 <tr><td>None</td></tr>
477 </table>
478
479 <div align="right"><a href="#top">Up</a></div>
480 <hr /><hr />
481 <a NAME="FunctionScope" ID="FunctionScope"></a>
482 <h2>FunctionScope</h2>
483 <p>
484 Class representing a name scope for a function.
485 </p>
486 <h3>Derived from</h3>
487 Scope
488 <h3>Class Attributes</h3>
489 <table>
490 <tr><td>None</td></tr>
491 </table>
492 <h3>Methods</h3>
493 <table>
494 <tr>
495 <td><a href="#FunctionScope.__init__">FunctionScope</a></td>
496 <td></td>
497 </tr>
498 </table>
499 <a NAME="FunctionScope.__init__" ID="FunctionScope.__init__"></a>
500 <h4>FunctionScope (Constructor)</h4>
501 <b>FunctionScope</b>(<i></i>)
502
503 <div align="right"><a href="#top">Up</a></div>
504 <hr /><hr />
505 <a NAME="Importation" ID="Importation"></a>
506 <h2>Importation</h2>
507 <p>
508 A binding created by an import statement.
509 </p>
510 <h3>Derived from</h3>
511 Binding
512 <h3>Class Attributes</h3>
513 <table>
514 <tr><td>None</td></tr>
515 </table>
516 <h3>Methods</h3>
517 <table>
518 <tr>
519 <td><a href="#Importation.__init__">Importation</a></td>
520 <td></td>
521 </tr>
522 </table>
523 <a NAME="Importation.__init__" ID="Importation.__init__"></a>
524 <h4>Importation (Constructor)</h4>
525 <b>Importation</b>(<i>name, source</i>)
526
527 <div align="right"><a href="#top">Up</a></div>
528 <hr /><hr />
529 <a NAME="ModuleScope" ID="ModuleScope"></a>
530 <h2>ModuleScope</h2>
531 <p>
532 Class representing a name scope for a module.
533 </p>
534 <h3>Derived from</h3>
535 Scope
536 <h3>Class Attributes</h3>
537 <table>
538 <tr><td>None</td></tr>
539 </table>
540 <h3>Methods</h3>
541 <table>
542 <tr><td>None</td></tr>
543 </table>
544
545 <div align="right"><a href="#top">Up</a></div>
546 <hr /><hr />
547 <a NAME="Scope" ID="Scope"></a>
548 <h2>Scope</h2>
549 <p>
550 Class defining the scope base class.
551 </p>
552 <h3>Derived from</h3>
553 dict
554 <h3>Class Attributes</h3>
555 <table>
556 <tr><td>importStarred</td></tr>
557 </table>
558 <h3>Methods</h3>
559 <table>
560 <tr>
561 <td><a href="#Scope.__init__">Scope</a></td>
562 <td></td>
563 </tr><tr>
564 <td><a href="#Scope.__repr__">__repr__</a></td>
565 <td></td>
566 </tr>
567 </table>
568 <a NAME="Scope.__init__" ID="Scope.__init__"></a>
569 <h4>Scope (Constructor)</h4>
570 <b>Scope</b>(<i></i>)
571 <a NAME="Scope.__repr__" ID="Scope.__repr__"></a>
572 <h4>Scope.__repr__</h4>
573 <b>__repr__</b>(<i></i>)
574
575 <div align="right"><a href="#top">Up</a></div>
576 <hr /><hr />
577 <a NAME="UnBinding" ID="UnBinding"></a>
578 <h2>UnBinding</h2>
579 <p>
580 Created by the 'del' operator.
581 </p>
582 <h3>Derived from</h3>
583 Binding
584 <h3>Class Attributes</h3>
585 <table>
586 <tr><td>None</td></tr>
587 </table>
588 <h3>Methods</h3>
589 <table>
590 <tr><td>None</td></tr>
591 </table>
592
593 <div align="right"><a href="#top">Up</a></div>
594 <hr />
595 </body></html>

eric ide

mercurial