src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.MiscellaneousChecker.html

branch
eric7
changeset 9327
2b768afcaee1
parent 9295
d14096c04126
child 9596
397f385b95d8
equal deleted inserted replaced
9326:1d8eadd8873e 9327:2b768afcaee1
12 Module implementing a checker for miscellaneous checks. 12 Module implementing a checker for miscellaneous checks.
13 </p> 13 </p>
14 <h3>Global Attributes</h3> 14 <h3>Global Attributes</h3>
15 15
16 <table> 16 <table>
17 <tr><td>None</td></tr> 17 <tr><td>BugBearContext</td></tr>
18 </table> 18 </table>
19 <h3>Classes</h3> 19 <h3>Classes</h3>
20 20
21 <table> 21 <table>
22 22
29 <td>Class implementing a node visitor to check datetime function calls.</td> 29 <td>Class implementing a node visitor to check datetime function calls.</td>
30 </tr> 30 </tr>
31 <tr> 31 <tr>
32 <td><a href="#LoggingVisitor">LoggingVisitor</a></td> 32 <td><a href="#LoggingVisitor">LoggingVisitor</a></td>
33 <td>Class implementing a node visitor to check logging statements.</td> 33 <td>Class implementing a node visitor to check logging statements.</td>
34 </tr>
35 <tr>
36 <td><a href="#M520NameFinder">M520NameFinder</a></td>
37 <td>Class to extract a name out of a tree of nodes ignoring names defined within the local scope of a comprehension.</td>
34 </tr> 38 </tr>
35 <tr> 39 <tr>
36 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> 40 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td>
37 <td>Class implementing a checker for miscellaneous checks.</td> 41 <td>Class implementing a checker for miscellaneous checks.</td>
38 </tr> 42 </tr>
73 <h3>Derived from</h3> 77 <h3>Derived from</h3>
74 ast.NodeVisitor 78 ast.NodeVisitor
75 <h3>Class Attributes</h3> 79 <h3>Class Attributes</h3>
76 80
77 <table> 81 <table>
78 <tr><td>NodeWindowSize</td></tr> 82 <tr><td>CONTEXTFUL_NODES</td></tr><tr><td>FUNCTION_NODES</td></tr><tr><td>NodeWindowSize</td></tr>
79 </table> 83 </table>
80 <h3>Class Methods</h3> 84 <h3>Class Methods</h3>
81 85
82 <table> 86 <table>
83 <tr><td>None</td></tr> 87 <tr><td>None</td></tr>
89 <tr> 93 <tr>
90 <td><a href="#BugBearVisitor.__init__">BugBearVisitor</a></td> 94 <td><a href="#BugBearVisitor.__init__">BugBearVisitor</a></td>
91 <td>Constructor</td> 95 <td>Constructor</td>
92 </tr> 96 </tr>
93 <tr> 97 <tr>
94 <td><a href="#BugBearVisitor.__checkForM502">__checkForM502</a></td> 98 <td><a href="#BugBearVisitor.__checkForM505">__checkForM505</a></td>
95 <td>Private method to check the use of *strip().</td> 99 <td>Private method to check the use of *strip().</td>
96 </tr> 100 </tr>
97 <tr> 101 <tr>
98 <td><a href="#BugBearVisitor.__checkForM507">__checkForM507</a></td> 102 <td><a href="#BugBearVisitor.__checkForM507">__checkForM507</a></td>
99 <td>Private method to check for unused loop variables.</td> 103 <td>Private method to check for unused loop variables.</td>
100 </tr> 104 </tr>
101 <tr> 105 <tr>
106 <td><a href="#BugBearVisitor.__checkForM512">__checkForM512</a></td>
107 <td>Private method to check for return/continue/break inside finally blocks.</td>
108 </tr>
109 <tr>
110 <td><a href="#BugBearVisitor.__checkForM515">__checkForM515</a></td>
111 <td>Private method to check for pointless comparisons.</td>
112 </tr>
113 <tr>
114 <td><a href="#BugBearVisitor.__checkForM516">__checkForM516</a></td>
115 <td>Private method to check for raising a literal instead of an exception.</td>
116 </tr>
117 <tr>
118 <td><a href="#BugBearVisitor.__checkForM517">__checkForM517</a></td>
119 <td>Private method to check for use of the evil syntax 'with assertRaises(Exception):.</td>
120 </tr>
121 <tr>
122 <td><a href="#BugBearVisitor.__checkForM518">__checkForM518</a></td>
123 <td>Private method to check for useless expressions.</td>
124 </tr>
125 <tr>
126 <td><a href="#BugBearVisitor.__checkForM519">__checkForM519</a></td>
127 <td>Private method to check for use of 'functools.lru_cache' or 'functools.cache'.</td>
128 </tr>
129 <tr>
130 <td><a href="#BugBearVisitor.__checkForM520">__checkForM520</a></td>
131 <td>Private method to check for a loop that modifies its iterable.</td>
132 </tr>
133 <tr>
134 <td><a href="#BugBearVisitor.__checkForM521">__checkForM521</a></td>
135 <td>Private method to check for use of an f-string as docstring.</td>
136 </tr>
137 <tr>
138 <td><a href="#BugBearVisitor.__checkForM522">__checkForM522</a></td>
139 <td>Private method to check for use of an f-string as docstring.</td>
140 </tr>
141 <tr>
142 <td><a href="#BugBearVisitor.__checkForM523">__checkForM523</a></td>
143 <td>Private method to check that functions (including lambdas) do not use loop variables.</td>
144 </tr>
145 <tr>
146 <td><a href="#BugBearVisitor.__checkForM524">__checkForM524</a></td>
147 <td>Private method to check for inheritance from abstract classes in abc and lack of any methods decorated with abstract*.</td>
148 </tr>
149 <tr>
150 <td><a href="#BugBearVisitor.__checkForM525">__checkForM525</a></td>
151 <td>Private method to check for exceptions being handled multiple times.</td>
152 </tr>
153 <tr>
154 <td><a href="#BugBearVisitor.__childrenInScope">__childrenInScope</a></td>
155 <td>Private method to get all child nodes in the given scope.</td>
156 </tr>
157 <tr>
158 <td><a href="#BugBearVisitor.__composeCallPath">__composeCallPath</a></td>
159 <td>Private method get the individual elements of the call path of a node.</td>
160 </tr>
161 <tr>
162 <td><a href="#BugBearVisitor.__getAssignedNames">__getAssignedNames</a></td>
163 <td>Private method to get the names of a for loop.</td>
164 </tr>
165 <tr>
166 <td><a href="#BugBearVisitor.__isIdentifier">__isIdentifier</a></td>
167 <td>Private method to check if arg is a valid identifier.</td>
168 </tr>
169 <tr>
170 <td><a href="#BugBearVisitor.__namesFromAssignments">__namesFromAssignments</a></td>
171 <td>Private method to get names of an assignment.</td>
172 </tr>
173 <tr>
174 <td><a href="#BugBearVisitor.__toNameStr">__toNameStr</a></td>
175 <td>Private method to turn Name and Attribute nodes to strings, handling any depth of attribute accesses.</td>
176 </tr>
177 <tr>
178 <td><a href="#BugBearVisitor.__typesafeIssubclass">__typesafeIssubclass</a></td>
179 <td>Private method implementing a type safe issubclass() function.</td>
180 </tr>
181 <tr>
182 <td><a href="#BugBearVisitor._loop">_loop</a></td>
183 <td></td>
184 </tr>
185 <tr>
186 <td><a href="#BugBearVisitor.isAbcClass">isAbcClass</a></td>
187 <td></td>
188 </tr>
189 <tr>
190 <td><a href="#BugBearVisitor.isAbstractDecorator">isAbstractDecorator</a></td>
191 <td></td>
192 </tr>
193 <tr>
194 <td><a href="#BugBearVisitor.nodeStack">nodeStack</a></td>
195 <td>Public method to get a reference to the most recent node stack.</td>
196 </tr>
197 <tr>
102 <td><a href="#BugBearVisitor.visit">visit</a></td> 198 <td><a href="#BugBearVisitor.visit">visit</a></td>
103 <td>Public method to traverse a given AST node.</td> 199 <td>Public method to traverse a given AST node.</td>
104 </tr> 200 </tr>
105 <tr> 201 <tr>
106 <td><a href="#BugBearVisitor.visit_Assert">visit_Assert</a></td> 202 <td><a href="#BugBearVisitor.visit_Assert">visit_Assert</a></td>
113 <tr> 209 <tr>
114 <td><a href="#BugBearVisitor.visit_AsyncFor">visit_AsyncFor</a></td> 210 <td><a href="#BugBearVisitor.visit_AsyncFor">visit_AsyncFor</a></td>
115 <td>Public method to handle 'for' statements.</td> 211 <td>Public method to handle 'for' statements.</td>
116 </tr> 212 </tr>
117 <tr> 213 <tr>
118 <td><a href="#BugBearVisitor.visit_Attribute">visit_Attribute</a></td>
119 <td>Public method to handle attributes.</td>
120 </tr>
121 <tr>
122 <td><a href="#BugBearVisitor.visit_Call">visit_Call</a></td> 214 <td><a href="#BugBearVisitor.visit_Call">visit_Call</a></td>
123 <td>Public method to handle a function call.</td> 215 <td>Public method to handle a function call.</td>
124 </tr> 216 </tr>
125 <tr> 217 <tr>
218 <td><a href="#BugBearVisitor.visit_ClassDef">visit_ClassDef</a></td>
219 <td>Public method to handle class definitions.</td>
220 </tr>
221 <tr>
222 <td><a href="#BugBearVisitor.visit_Compare">visit_Compare</a></td>
223 <td>Public method to handle comparison statements.</td>
224 </tr>
225 <tr>
226 <td><a href="#BugBearVisitor.visit_DictComp">visit_DictComp</a></td>
227 <td>Public method to handle dictionary comprehensions.</td>
228 </tr>
229 <tr>
230 <td><a href="#BugBearVisitor.visit_ExceptHandler">visit_ExceptHandler</a></td>
231 <td>Public method to handle exception handlers.</td>
232 </tr>
233 <tr>
126 <td><a href="#BugBearVisitor.visit_For">visit_For</a></td> 234 <td><a href="#BugBearVisitor.visit_For">visit_For</a></td>
127 <td>Public method to handle 'for' statements.</td> 235 <td>Public method to handle 'for' statements.</td>
128 </tr> 236 </tr>
129 <tr> 237 <tr>
238 <td><a href="#BugBearVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
239 <td>Public method to handle function definitions.</td>
240 </tr>
241 <tr>
242 <td><a href="#BugBearVisitor.visit_GeneratorExp">visit_GeneratorExp</a></td>
243 <td>Public method to handle generator expressions.</td>
244 </tr>
245 <tr>
130 <td><a href="#BugBearVisitor.visit_JoinedStr">visit_JoinedStr</a></td> 246 <td><a href="#BugBearVisitor.visit_JoinedStr">visit_JoinedStr</a></td>
131 <td>Public method to handle f-string arguments.</td> 247 <td>Public method to handle f-string arguments.</td>
132 </tr> 248 </tr>
133 <tr> 249 <tr>
250 <td><a href="#BugBearVisitor.visit_ListComp">visit_ListComp</a></td>
251 <td>Public method to handle list comprehensions.</td>
252 </tr>
253 <tr>
254 <td><a href="#BugBearVisitor.visit_Raise">visit_Raise</a></td>
255 <td>Public method to handle 'raise' statements.</td>
256 </tr>
257 <tr>
258 <td><a href="#BugBearVisitor.visit_SetComp">visit_SetComp</a></td>
259 <td>Public method to handle set comprehensions.</td>
260 </tr>
261 <tr>
262 <td><a href="#BugBearVisitor.visit_Try">visit_Try</a></td>
263 <td>Public method to handle 'try' statements'.</td>
264 </tr>
265 <tr>
134 <td><a href="#BugBearVisitor.visit_UAdd">visit_UAdd</a></td> 266 <td><a href="#BugBearVisitor.visit_UAdd">visit_UAdd</a></td>
135 <td>Public method to handle unary additions.</td> 267 <td>Public method to handle unary additions.</td>
268 </tr>
269 <tr>
270 <td><a href="#BugBearVisitor.visit_While">visit_While</a></td>
271 <td>Public method to handle 'while' statements.</td>
272 </tr>
273 <tr>
274 <td><a href="#BugBearVisitor.visit_With">visit_With</a></td>
275 <td>Public method to handle 'with' statements.</td>
136 </tr> 276 </tr>
137 </table> 277 </table>
138 <h3>Static Methods</h3> 278 <h3>Static Methods</h3>
139 279
140 <table> 280 <table>
146 <b>BugBearVisitor</b>(<i></i>) 286 <b>BugBearVisitor</b>(<i></i>)
147 287
148 <p> 288 <p>
149 Constructor 289 Constructor
150 </p> 290 </p>
151 <a NAME="BugBearVisitor.__checkForM502" ID="BugBearVisitor.__checkForM502"></a> 291 <a NAME="BugBearVisitor.__checkForM505" ID="BugBearVisitor.__checkForM505"></a>
152 <h4>BugBearVisitor.__checkForM502</h4> 292 <h4>BugBearVisitor.__checkForM505</h4>
153 <b>__checkForM502</b>(<i>node</i>) 293 <b>__checkForM505</b>(<i>node</i>)
154 294
155 <p> 295 <p>
156 Private method to check the use of *strip(). 296 Private method to check the use of *strip().
157 </p> 297 </p>
158 <dl> 298 <dl>
169 <p> 309 <p>
170 Private method to check for unused loop variables. 310 Private method to check for unused loop variables.
171 </p> 311 </p>
172 <dl> 312 <dl>
173 313
174 <dt><i>node</i> (ast.For)</dt> 314 <dt><i>node</i> (ast.For or ast.AsyncFor)</dt>
175 <dd> 315 <dd>
176 reference to the node to be processed 316 reference to the node to be processed
317 </dd>
318 </dl>
319 <a NAME="BugBearVisitor.__checkForM512" ID="BugBearVisitor.__checkForM512"></a>
320 <h4>BugBearVisitor.__checkForM512</h4>
321 <b>__checkForM512</b>(<i>node</i>)
322
323 <p>
324 Private method to check for return/continue/break inside finally blocks.
325 </p>
326 <dl>
327
328 <dt><i>node</i> (ast.Try)</dt>
329 <dd>
330 reference to the node to be processed
331 </dd>
332 </dl>
333 <a NAME="BugBearVisitor.__checkForM515" ID="BugBearVisitor.__checkForM515"></a>
334 <h4>BugBearVisitor.__checkForM515</h4>
335 <b>__checkForM515</b>(<i>node</i>)
336
337 <p>
338 Private method to check for pointless comparisons.
339 </p>
340 <dl>
341
342 <dt><i>node</i> (ast.Compare)</dt>
343 <dd>
344 reference to the node to be processed
345 </dd>
346 </dl>
347 <a NAME="BugBearVisitor.__checkForM516" ID="BugBearVisitor.__checkForM516"></a>
348 <h4>BugBearVisitor.__checkForM516</h4>
349 <b>__checkForM516</b>(<i>node</i>)
350
351 <p>
352 Private method to check for raising a literal instead of an exception.
353 </p>
354 <dl>
355
356 <dt><i>node</i> (ast.Raise)</dt>
357 <dd>
358 reference to the node to be processed
359 </dd>
360 </dl>
361 <a NAME="BugBearVisitor.__checkForM517" ID="BugBearVisitor.__checkForM517"></a>
362 <h4>BugBearVisitor.__checkForM517</h4>
363 <b>__checkForM517</b>(<i>node</i>)
364
365 <p>
366 Private method to check for use of the evil syntax
367 'with assertRaises(Exception):.
368 </p>
369 <dl>
370
371 <dt><i>node</i> (ast.With)</dt>
372 <dd>
373 reference to the node to be processed
374 </dd>
375 </dl>
376 <a NAME="BugBearVisitor.__checkForM518" ID="BugBearVisitor.__checkForM518"></a>
377 <h4>BugBearVisitor.__checkForM518</h4>
378 <b>__checkForM518</b>(<i>node</i>)
379
380 <p>
381 Private method to check for useless expressions.
382 </p>
383 <dl>
384
385 <dt><i>node</i> (ast.FunctionDef)</dt>
386 <dd>
387 reference to the node to be processed
388 </dd>
389 </dl>
390 <a NAME="BugBearVisitor.__checkForM519" ID="BugBearVisitor.__checkForM519"></a>
391 <h4>BugBearVisitor.__checkForM519</h4>
392 <b>__checkForM519</b>(<i>node</i>)
393
394 <p>
395 Private method to check for use of 'functools.lru_cache' or 'functools.cache'.
396 </p>
397 <dl>
398
399 <dt><i>node</i> (ast.FunctionDef)</dt>
400 <dd>
401 reference to the node to be processed
402 </dd>
403 </dl>
404 <a NAME="BugBearVisitor.__checkForM520" ID="BugBearVisitor.__checkForM520"></a>
405 <h4>BugBearVisitor.__checkForM520</h4>
406 <b>__checkForM520</b>(<i>node</i>)
407
408 <p>
409 Private method to check for a loop that modifies its iterable.
410 </p>
411 <dl>
412
413 <dt><i>node</i> (ast.For or ast.AsyncFor)</dt>
414 <dd>
415 reference to the node to be processed
416 </dd>
417 </dl>
418 <a NAME="BugBearVisitor.__checkForM521" ID="BugBearVisitor.__checkForM521"></a>
419 <h4>BugBearVisitor.__checkForM521</h4>
420 <b>__checkForM521</b>(<i>node</i>)
421
422 <p>
423 Private method to check for use of an f-string as docstring.
424 </p>
425 <dl>
426
427 <dt><i>node</i> (ast.FunctionDef or ast.ClassDef)</dt>
428 <dd>
429 reference to the node to be processed
430 </dd>
431 </dl>
432 <a NAME="BugBearVisitor.__checkForM522" ID="BugBearVisitor.__checkForM522"></a>
433 <h4>BugBearVisitor.__checkForM522</h4>
434 <b>__checkForM522</b>(<i>node</i>)
435
436 <p>
437 Private method to check for use of an f-string as docstring.
438 </p>
439 <dl>
440
441 <dt><i>node</i> (ast.With)</dt>
442 <dd>
443 reference to the node to be processed
444 </dd>
445 </dl>
446 <a NAME="BugBearVisitor.__checkForM523" ID="BugBearVisitor.__checkForM523"></a>
447 <h4>BugBearVisitor.__checkForM523</h4>
448 <b>__checkForM523</b>(<i>loopNode</i>)
449
450 <p>
451 Private method to check that functions (including lambdas) do not use loop
452 variables.
453 </p>
454 <dl>
455
456 <dt><i>loopNode</i> (ast.For, ast.AsyncFor, ast.While, ast.ListComp, ast.SetComp,ast.DictComp,)</dt>
457 <dd>
458 reference to the node to be processed
459 or ast.GeneratorExp
460 </dd>
461 </dl>
462 <a NAME="BugBearVisitor.__checkForM524" ID="BugBearVisitor.__checkForM524"></a>
463 <h4>BugBearVisitor.__checkForM524</h4>
464 <b>__checkForM524</b>(<i>node</i>)
465
466 <p>
467 Private method to check for inheritance from abstract classes in abc and lack of
468 any methods decorated with abstract*.
469 </p>
470 <dl>
471
472 <dt><i>node</i> (ast.ClassDef)</dt>
473 <dd>
474 reference to the node to be processed
475 </dd>
476 </dl>
477 <a NAME="BugBearVisitor.__checkForM525" ID="BugBearVisitor.__checkForM525"></a>
478 <h4>BugBearVisitor.__checkForM525</h4>
479 <b>__checkForM525</b>(<i>node</i>)
480
481 <p>
482 Private method to check for exceptions being handled multiple times.
483 </p>
484 <dl>
485
486 <dt><i>node</i> (ast.Try)</dt>
487 <dd>
488 reference to the node to be processed
489 </dd>
490 </dl>
491 <a NAME="BugBearVisitor.__childrenInScope" ID="BugBearVisitor.__childrenInScope"></a>
492 <h4>BugBearVisitor.__childrenInScope</h4>
493 <b>__childrenInScope</b>(<i>node</i>)
494
495 <p>
496 Private method to get all child nodes in the given scope.
497 </p>
498 <dl>
499
500 <dt><i>node</i> (ast.Node)</dt>
501 <dd>
502 reference to the node to be processed
503 </dd>
504 </dl>
505 <dl>
506 <dt>Yield:</dt>
507 <dd>
508 reference to a child node
509 </dd>
510 </dl>
511 <dl>
512 <dt>Yield Type:</dt>
513 <dd>
514 ast.Node
515 </dd>
516 </dl>
517 <a NAME="BugBearVisitor.__composeCallPath" ID="BugBearVisitor.__composeCallPath"></a>
518 <h4>BugBearVisitor.__composeCallPath</h4>
519 <b>__composeCallPath</b>(<i>node</i>)
520
521 <p>
522 Private method get the individual elements of the call path of a node.
523 </p>
524 <dl>
525
526 <dt><i>node</i> (ast.Node)</dt>
527 <dd>
528 reference to the node
529 </dd>
530 </dl>
531 <dl>
532 <dt>Yield:</dt>
533 <dd>
534 one element of the call path
535 </dd>
536 </dl>
537 <dl>
538 <dt>Yield Type:</dt>
539 <dd>
540 ast.Node
541 </dd>
542 </dl>
543 <a NAME="BugBearVisitor.__getAssignedNames" ID="BugBearVisitor.__getAssignedNames"></a>
544 <h4>BugBearVisitor.__getAssignedNames</h4>
545 <b>__getAssignedNames</b>(<i>loopNode</i>)
546
547 <p>
548 Private method to get the names of a for loop.
549 </p>
550 <dl>
551
552 <dt><i>loopNode</i> (ast.For)</dt>
553 <dd>
554 reference to the node to be processed
555 </dd>
556 </dl>
557 <dl>
558 <dt>Yield:</dt>
559 <dd>
560 DESCRIPTION
561 </dd>
562 </dl>
563 <dl>
564 <dt>Yield Type:</dt>
565 <dd>
566 TYPE
567 </dd>
568 </dl>
569 <a NAME="BugBearVisitor.__isIdentifier" ID="BugBearVisitor.__isIdentifier"></a>
570 <h4>BugBearVisitor.__isIdentifier</h4>
571 <b>__isIdentifier</b>(<i>arg</i>)
572
573 <p>
574 Private method to check if arg is a valid identifier.
575 </p>
576 <p>
577 See https://docs.python.org/2/reference/lexical_analysis.html#identifiers
578 </p>
579 <dl>
580
581 <dt><i>arg</i> (ast.Node)</dt>
582 <dd>
583 reference to an argument node
584 </dd>
585 </dl>
586 <dl>
587 <dt>Return:</dt>
588 <dd>
589 flag indicating a valid identifier
590 </dd>
591 </dl>
592 <dl>
593 <dt>Return Type:</dt>
594 <dd>
595 TYPE
596 </dd>
597 </dl>
598 <a NAME="BugBearVisitor.__namesFromAssignments" ID="BugBearVisitor.__namesFromAssignments"></a>
599 <h4>BugBearVisitor.__namesFromAssignments</h4>
600 <b>__namesFromAssignments</b>(<i>assignTarget</i>)
601
602 <p>
603 Private method to get names of an assignment.
604 </p>
605 <dl>
606
607 <dt><i>assignTarget</i> (ast.Node)</dt>
608 <dd>
609 reference to the node to be processed
610 </dd>
611 </dl>
612 <dl>
613 <dt>Yield:</dt>
614 <dd>
615 name of the assignment
616 </dd>
617 </dl>
618 <dl>
619 <dt>Yield Type:</dt>
620 <dd>
621 str
622 </dd>
623 </dl>
624 <a NAME="BugBearVisitor.__toNameStr" ID="BugBearVisitor.__toNameStr"></a>
625 <h4>BugBearVisitor.__toNameStr</h4>
626 <b>__toNameStr</b>(<i>node</i>)
627
628 <p>
629 Private method to turn Name and Attribute nodes to strings, handling any
630 depth of attribute accesses.
631 </p>
632 <p>
633
634 </p>
635 <dl>
636
637 <dt><i>node</i> (ast.Name or ast.Attribute)</dt>
638 <dd>
639 reference to the node
640 </dd>
641 </dl>
642 <dl>
643 <dt>Return:</dt>
644 <dd>
645 string representation
646 </dd>
647 </dl>
648 <dl>
649 <dt>Return Type:</dt>
650 <dd>
651 str
652 </dd>
653 </dl>
654 <a NAME="BugBearVisitor.__typesafeIssubclass" ID="BugBearVisitor.__typesafeIssubclass"></a>
655 <h4>BugBearVisitor.__typesafeIssubclass</h4>
656 <b>__typesafeIssubclass</b>(<i>obj, classOrTuple</i>)
657
658 <p>
659 Private method implementing a type safe issubclass() function.
660 </p>
661 <dl>
662
663 <dt><i>obj</i> (any)</dt>
664 <dd>
665 reference to the object to be tested
666 </dd>
667 <dt><i>classOrTuple</i> (type)</dt>
668 <dd>
669 type to check against
670 </dd>
671 </dl>
672 <dl>
673 <dt>Return:</dt>
674 <dd>
675 flag indicating a subclass
676 </dd>
677 </dl>
678 <dl>
679 <dt>Return Type:</dt>
680 <dd>
681 bool
682 </dd>
683 </dl>
684 <a NAME="BugBearVisitor._loop" ID="BugBearVisitor._loop"></a>
685 <h4>BugBearVisitor._loop</h4>
686 <b>_loop</b>(<i>badNodeTypes</i>)
687
688 <a NAME="BugBearVisitor.isAbcClass" ID="BugBearVisitor.isAbcClass"></a>
689 <h4>BugBearVisitor.isAbcClass</h4>
690 <b>isAbcClass</b>(<i></i>)
691
692 <a NAME="BugBearVisitor.isAbstractDecorator" ID="BugBearVisitor.isAbstractDecorator"></a>
693 <h4>BugBearVisitor.isAbstractDecorator</h4>
694 <b>isAbstractDecorator</b>(<i></i>)
695
696 <a NAME="BugBearVisitor.nodeStack" ID="BugBearVisitor.nodeStack"></a>
697 <h4>BugBearVisitor.nodeStack</h4>
698 <b>nodeStack</b>(<i></i>)
699
700 <p>
701 Public method to get a reference to the most recent node stack.
702 </p>
703 <dl>
704 <dt>Return:</dt>
705 <dd>
706 reference to the most recent node stack
707 </dd>
708 </dl>
709 <dl>
710 <dt>Return Type:</dt>
711 <dd>
712 list
177 </dd> 713 </dd>
178 </dl> 714 </dl>
179 <a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a> 715 <a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a>
180 <h4>BugBearVisitor.visit</h4> 716 <h4>BugBearVisitor.visit</h4>
181 <b>visit</b>(<i>node</i>) 717 <b>visit</b>(<i>node</i>)
230 <dt><i>node</i> (ast.AsyncFor)</dt> 766 <dt><i>node</i> (ast.AsyncFor)</dt>
231 <dd> 767 <dd>
232 reference to the node to be processed 768 reference to the node to be processed
233 </dd> 769 </dd>
234 </dl> 770 </dl>
235 <a NAME="BugBearVisitor.visit_Attribute" ID="BugBearVisitor.visit_Attribute"></a>
236 <h4>BugBearVisitor.visit_Attribute</h4>
237 <b>visit_Attribute</b>(<i>node</i>)
238
239 <p>
240 Public method to handle attributes.
241 </p>
242 <dl>
243
244 <dt><i>node</i> (ast.Attribute)</dt>
245 <dd>
246 reference to the node to be processed
247 </dd>
248 </dl>
249 <a NAME="BugBearVisitor.visit_Call" ID="BugBearVisitor.visit_Call"></a> 771 <a NAME="BugBearVisitor.visit_Call" ID="BugBearVisitor.visit_Call"></a>
250 <h4>BugBearVisitor.visit_Call</h4> 772 <h4>BugBearVisitor.visit_Call</h4>
251 <b>visit_Call</b>(<i>node</i>) 773 <b>visit_Call</b>(<i>node</i>)
252 774
253 <p> 775 <p>
258 <dt><i>node</i> (ast.Call)</dt> 780 <dt><i>node</i> (ast.Call)</dt>
259 <dd> 781 <dd>
260 reference to the node to be processed 782 reference to the node to be processed
261 </dd> 783 </dd>
262 </dl> 784 </dl>
785 <a NAME="BugBearVisitor.visit_ClassDef" ID="BugBearVisitor.visit_ClassDef"></a>
786 <h4>BugBearVisitor.visit_ClassDef</h4>
787 <b>visit_ClassDef</b>(<i>node</i>)
788
789 <p>
790 Public method to handle class definitions.
791 </p>
792 <dl>
793
794 <dt><i>node</i> (ast.ClassDef)</dt>
795 <dd>
796 reference to the node to be processed
797 </dd>
798 </dl>
799 <a NAME="BugBearVisitor.visit_Compare" ID="BugBearVisitor.visit_Compare"></a>
800 <h4>BugBearVisitor.visit_Compare</h4>
801 <b>visit_Compare</b>(<i>node</i>)
802
803 <p>
804 Public method to handle comparison statements.
805 </p>
806 <dl>
807
808 <dt><i>node</i> (ast.Compare)</dt>
809 <dd>
810 reference to the node to be processed
811 </dd>
812 </dl>
813 <a NAME="BugBearVisitor.visit_DictComp" ID="BugBearVisitor.visit_DictComp"></a>
814 <h4>BugBearVisitor.visit_DictComp</h4>
815 <b>visit_DictComp</b>(<i>node</i>)
816
817 <p>
818 Public method to handle dictionary comprehensions.
819 </p>
820 <dl>
821
822 <dt><i>node</i> (ast.DictComp)</dt>
823 <dd>
824 reference to the node to be processed
825 </dd>
826 </dl>
827 <a NAME="BugBearVisitor.visit_ExceptHandler" ID="BugBearVisitor.visit_ExceptHandler"></a>
828 <h4>BugBearVisitor.visit_ExceptHandler</h4>
829 <b>visit_ExceptHandler</b>(<i>node</i>)
830
831 <p>
832 Public method to handle exception handlers.
833 </p>
834 <dl>
835
836 <dt><i>node</i> (ast.ExceptHandler)</dt>
837 <dd>
838 reference to the node to be processed
839 </dd>
840 </dl>
263 <a NAME="BugBearVisitor.visit_For" ID="BugBearVisitor.visit_For"></a> 841 <a NAME="BugBearVisitor.visit_For" ID="BugBearVisitor.visit_For"></a>
264 <h4>BugBearVisitor.visit_For</h4> 842 <h4>BugBearVisitor.visit_For</h4>
265 <b>visit_For</b>(<i>node</i>) 843 <b>visit_For</b>(<i>node</i>)
266 844
267 <p> 845 <p>
272 <dt><i>node</i> (ast.For)</dt> 850 <dt><i>node</i> (ast.For)</dt>
273 <dd> 851 <dd>
274 reference to the node to be processed 852 reference to the node to be processed
275 </dd> 853 </dd>
276 </dl> 854 </dl>
855 <a NAME="BugBearVisitor.visit_FunctionDef" ID="BugBearVisitor.visit_FunctionDef"></a>
856 <h4>BugBearVisitor.visit_FunctionDef</h4>
857 <b>visit_FunctionDef</b>(<i>node</i>)
858
859 <p>
860 Public method to handle function definitions.
861 </p>
862 <dl>
863
864 <dt><i>node</i> (ast.FunctionDef)</dt>
865 <dd>
866 reference to the node to be processed
867 </dd>
868 </dl>
869 <a NAME="BugBearVisitor.visit_GeneratorExp" ID="BugBearVisitor.visit_GeneratorExp"></a>
870 <h4>BugBearVisitor.visit_GeneratorExp</h4>
871 <b>visit_GeneratorExp</b>(<i>node</i>)
872
873 <p>
874 Public method to handle generator expressions.
875 </p>
876 <dl>
877
878 <dt><i>node</i> (ast.GeneratorExp)</dt>
879 <dd>
880 reference to the node to be processed
881 </dd>
882 </dl>
277 <a NAME="BugBearVisitor.visit_JoinedStr" ID="BugBearVisitor.visit_JoinedStr"></a> 883 <a NAME="BugBearVisitor.visit_JoinedStr" ID="BugBearVisitor.visit_JoinedStr"></a>
278 <h4>BugBearVisitor.visit_JoinedStr</h4> 884 <h4>BugBearVisitor.visit_JoinedStr</h4>
279 <b>visit_JoinedStr</b>(<i>node</i>) 885 <b>visit_JoinedStr</b>(<i>node</i>)
280 886
281 <p> 887 <p>
286 <dt><i>node</i> (ast.JoinedStr)</dt> 892 <dt><i>node</i> (ast.JoinedStr)</dt>
287 <dd> 893 <dd>
288 reference to the node to be processed 894 reference to the node to be processed
289 </dd> 895 </dd>
290 </dl> 896 </dl>
897 <a NAME="BugBearVisitor.visit_ListComp" ID="BugBearVisitor.visit_ListComp"></a>
898 <h4>BugBearVisitor.visit_ListComp</h4>
899 <b>visit_ListComp</b>(<i>node</i>)
900
901 <p>
902 Public method to handle list comprehensions.
903 </p>
904 <dl>
905
906 <dt><i>node</i> (ast.ListComp)</dt>
907 <dd>
908 reference to the node to be processed
909 </dd>
910 </dl>
911 <a NAME="BugBearVisitor.visit_Raise" ID="BugBearVisitor.visit_Raise"></a>
912 <h4>BugBearVisitor.visit_Raise</h4>
913 <b>visit_Raise</b>(<i>node</i>)
914
915 <p>
916 Public method to handle 'raise' statements.
917 </p>
918 <dl>
919
920 <dt><i>node</i> (ast.Raise)</dt>
921 <dd>
922 reference to the node to be processed
923 </dd>
924 </dl>
925 <a NAME="BugBearVisitor.visit_SetComp" ID="BugBearVisitor.visit_SetComp"></a>
926 <h4>BugBearVisitor.visit_SetComp</h4>
927 <b>visit_SetComp</b>(<i>node</i>)
928
929 <p>
930 Public method to handle set comprehensions.
931 </p>
932 <dl>
933
934 <dt><i>node</i> (ast.SetComp)</dt>
935 <dd>
936 reference to the node to be processed
937 </dd>
938 </dl>
939 <a NAME="BugBearVisitor.visit_Try" ID="BugBearVisitor.visit_Try"></a>
940 <h4>BugBearVisitor.visit_Try</h4>
941 <b>visit_Try</b>(<i>node</i>)
942
943 <p>
944 Public method to handle 'try' statements'.
945 </p>
946 <dl>
947
948 <dt><i>node</i> (ast.Try)</dt>
949 <dd>
950 reference to the node to be processed
951 </dd>
952 </dl>
291 <a NAME="BugBearVisitor.visit_UAdd" ID="BugBearVisitor.visit_UAdd"></a> 953 <a NAME="BugBearVisitor.visit_UAdd" ID="BugBearVisitor.visit_UAdd"></a>
292 <h4>BugBearVisitor.visit_UAdd</h4> 954 <h4>BugBearVisitor.visit_UAdd</h4>
293 <b>visit_UAdd</b>(<i>node</i>) 955 <b>visit_UAdd</b>(<i>node</i>)
294 956
295 <p> 957 <p>
296 Public method to handle unary additions. 958 Public method to handle unary additions.
297 </p> 959 </p>
298 <dl> 960 <dl>
299 961
300 <dt><i>node</i> (ast.UAdd)</dt> 962 <dt><i>node</i> (ast.UAdd)</dt>
963 <dd>
964 reference to the node to be processed
965 </dd>
966 </dl>
967 <a NAME="BugBearVisitor.visit_While" ID="BugBearVisitor.visit_While"></a>
968 <h4>BugBearVisitor.visit_While</h4>
969 <b>visit_While</b>(<i>node</i>)
970
971 <p>
972 Public method to handle 'while' statements.
973 </p>
974 <dl>
975
976 <dt><i>node</i> (ast.While)</dt>
977 <dd>
978 reference to the node to be processed
979 </dd>
980 </dl>
981 <a NAME="BugBearVisitor.visit_With" ID="BugBearVisitor.visit_With"></a>
982 <h4>BugBearVisitor.visit_With</h4>
983 <b>visit_With</b>(<i>node</i>)
984
985 <p>
986 Public method to handle 'with' statements.
987 </p>
988 <dl>
989
990 <dt><i>node</i> (ast.With)</dt>
301 <dd> 991 <dd>
302 reference to the node to be processed 992 reference to the node to be processed
303 </dd> 993 </dd>
304 </dl> 994 </dl>
305 <div align="right"><a href="#top">Up</a></div> 995 <div align="right"><a href="#top">Up</a></div>
643 </dd> 1333 </dd>
644 </dl> 1334 </dl>
645 <div align="right"><a href="#top">Up</a></div> 1335 <div align="right"><a href="#top">Up</a></div>
646 <hr /> 1336 <hr />
647 <hr /> 1337 <hr />
1338 <a NAME="M520NameFinder" ID="M520NameFinder"></a>
1339 <h2>M520NameFinder</h2>
1340
1341 <p>
1342 Class to extract a name out of a tree of nodes ignoring names defined within the
1343 local scope of a comprehension.
1344 </p>
1345 <h3>Derived from</h3>
1346 NameFinder
1347 <h3>Class Attributes</h3>
1348
1349 <table>
1350 <tr><td>None</td></tr>
1351 </table>
1352 <h3>Class Methods</h3>
1353
1354 <table>
1355 <tr><td>None</td></tr>
1356 </table>
1357 <h3>Methods</h3>
1358
1359 <table>
1360
1361 <tr>
1362 <td><a href="#M520NameFinder.visit_DictComp">visit_DictComp</a></td>
1363 <td>Public method to handle a dictionary comprehension.</td>
1364 </tr>
1365 <tr>
1366 <td><a href="#M520NameFinder.visit_GeneratorExp">visit_GeneratorExp</a></td>
1367 <td>Public method to handle a generator expressions.</td>
1368 </tr>
1369 <tr>
1370 <td><a href="#M520NameFinder.visit_Lambda">visit_Lambda</a></td>
1371 <td>Public method to handle a Lambda function.</td>
1372 </tr>
1373 <tr>
1374 <td><a href="#M520NameFinder.visit_ListComp">visit_ListComp</a></td>
1375 <td>Public method to handle a list comprehension.</td>
1376 </tr>
1377 <tr>
1378 <td><a href="#M520NameFinder.visit_comprehension">visit_comprehension</a></td>
1379 <td>Public method to handle the 'for' of a comprehension.</td>
1380 </tr>
1381 </table>
1382 <h3>Static Methods</h3>
1383
1384 <table>
1385 <tr><td>None</td></tr>
1386 </table>
1387
1388 <a NAME="M520NameFinder.visit_DictComp" ID="M520NameFinder.visit_DictComp"></a>
1389 <h4>M520NameFinder.visit_DictComp</h4>
1390 <b>visit_DictComp</b>(<i>node</i>)
1391
1392 <p>
1393 Public method to handle a dictionary comprehension.
1394 </p>
1395 <dl>
1396
1397 <dt><i>node</i> (TYPE)</dt>
1398 <dd>
1399 reference to the node to be processed
1400 </dd>
1401 </dl>
1402 <a NAME="M520NameFinder.visit_GeneratorExp" ID="M520NameFinder.visit_GeneratorExp"></a>
1403 <h4>M520NameFinder.visit_GeneratorExp</h4>
1404 <b>visit_GeneratorExp</b>(<i>node</i>)
1405
1406 <p>
1407 Public method to handle a generator expressions.
1408 </p>
1409 <dl>
1410
1411 <dt><i>node</i> (ast.GeneratorExp)</dt>
1412 <dd>
1413 reference to the node to be processed
1414 </dd>
1415 </dl>
1416 <a NAME="M520NameFinder.visit_Lambda" ID="M520NameFinder.visit_Lambda"></a>
1417 <h4>M520NameFinder.visit_Lambda</h4>
1418 <b>visit_Lambda</b>(<i>node</i>)
1419
1420 <p>
1421 Public method to handle a Lambda function.
1422 </p>
1423 <dl>
1424
1425 <dt><i>node</i> (ast.Lambda)</dt>
1426 <dd>
1427 reference to the node to be processed
1428 </dd>
1429 </dl>
1430 <a NAME="M520NameFinder.visit_ListComp" ID="M520NameFinder.visit_ListComp"></a>
1431 <h4>M520NameFinder.visit_ListComp</h4>
1432 <b>visit_ListComp</b>(<i>node</i>)
1433
1434 <p>
1435 Public method to handle a list comprehension.
1436 </p>
1437 <dl>
1438
1439 <dt><i>node</i> (TYPE)</dt>
1440 <dd>
1441 reference to the node to be processed
1442 </dd>
1443 </dl>
1444 <a NAME="M520NameFinder.visit_comprehension" ID="M520NameFinder.visit_comprehension"></a>
1445 <h4>M520NameFinder.visit_comprehension</h4>
1446 <b>visit_comprehension</b>(<i>node</i>)
1447
1448 <p>
1449 Public method to handle the 'for' of a comprehension.
1450 </p>
1451 <dl>
1452
1453 <dt><i>node</i> (ast.comprehension)</dt>
1454 <dd>
1455 reference to the node to be processed
1456 </dd>
1457 </dl>
1458 <div align="right"><a href="#top">Up</a></div>
1459 <hr />
1460 <hr />
648 <a NAME="MiscellaneousChecker" ID="MiscellaneousChecker"></a> 1461 <a NAME="MiscellaneousChecker" ID="MiscellaneousChecker"></a>
649 <h2>MiscellaneousChecker</h2> 1462 <h2>MiscellaneousChecker</h2>
650 1463
651 <p> 1464 <p>
652 Class implementing a checker for miscellaneous checks. 1465 Class implementing a checker for miscellaneous checks.
1170 <dl> 1983 <dl>
1171 1984
1172 <dt><i>node</i> (ast.Node)</dt> 1985 <dt><i>node</i> (ast.Node)</dt>
1173 <dd> 1986 <dd>
1174 AST node to be traversed 1987 AST node to be traversed
1988 </dd>
1989 </dl>
1990 <dl>
1991 <dt>Return:</dt>
1992 <dd>
1993 reference to the last processed node
1994 </dd>
1995 </dl>
1996 <dl>
1997 <dt>Return Type:</dt>
1998 <dd>
1999 ast.Node
1175 </dd> 2000 </dd>
1176 </dl> 2001 </dl>
1177 <a NAME="NameFinder.visit_Name" ID="NameFinder.visit_Name"></a> 2002 <a NAME="NameFinder.visit_Name" ID="NameFinder.visit_Name"></a>
1178 <h4>NameFinder.visit_Name</h4> 2003 <h4>NameFinder.visit_Name</h4>
1179 <b>visit_Name</b>(<i>node</i>) 2004 <b>visit_Name</b>(<i>node</i>)

eric ide

mercurial