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

branch
eric7
changeset 11150
73d80859079c
equal deleted inserted replaced
11149:fc45672fae42 11150:73d80859079c
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.BugBearVisitor</title>
4 <meta charset="UTF-8">
5 <link rel="stylesheet" href="styles.css">
6 </head>
7 <body>
8 <a NAME="top" ID="top"></a>
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.BugBearVisitor</h1>
10 <p>
11 Module implementing a visitor to check for various potential issues.
12 </p>
13
14 <h3>Global Attributes</h3>
15 <table>
16 <tr><td>BugBearContext</td></tr>
17 <tr><td>BugbearImmutableCalls</td></tr>
18 <tr><td>BugbearMutableCalls</td></tr>
19 <tr><td>BugbearMutableComprehensions</td></tr>
20 <tr><td>BugbearMutableLiterals</td></tr>
21 </table>
22
23 <h3>Classes</h3>
24 <table>
25 <tr>
26 <td><a href="#BugBearVisitor">BugBearVisitor</a></td>
27 <td>Class implementing a node visitor to check for various topics.</td>
28 </tr>
29 <tr>
30 <td><a href="#ExceptBaseExceptionVisitor">ExceptBaseExceptionVisitor</a></td>
31 <td>Class to determine, if a 'BaseException' is re-raised.</td>
32 </tr>
33 <tr>
34 <td><a href="#FunctionDefDefaultsVisitor">FunctionDefDefaultsVisitor</a></td>
35 <td>Class used by M506, M508 and M539.</td>
36 </tr>
37 <tr>
38 <td><a href="#M520NameFinder">M520NameFinder</a></td>
39 <td>Class to extract a name out of a tree of nodes ignoring names defined within the local scope of a comprehension.</td>
40 </tr>
41 <tr>
42 <td><a href="#M540CaughtException">M540CaughtException</a></td>
43 <td>Class to hold the data for a caught exception.</td>
44 </tr>
45 <tr>
46 <td><a href="#M541UnhandledKeyType">M541UnhandledKeyType</a></td>
47 <td>Class to hold a dictionary key of a type that we do not check for duplicates.</td>
48 </tr>
49 <tr>
50 <td><a href="#M541VariableKeyType">M541VariableKeyType</a></td>
51 <td>Class to hold the name of a variable key type.</td>
52 </tr>
53 <tr>
54 <td><a href="#M569Checker">M569Checker</a></td>
55 <td>Class traversing a 'for' loop body to check for modifications to a loop's mutable iterable.</td>
56 </tr>
57 <tr>
58 <td><a href="#NameFinder">NameFinder</a></td>
59 <td>Class to extract a name out of a tree of nodes.</td>
60 </tr>
61 <tr>
62 <td><a href="#NamedExprFinder">NamedExprFinder</a></td>
63 <td>Class to extract names defined through an ast.NamedExpr.</td>
64 </tr>
65 </table>
66
67 <h3>Functions</h3>
68 <table>
69 <tr>
70 <td><a href="#composeCallPath">composeCallPath</a></td>
71 <td>Generator function to assemble the call path of a given node.</td>
72 </tr>
73 </table>
74
75 <hr />
76 <hr />
77 <a NAME="BugBearVisitor" ID="BugBearVisitor"></a>
78 <h2>BugBearVisitor</h2>
79 <p>
80 Class implementing a node visitor to check for various topics.
81 </p>
82
83 <h3>Derived from</h3>
84 ast.NodeVisitor
85 <h3>Class Attributes</h3>
86 <table>
87 <tr><td>CONTEXTFUL_NODES</td></tr>
88 <tr><td>FUNCTION_NODES</td></tr>
89 <tr><td>NodeWindowSize</td></tr>
90 </table>
91
92 <h3>Class Methods</h3>
93 <table>
94 <tr><td>None</td></tr>
95 </table>
96
97 <h3>Methods</h3>
98 <table>
99 <tr>
100 <td><a href="#BugBearVisitor.__init__">BugBearVisitor</a></td>
101 <td>Constructor</td>
102 </tr>
103 <tr>
104 <td><a href="#BugBearVisitor.__checkForM505">__checkForM505</a></td>
105 <td>Private method to check the use of *strip().</td>
106 </tr>
107 <tr>
108 <td><a href="#BugBearVisitor.__checkForM506_M508">__checkForM506_M508</a></td>
109 <td>Private method to check the use of mutable literals, comprehensions and calls.</td>
110 </tr>
111 <tr>
112 <td><a href="#BugBearVisitor.__checkForM507">__checkForM507</a></td>
113 <td>Private method to check for unused loop variables.</td>
114 </tr>
115 <tr>
116 <td><a href="#BugBearVisitor.__checkForM512">__checkForM512</a></td>
117 <td>Private method to check for return/continue/break inside finally blocks.</td>
118 </tr>
119 <tr>
120 <td><a href="#BugBearVisitor.__checkForM513_M514_M529_M530">__checkForM513_M514_M529_M530</a></td>
121 <td>Private method to check various exception handler situations.</td>
122 </tr>
123 <tr>
124 <td><a href="#BugBearVisitor.__checkForM515">__checkForM515</a></td>
125 <td>Private method to check for pointless comparisons.</td>
126 </tr>
127 <tr>
128 <td><a href="#BugBearVisitor.__checkForM516">__checkForM516</a></td>
129 <td>Private method to check for raising a literal instead of an exception.</td>
130 </tr>
131 <tr>
132 <td><a href="#BugBearVisitor.__checkForM517">__checkForM517</a></td>
133 <td>Private method to check for use of the evil syntax 'with assertRaises(Exception): or 'with pytest.raises(Exception):'.</td>
134 </tr>
135 <tr>
136 <td><a href="#BugBearVisitor.__checkForM518">__checkForM518</a></td>
137 <td>Private method to check for useless expressions.</td>
138 </tr>
139 <tr>
140 <td><a href="#BugBearVisitor.__checkForM519">__checkForM519</a></td>
141 <td>Private method to check for use of 'functools.lru_cache' or 'functools.cache'.</td>
142 </tr>
143 <tr>
144 <td><a href="#BugBearVisitor.__checkForM520">__checkForM520</a></td>
145 <td>Private method to check for a loop that modifies its iterable.</td>
146 </tr>
147 <tr>
148 <td><a href="#BugBearVisitor.__checkForM521">__checkForM521</a></td>
149 <td>Private method to check for use of an f-string as docstring.</td>
150 </tr>
151 <tr>
152 <td><a href="#BugBearVisitor.__checkForM522">__checkForM522</a></td>
153 <td>Private method to check for use of an f-string as docstring.</td>
154 </tr>
155 <tr>
156 <td><a href="#BugBearVisitor.__checkForM523">__checkForM523</a></td>
157 <td>Private method to check that functions (including lambdas) do not use loop variables.</td>
158 </tr>
159 <tr>
160 <td><a href="#BugBearVisitor.__checkForM524_M527">__checkForM524_M527</a></td>
161 <td>Private method to check for inheritance from abstract classes in abc and lack of any methods decorated with abstract*.</td>
162 </tr>
163 <tr>
164 <td><a href="#BugBearVisitor.__checkForM525">__checkForM525</a></td>
165 <td>Private method to check for exceptions being handled multiple times.</td>
166 </tr>
167 <tr>
168 <td><a href="#BugBearVisitor.__checkForM526">__checkForM526</a></td>
169 <td>Private method to check for Star-arg unpacking after keyword argument.</td>
170 </tr>
171 <tr>
172 <td><a href="#BugBearVisitor.__checkForM528">__checkForM528</a></td>
173 <td>Private method to check for warn without stacklevel.</td>
174 </tr>
175 <tr>
176 <td><a href="#BugBearVisitor.__checkForM531">__checkForM531</a></td>
177 <td>Private method to check that 'itertools.groupby' isn't iterated over more than once.</td>
178 </tr>
179 <tr>
180 <td><a href="#BugBearVisitor.__checkForM532">__checkForM532</a></td>
181 <td>Private method to check for possible unintentional typing annotation.</td>
182 </tr>
183 <tr>
184 <td><a href="#BugBearVisitor.__checkForM533">__checkForM533</a></td>
185 <td>Private method to check a set for duplicate items.</td>
186 </tr>
187 <tr>
188 <td><a href="#BugBearVisitor.__checkForM534">__checkForM534</a></td>
189 <td>Private method to check that re.sub/subn/split arguments flags/count/maxsplit are passed as keyword arguments.</td>
190 </tr>
191 <tr>
192 <td><a href="#BugBearVisitor.__checkForM535">__checkForM535</a></td>
193 <td>Private method to check that a static key isn't used in a dict comprehension.</td>
194 </tr>
195 <tr>
196 <td><a href="#BugBearVisitor.__checkForM539">__checkForM539</a></td>
197 <td>Private method to check for correct ContextVar usage.</td>
198 </tr>
199 <tr>
200 <td><a href="#BugBearVisitor.__checkForM540AddNote">__checkForM540AddNote</a></td>
201 <td>Private method to check add_note usage.</td>
202 </tr>
203 <tr>
204 <td><a href="#BugBearVisitor.__checkForM540Usage">__checkForM540Usage</a></td>
205 <td>Private method to check the usage of exceptions with added note.</td>
206 </tr>
207 <tr>
208 <td><a href="#BugBearVisitor.__checkForM541">__checkForM541</a></td>
209 <td>Private method to check for duplicate key value pairs in a dictionary literal.</td>
210 </tr>
211 <tr>
212 <td><a href="#BugBearVisitor.__checkForM569">__checkForM569</a></td>
213 <td>Private method to check for changes to a loop's mutable iterable.</td>
214 </tr>
215 <tr>
216 <td><a href="#BugBearVisitor.__checkRedundantExcepthandlers">__checkRedundantExcepthandlers</a></td>
217 <td>Private method to check for redundant exception types in an exception handler.</td>
218 </tr>
219 <tr>
220 <td><a href="#BugBearVisitor.__childrenInScope">__childrenInScope</a></td>
221 <td>Private method to get all child nodes in the given scope.</td>
222 </tr>
223 <tr>
224 <td><a href="#BugBearVisitor.__flattenExcepthandler">__flattenExcepthandler</a></td>
225 <td>Private method to flatten the list of exceptions handled by an except handler.</td>
226 </tr>
227 <tr>
228 <td><a href="#BugBearVisitor.__getAssignedNames">__getAssignedNames</a></td>
229 <td>Private method to get the names of a for loop.</td>
230 </tr>
231 <tr>
232 <td><a href="#BugBearVisitor.__getDictCompLoopAndNamedExprVarNames">__getDictCompLoopAndNamedExprVarNames</a></td>
233 <td>Private method to get the names of comprehension loop variables.</td>
234 </tr>
235 <tr>
236 <td><a href="#BugBearVisitor.__getNamesFromTuple">__getNamesFromTuple</a></td>
237 <td>Private method to get the names from an ast.Tuple node.</td>
238 </tr>
239 <tr>
240 <td><a href="#BugBearVisitor.__inClassInit">__inClassInit</a></td>
241 <td>Private method to check, if we are inside an '__init__' method.</td>
242 </tr>
243 <tr>
244 <td><a href="#BugBearVisitor.__isIdentifier">__isIdentifier</a></td>
245 <td>Private method to check if arg is a valid identifier.</td>
246 </tr>
247 <tr>
248 <td><a href="#BugBearVisitor.__namesFromAssignments">__namesFromAssignments</a></td>
249 <td>Private method to get names of an assignment.</td>
250 </tr>
251 <tr>
252 <td><a href="#BugBearVisitor.__typesafeIssubclass">__typesafeIssubclass</a></td>
253 <td>Private method implementing a type safe issubclass() function.</td>
254 </tr>
255 <tr>
256 <td><a href="#BugBearVisitor.__walkList">__walkList</a></td>
257 <td>Private method to walk a given list of nodes.</td>
258 </tr>
259 <tr>
260 <td><a href="#BugBearVisitor._loop">_loop</a></td>
261 <td></td>
262 </tr>
263 <tr>
264 <td><a href="#BugBearVisitor.check">check</a></td>
265 <td></td>
266 </tr>
267 <tr>
268 <td><a href="#BugBearVisitor.convertToValue">convertToValue</a></td>
269 <td>Function to extract the value of a given item.</td>
270 </tr>
271 <tr>
272 <td><a href="#BugBearVisitor.emptyBody">emptyBody</a></td>
273 <td></td>
274 </tr>
275 <tr>
276 <td><a href="#BugBearVisitor.isAbcClass">isAbcClass</a></td>
277 <td></td>
278 </tr>
279 <tr>
280 <td><a href="#BugBearVisitor.isAbstractDecorator">isAbstractDecorator</a></td>
281 <td></td>
282 </tr>
283 <tr>
284 <td><a href="#BugBearVisitor.isOverload">isOverload</a></td>
285 <td></td>
286 </tr>
287 <tr>
288 <td><a href="#BugBearVisitor.isStrOrEllipsis">isStrOrEllipsis</a></td>
289 <td></td>
290 </tr>
291 <tr>
292 <td><a href="#BugBearVisitor.nodeStack">nodeStack</a></td>
293 <td>Public method to get a reference to the most recent node stack.</td>
294 </tr>
295 <tr>
296 <td><a href="#BugBearVisitor.superwalk">superwalk</a></td>
297 <td>Function to walk an AST node or a list of AST nodes.</td>
298 </tr>
299 <tr>
300 <td><a href="#BugBearVisitor.toNameStr">toNameStr</a></td>
301 <td>Public method to turn Name and Attribute nodes to strings, handling any depth of attribute accesses.</td>
302 </tr>
303 <tr>
304 <td><a href="#BugBearVisitor.visit">visit</a></td>
305 <td>Public method to traverse a given AST node.</td>
306 </tr>
307 <tr>
308 <td><a href="#BugBearVisitor.visit_AnnAssign">visit_AnnAssign</a></td>
309 <td>Public method to check annotated assign statements.</td>
310 </tr>
311 <tr>
312 <td><a href="#BugBearVisitor.visit_Assert">visit_Assert</a></td>
313 <td>Public method to handle 'assert' statements.</td>
314 </tr>
315 <tr>
316 <td><a href="#BugBearVisitor.visit_Assign">visit_Assign</a></td>
317 <td>Public method to handle assignments.</td>
318 </tr>
319 <tr>
320 <td><a href="#BugBearVisitor.visit_AsyncFor">visit_AsyncFor</a></td>
321 <td>Public method to handle 'for' statements.</td>
322 </tr>
323 <tr>
324 <td><a href="#BugBearVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
325 <td>Public method to handle async function definitions.</td>
326 </tr>
327 <tr>
328 <td><a href="#BugBearVisitor.visit_Call">visit_Call</a></td>
329 <td>Public method to handle a function call.</td>
330 </tr>
331 <tr>
332 <td><a href="#BugBearVisitor.visit_ClassDef">visit_ClassDef</a></td>
333 <td>Public method to handle class definitions.</td>
334 </tr>
335 <tr>
336 <td><a href="#BugBearVisitor.visit_Compare">visit_Compare</a></td>
337 <td>Public method to handle comparison statements.</td>
338 </tr>
339 <tr>
340 <td><a href="#BugBearVisitor.visit_Dict">visit_Dict</a></td>
341 <td>Public method to check a dictionary.</td>
342 </tr>
343 <tr>
344 <td><a href="#BugBearVisitor.visit_DictComp">visit_DictComp</a></td>
345 <td>Public method to handle dictionary comprehensions.</td>
346 </tr>
347 <tr>
348 <td><a href="#BugBearVisitor.visit_ExceptHandler">visit_ExceptHandler</a></td>
349 <td>Public method to handle exception handlers.</td>
350 </tr>
351 <tr>
352 <td><a href="#BugBearVisitor.visit_For">visit_For</a></td>
353 <td>Public method to handle 'for' statements.</td>
354 </tr>
355 <tr>
356 <td><a href="#BugBearVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
357 <td>Public method to handle function definitions.</td>
358 </tr>
359 <tr>
360 <td><a href="#BugBearVisitor.visit_GeneratorExp">visit_GeneratorExp</a></td>
361 <td>Public method to handle generator expressions.</td>
362 </tr>
363 <tr>
364 <td><a href="#BugBearVisitor.visit_Import">visit_Import</a></td>
365 <td>Public method to check imports.</td>
366 </tr>
367 <tr>
368 <td><a href="#BugBearVisitor.visit_ImportFrom">visit_ImportFrom</a></td>
369 <td>Public method to check from imports.</td>
370 </tr>
371 <tr>
372 <td><a href="#BugBearVisitor.visit_JoinedStr">visit_JoinedStr</a></td>
373 <td>Public method to handle f-string arguments.</td>
374 </tr>
375 <tr>
376 <td><a href="#BugBearVisitor.visit_ListComp">visit_ListComp</a></td>
377 <td>Public method to handle list comprehensions.</td>
378 </tr>
379 <tr>
380 <td><a href="#BugBearVisitor.visit_Module">visit_Module</a></td>
381 <td>Public method to handle a module node.</td>
382 </tr>
383 <tr>
384 <td><a href="#BugBearVisitor.visit_Raise">visit_Raise</a></td>
385 <td>Public method to handle 'raise' statements.</td>
386 </tr>
387 <tr>
388 <td><a href="#BugBearVisitor.visit_Return">visit_Return</a></td>
389 <td>Public method to handle 'Return' nodes.</td>
390 </tr>
391 <tr>
392 <td><a href="#BugBearVisitor.visit_Set">visit_Set</a></td>
393 <td>Public method to check a set.</td>
394 </tr>
395 <tr>
396 <td><a href="#BugBearVisitor.visit_SetComp">visit_SetComp</a></td>
397 <td>Public method to handle set comprehensions.</td>
398 </tr>
399 <tr>
400 <td><a href="#BugBearVisitor.visit_Try">visit_Try</a></td>
401 <td>Public method to handle 'try' statements.</td>
402 </tr>
403 <tr>
404 <td><a href="#BugBearVisitor.visit_TryStar">visit_TryStar</a></td>
405 <td>Public method to handle 'except*' statements.</td>
406 </tr>
407 <tr>
408 <td><a href="#BugBearVisitor.visit_UAdd">visit_UAdd</a></td>
409 <td>Public method to handle unary additions.</td>
410 </tr>
411 <tr>
412 <td><a href="#BugBearVisitor.visit_While">visit_While</a></td>
413 <td>Public method to handle 'while' statements.</td>
414 </tr>
415 <tr>
416 <td><a href="#BugBearVisitor.visit_With">visit_With</a></td>
417 <td>Public method to handle 'with' statements.</td>
418 </tr>
419 <tr>
420 <td><a href="#BugBearVisitor.visit_Yield">visit_Yield</a></td>
421 <td>Public method to handle 'Yield' nodes.</td>
422 </tr>
423 <tr>
424 <td><a href="#BugBearVisitor.visit_YieldFrom">visit_YieldFrom</a></td>
425 <td>Public method to handle 'YieldFrom' nodes.</td>
426 </tr>
427 </table>
428
429 <h3>Static Methods</h3>
430 <table>
431 <tr><td>None</td></tr>
432 </table>
433
434
435 <a NAME="BugBearVisitor.__init__" ID="BugBearVisitor.__init__"></a>
436 <h4>BugBearVisitor (Constructor)</h4>
437 <b>BugBearVisitor</b>(<i></i>)
438 <p>
439 Constructor
440 </p>
441
442 <a NAME="BugBearVisitor.__checkForM505" ID="BugBearVisitor.__checkForM505"></a>
443 <h4>BugBearVisitor.__checkForM505</h4>
444 <b>__checkForM505</b>(<i>node</i>)
445 <p>
446 Private method to check the use of *strip().
447 </p>
448
449 <dl>
450
451 <dt><i>node</i> (ast.Call)</dt>
452 <dd>
453 reference to the node to be processed
454 </dd>
455 </dl>
456 <a NAME="BugBearVisitor.__checkForM506_M508" ID="BugBearVisitor.__checkForM506_M508"></a>
457 <h4>BugBearVisitor.__checkForM506_M508</h4>
458 <b>__checkForM506_M508</b>(<i>node</i>)
459 <p>
460 Private method to check the use of mutable literals, comprehensions and calls.
461 </p>
462
463 <dl>
464
465 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
466 <dd>
467 reference to the node to be processed
468 </dd>
469 </dl>
470 <a NAME="BugBearVisitor.__checkForM507" ID="BugBearVisitor.__checkForM507"></a>
471 <h4>BugBearVisitor.__checkForM507</h4>
472 <b>__checkForM507</b>(<i>node</i>)
473 <p>
474 Private method to check for unused loop variables.
475 </p>
476
477 <dl>
478
479 <dt><i>node</i> (ast.For or ast.AsyncFor)</dt>
480 <dd>
481 reference to the node to be processed
482 </dd>
483 </dl>
484 <a NAME="BugBearVisitor.__checkForM512" ID="BugBearVisitor.__checkForM512"></a>
485 <h4>BugBearVisitor.__checkForM512</h4>
486 <b>__checkForM512</b>(<i>node</i>)
487 <p>
488 Private method to check for return/continue/break inside finally blocks.
489 </p>
490
491 <dl>
492
493 <dt><i>node</i> (ast.Try)</dt>
494 <dd>
495 reference to the node to be processed
496 </dd>
497 </dl>
498 <a NAME="BugBearVisitor.__checkForM513_M514_M529_M530" ID="BugBearVisitor.__checkForM513_M514_M529_M530"></a>
499 <h4>BugBearVisitor.__checkForM513_M514_M529_M530</h4>
500 <b>__checkForM513_M514_M529_M530</b>(<i>node</i>)
501 <p>
502 Private method to check various exception handler situations.
503 </p>
504
505 <dl>
506
507 <dt><i>node</i> (ast.ExceptHandler)</dt>
508 <dd>
509 reference to the node to be processed
510 </dd>
511 </dl>
512 <dl>
513 <dt>Return:</dt>
514 <dd>
515 list of exception handler names
516 </dd>
517 </dl>
518 <dl>
519 <dt>Return Type:</dt>
520 <dd>
521 list of str
522 </dd>
523 </dl>
524 <a NAME="BugBearVisitor.__checkForM515" ID="BugBearVisitor.__checkForM515"></a>
525 <h4>BugBearVisitor.__checkForM515</h4>
526 <b>__checkForM515</b>(<i>node</i>)
527 <p>
528 Private method to check for pointless comparisons.
529 </p>
530
531 <dl>
532
533 <dt><i>node</i> (ast.Compare)</dt>
534 <dd>
535 reference to the node to be processed
536 </dd>
537 </dl>
538 <a NAME="BugBearVisitor.__checkForM516" ID="BugBearVisitor.__checkForM516"></a>
539 <h4>BugBearVisitor.__checkForM516</h4>
540 <b>__checkForM516</b>(<i>node</i>)
541 <p>
542 Private method to check for raising a literal instead of an exception.
543 </p>
544
545 <dl>
546
547 <dt><i>node</i> (ast.Raise)</dt>
548 <dd>
549 reference to the node to be processed
550 </dd>
551 </dl>
552 <a NAME="BugBearVisitor.__checkForM517" ID="BugBearVisitor.__checkForM517"></a>
553 <h4>BugBearVisitor.__checkForM517</h4>
554 <b>__checkForM517</b>(<i>node</i>)
555 <p>
556 Private method to check for use of the evil syntax
557 'with assertRaises(Exception): or 'with pytest.raises(Exception):'.
558 </p>
559
560 <dl>
561
562 <dt><i>node</i> (ast.With)</dt>
563 <dd>
564 reference to the node to be processed
565 </dd>
566 </dl>
567 <a NAME="BugBearVisitor.__checkForM518" ID="BugBearVisitor.__checkForM518"></a>
568 <h4>BugBearVisitor.__checkForM518</h4>
569 <b>__checkForM518</b>(<i>node</i>)
570 <p>
571 Private method to check for useless expressions.
572 </p>
573
574 <dl>
575
576 <dt><i>node</i> (ast.FunctionDef)</dt>
577 <dd>
578 reference to the node to be processed
579 </dd>
580 </dl>
581 <a NAME="BugBearVisitor.__checkForM519" ID="BugBearVisitor.__checkForM519"></a>
582 <h4>BugBearVisitor.__checkForM519</h4>
583 <b>__checkForM519</b>(<i>node</i>)
584 <p>
585 Private method to check for use of 'functools.lru_cache' or 'functools.cache'.
586 </p>
587
588 <dl>
589
590 <dt><i>node</i> (ast.FunctionDef)</dt>
591 <dd>
592 reference to the node to be processed
593 </dd>
594 </dl>
595 <a NAME="BugBearVisitor.__checkForM520" ID="BugBearVisitor.__checkForM520"></a>
596 <h4>BugBearVisitor.__checkForM520</h4>
597 <b>__checkForM520</b>(<i>node</i>)
598 <p>
599 Private method to check for a loop that modifies its iterable.
600 </p>
601
602 <dl>
603
604 <dt><i>node</i> (ast.For or ast.AsyncFor)</dt>
605 <dd>
606 reference to the node to be processed
607 </dd>
608 </dl>
609 <a NAME="BugBearVisitor.__checkForM521" ID="BugBearVisitor.__checkForM521"></a>
610 <h4>BugBearVisitor.__checkForM521</h4>
611 <b>__checkForM521</b>(<i>node</i>)
612 <p>
613 Private method to check for use of an f-string as docstring.
614 </p>
615
616 <dl>
617
618 <dt><i>node</i> (ast.FunctionDef or ast.ClassDef)</dt>
619 <dd>
620 reference to the node to be processed
621 </dd>
622 </dl>
623 <a NAME="BugBearVisitor.__checkForM522" ID="BugBearVisitor.__checkForM522"></a>
624 <h4>BugBearVisitor.__checkForM522</h4>
625 <b>__checkForM522</b>(<i>node</i>)
626 <p>
627 Private method to check for use of an f-string as docstring.
628 </p>
629
630 <dl>
631
632 <dt><i>node</i> (ast.With)</dt>
633 <dd>
634 reference to the node to be processed
635 </dd>
636 </dl>
637 <a NAME="BugBearVisitor.__checkForM523" ID="BugBearVisitor.__checkForM523"></a>
638 <h4>BugBearVisitor.__checkForM523</h4>
639 <b>__checkForM523</b>(<i>loopNode</i>)
640 <p>
641 Private method to check that functions (including lambdas) do not use loop
642 variables.
643 </p>
644
645 <dl>
646
647 <dt><i>loopNode</i> (ast.For, ast.AsyncFor, ast.While, ast.ListComp, ast.SetComp,ast.DictComp,)</dt>
648 <dd>
649 reference to the node to be processed
650 or ast.GeneratorExp
651 </dd>
652 </dl>
653 <a NAME="BugBearVisitor.__checkForM524_M527" ID="BugBearVisitor.__checkForM524_M527"></a>
654 <h4>BugBearVisitor.__checkForM524_M527</h4>
655 <b>__checkForM524_M527</b>(<i>node</i>)
656 <p>
657 Private method to check for inheritance from abstract classes in abc and lack of
658 any methods decorated with abstract*.
659 </p>
660
661 <dl>
662
663 <dt><i>node</i> (ast.ClassDef)</dt>
664 <dd>
665 reference to the node to be processed
666 </dd>
667 </dl>
668 <a NAME="BugBearVisitor.__checkForM525" ID="BugBearVisitor.__checkForM525"></a>
669 <h4>BugBearVisitor.__checkForM525</h4>
670 <b>__checkForM525</b>(<i>node</i>)
671 <p>
672 Private method to check for exceptions being handled multiple times.
673 </p>
674
675 <dl>
676
677 <dt><i>node</i> (ast.Try)</dt>
678 <dd>
679 reference to the node to be processed
680 </dd>
681 </dl>
682 <a NAME="BugBearVisitor.__checkForM526" ID="BugBearVisitor.__checkForM526"></a>
683 <h4>BugBearVisitor.__checkForM526</h4>
684 <b>__checkForM526</b>(<i>node</i>)
685 <p>
686 Private method to check for Star-arg unpacking after keyword argument.
687 </p>
688
689 <dl>
690
691 <dt><i>node</i> (ast.Call)</dt>
692 <dd>
693 reference to the node to be processed
694 </dd>
695 </dl>
696 <a NAME="BugBearVisitor.__checkForM528" ID="BugBearVisitor.__checkForM528"></a>
697 <h4>BugBearVisitor.__checkForM528</h4>
698 <b>__checkForM528</b>(<i>node</i>)
699 <p>
700 Private method to check for warn without stacklevel.
701 </p>
702
703 <dl>
704
705 <dt><i>node</i> (ast.Call)</dt>
706 <dd>
707 reference to the node to be processed
708 </dd>
709 </dl>
710 <a NAME="BugBearVisitor.__checkForM531" ID="BugBearVisitor.__checkForM531"></a>
711 <h4>BugBearVisitor.__checkForM531</h4>
712 <b>__checkForM531</b>(<i>loopNode</i>)
713 <p>
714 Private method to check that 'itertools.groupby' isn't iterated over more than
715 once.
716 </p>
717 <p>
718 A warning is emitted when the generator returned by 'groupby()' is used
719 more than once inside a loop body or when it's used in a nested loop.
720 </p>
721
722 <dl>
723
724 <dt><i>loopNode</i> (ast.For or ast.AsyncFor)</dt>
725 <dd>
726 reference to the node to be processed
727 </dd>
728 </dl>
729 <a NAME="BugBearVisitor.__checkForM532" ID="BugBearVisitor.__checkForM532"></a>
730 <h4>BugBearVisitor.__checkForM532</h4>
731 <b>__checkForM532</b>(<i>node</i>)
732 <p>
733 Private method to check for possible unintentional typing annotation.
734 </p>
735
736 <dl>
737
738 <dt><i>node</i> (ast.AnnAssign)</dt>
739 <dd>
740 reference to the node to be processed
741 </dd>
742 </dl>
743 <a NAME="BugBearVisitor.__checkForM533" ID="BugBearVisitor.__checkForM533"></a>
744 <h4>BugBearVisitor.__checkForM533</h4>
745 <b>__checkForM533</b>(<i>node</i>)
746 <p>
747 Private method to check a set for duplicate items.
748 </p>
749
750 <dl>
751
752 <dt><i>node</i> (ast.Set)</dt>
753 <dd>
754 reference to the node to be processed
755 </dd>
756 </dl>
757 <a NAME="BugBearVisitor.__checkForM534" ID="BugBearVisitor.__checkForM534"></a>
758 <h4>BugBearVisitor.__checkForM534</h4>
759 <b>__checkForM534</b>(<i>node</i>)
760 <p>
761 Private method to check that re.sub/subn/split arguments flags/count/maxsplit
762 are passed as keyword arguments.
763 </p>
764
765 <dl>
766
767 <dt><i>node</i> (ast.Call)</dt>
768 <dd>
769 reference to the node to be processed
770 </dd>
771 </dl>
772 <a NAME="BugBearVisitor.__checkForM535" ID="BugBearVisitor.__checkForM535"></a>
773 <h4>BugBearVisitor.__checkForM535</h4>
774 <b>__checkForM535</b>(<i>node</i>)
775 <p>
776 Private method to check that a static key isn't used in a dict comprehension.
777 </p>
778 <p>
779 Record a warning if a likely unchanging key is used - either a constant,
780 or a variable that isn't coming from the generator expression.
781 </p>
782
783 <dl>
784
785 <dt><i>node</i> (ast.DictComp)</dt>
786 <dd>
787 reference to the node to be processed
788 </dd>
789 </dl>
790 <a NAME="BugBearVisitor.__checkForM539" ID="BugBearVisitor.__checkForM539"></a>
791 <h4>BugBearVisitor.__checkForM539</h4>
792 <b>__checkForM539</b>(<i>node</i>)
793 <p>
794 Private method to check for correct ContextVar usage.
795 </p>
796
797 <dl>
798
799 <dt><i>node</i> (ast.Call)</dt>
800 <dd>
801 reference to the node to be processed
802 </dd>
803 </dl>
804 <a NAME="BugBearVisitor.__checkForM540AddNote" ID="BugBearVisitor.__checkForM540AddNote"></a>
805 <h4>BugBearVisitor.__checkForM540AddNote</h4>
806 <b>__checkForM540AddNote</b>(<i>node</i>)
807 <p>
808 Private method to check add_note usage.
809 </p>
810
811 <dl>
812
813 <dt><i>node</i> (ast.Attribute)</dt>
814 <dd>
815 reference to the node to be processed
816 </dd>
817 </dl>
818 <dl>
819 <dt>Return:</dt>
820 <dd>
821 flag
822 </dd>
823 </dl>
824 <dl>
825 <dt>Return Type:</dt>
826 <dd>
827 bool
828 </dd>
829 </dl>
830 <a NAME="BugBearVisitor.__checkForM540Usage" ID="BugBearVisitor.__checkForM540Usage"></a>
831 <h4>BugBearVisitor.__checkForM540Usage</h4>
832 <b>__checkForM540Usage</b>(<i>node</i>)
833 <p>
834 Private method to check the usage of exceptions with added note.
835 </p>
836
837 <dl>
838
839 <dt><i>node</i> (ast.expr or None)</dt>
840 <dd>
841 reference to the node to be processed
842 </dd>
843 </dl>
844 <a NAME="BugBearVisitor.__checkForM541" ID="BugBearVisitor.__checkForM541"></a>
845 <h4>BugBearVisitor.__checkForM541</h4>
846 <b>__checkForM541</b>(<i>node</i>)
847 <p>
848 Private method to check for duplicate key value pairs in a dictionary literal.
849 </p>
850
851 <dl>
852
853 <dt><i>node</i> (ast.Dict)</dt>
854 <dd>
855 reference to the node to be processed
856 </dd>
857 </dl>
858 <a NAME="BugBearVisitor.__checkForM569" ID="BugBearVisitor.__checkForM569"></a>
859 <h4>BugBearVisitor.__checkForM569</h4>
860 <b>__checkForM569</b>(<i>node</i>)
861 <p>
862 Private method to check for changes to a loop's mutable iterable.
863 </p>
864
865 <dl>
866
867 <dt><i>node</i> (ast.For)</dt>
868 <dd>
869 loop node to be checked
870 </dd>
871 </dl>
872 <a NAME="BugBearVisitor.__checkRedundantExcepthandlers" ID="BugBearVisitor.__checkRedundantExcepthandlers"></a>
873 <h4>BugBearVisitor.__checkRedundantExcepthandlers</h4>
874 <b>__checkRedundantExcepthandlers</b>(<i>names, node, inTryStar</i>)
875 <p>
876 Private method to check for redundant exception types in an exception handler.
877 </p>
878
879 <dl>
880
881 <dt><i>names</i> (list of ast.Name)</dt>
882 <dd>
883 list of exception types to be checked
884 </dd>
885 <dt><i>node</i> (ast.ExceptionHandler)</dt>
886 <dd>
887 reference to the exception handler node
888 </dd>
889 <dt><i>inTryStar</i> (str)</dt>
890 <dd>
891 character indicating an 'except*' handler
892 </dd>
893 </dl>
894 <dl>
895 <dt>Return:</dt>
896 <dd>
897 tuple containing the error data
898 </dd>
899 </dl>
900 <dl>
901 <dt>Return Type:</dt>
902 <dd>
903 tuple of (ast.Node, str, str, str, str)
904 </dd>
905 </dl>
906 <a NAME="BugBearVisitor.__childrenInScope" ID="BugBearVisitor.__childrenInScope"></a>
907 <h4>BugBearVisitor.__childrenInScope</h4>
908 <b>__childrenInScope</b>(<i>node</i>)
909 <p>
910 Private method to get all child nodes in the given scope.
911 </p>
912
913 <dl>
914
915 <dt><i>node</i> (ast.Node)</dt>
916 <dd>
917 reference to the node to be processed
918 </dd>
919 </dl>
920 <dl>
921 <dt>Yield:</dt>
922 <dd>
923 reference to a child node
924 </dd>
925 </dl>
926 <dl>
927 <dt>Yield Type:</dt>
928 <dd>
929 ast.Node
930 </dd>
931 </dl>
932 <a NAME="BugBearVisitor.__flattenExcepthandler" ID="BugBearVisitor.__flattenExcepthandler"></a>
933 <h4>BugBearVisitor.__flattenExcepthandler</h4>
934 <b>__flattenExcepthandler</b>(<i>node</i>)
935 <p>
936 Private method to flatten the list of exceptions handled by an except handler.
937 </p>
938
939 <dl>
940
941 <dt><i>node</i> (ast.Node)</dt>
942 <dd>
943 reference to the node to be processed
944 </dd>
945 </dl>
946 <dl>
947 <dt>Yield:</dt>
948 <dd>
949 reference to the exception type node
950 </dd>
951 </dl>
952 <dl>
953 <dt>Yield Type:</dt>
954 <dd>
955 ast.Node
956 </dd>
957 </dl>
958 <a NAME="BugBearVisitor.__getAssignedNames" ID="BugBearVisitor.__getAssignedNames"></a>
959 <h4>BugBearVisitor.__getAssignedNames</h4>
960 <b>__getAssignedNames</b>(<i>loopNode</i>)
961 <p>
962 Private method to get the names of a for loop.
963 </p>
964
965 <dl>
966
967 <dt><i>loopNode</i> (ast.For)</dt>
968 <dd>
969 reference to the node to be processed
970 </dd>
971 </dl>
972 <dl>
973 <dt>Yield:</dt>
974 <dd>
975 DESCRIPTION
976 </dd>
977 </dl>
978 <dl>
979 <dt>Yield Type:</dt>
980 <dd>
981 TYPE
982 </dd>
983 </dl>
984 <a NAME="BugBearVisitor.__getDictCompLoopAndNamedExprVarNames" ID="BugBearVisitor.__getDictCompLoopAndNamedExprVarNames"></a>
985 <h4>BugBearVisitor.__getDictCompLoopAndNamedExprVarNames</h4>
986 <b>__getDictCompLoopAndNamedExprVarNames</b>(<i>node</i>)
987 <p>
988 Private method to get the names of comprehension loop variables.
989 </p>
990
991 <dl>
992
993 <dt><i>node</i> (ast.DictComp)</dt>
994 <dd>
995 ast node to be processed
996 </dd>
997 </dl>
998 <dl>
999 <dt>Yield:</dt>
1000 <dd>
1001 loop variable names
1002 </dd>
1003 </dl>
1004 <dl>
1005 <dt>Yield Type:</dt>
1006 <dd>
1007 str
1008 </dd>
1009 </dl>
1010 <a NAME="BugBearVisitor.__getNamesFromTuple" ID="BugBearVisitor.__getNamesFromTuple"></a>
1011 <h4>BugBearVisitor.__getNamesFromTuple</h4>
1012 <b>__getNamesFromTuple</b>(<i>node</i>)
1013 <p>
1014 Private method to get the names from an ast.Tuple node.
1015 </p>
1016
1017 <dl>
1018
1019 <dt><i>node</i> (ast.Tuple)</dt>
1020 <dd>
1021 ast node to be processed
1022 </dd>
1023 </dl>
1024 <dl>
1025 <dt>Yield:</dt>
1026 <dd>
1027 names
1028 </dd>
1029 </dl>
1030 <dl>
1031 <dt>Yield Type:</dt>
1032 <dd>
1033 str
1034 </dd>
1035 </dl>
1036 <a NAME="BugBearVisitor.__inClassInit" ID="BugBearVisitor.__inClassInit"></a>
1037 <h4>BugBearVisitor.__inClassInit</h4>
1038 <b>__inClassInit</b>(<i></i>)
1039 <p>
1040 Private method to check, if we are inside an '__init__' method.
1041 </p>
1042
1043 <dl>
1044 <dt>Return:</dt>
1045 <dd>
1046 flag indicating being within the '__init__' method
1047 </dd>
1048 </dl>
1049 <dl>
1050 <dt>Return Type:</dt>
1051 <dd>
1052 bool
1053 </dd>
1054 </dl>
1055 <a NAME="BugBearVisitor.__isIdentifier" ID="BugBearVisitor.__isIdentifier"></a>
1056 <h4>BugBearVisitor.__isIdentifier</h4>
1057 <b>__isIdentifier</b>(<i>arg</i>)
1058 <p>
1059 Private method to check if arg is a valid identifier.
1060 </p>
1061 <p>
1062 See https://docs.python.org/2/reference/lexical_analysis.html#identifiers
1063 </p>
1064
1065 <dl>
1066
1067 <dt><i>arg</i> (ast.Node)</dt>
1068 <dd>
1069 reference to an argument node
1070 </dd>
1071 </dl>
1072 <dl>
1073 <dt>Return:</dt>
1074 <dd>
1075 flag indicating a valid identifier
1076 </dd>
1077 </dl>
1078 <dl>
1079 <dt>Return Type:</dt>
1080 <dd>
1081 TYPE
1082 </dd>
1083 </dl>
1084 <a NAME="BugBearVisitor.__namesFromAssignments" ID="BugBearVisitor.__namesFromAssignments"></a>
1085 <h4>BugBearVisitor.__namesFromAssignments</h4>
1086 <b>__namesFromAssignments</b>(<i>assignTarget</i>)
1087 <p>
1088 Private method to get names of an assignment.
1089 </p>
1090
1091 <dl>
1092
1093 <dt><i>assignTarget</i> (ast.Node)</dt>
1094 <dd>
1095 reference to the node to be processed
1096 </dd>
1097 </dl>
1098 <dl>
1099 <dt>Yield:</dt>
1100 <dd>
1101 name of the assignment
1102 </dd>
1103 </dl>
1104 <dl>
1105 <dt>Yield Type:</dt>
1106 <dd>
1107 str
1108 </dd>
1109 </dl>
1110 <a NAME="BugBearVisitor.__typesafeIssubclass" ID="BugBearVisitor.__typesafeIssubclass"></a>
1111 <h4>BugBearVisitor.__typesafeIssubclass</h4>
1112 <b>__typesafeIssubclass</b>(<i>obj, classOrTuple</i>)
1113 <p>
1114 Private method implementing a type safe issubclass() function.
1115 </p>
1116
1117 <dl>
1118
1119 <dt><i>obj</i> (Any)</dt>
1120 <dd>
1121 reference to the object to be tested
1122 </dd>
1123 <dt><i>classOrTuple</i> (type)</dt>
1124 <dd>
1125 type to check against
1126 </dd>
1127 </dl>
1128 <dl>
1129 <dt>Return:</dt>
1130 <dd>
1131 flag indicating a subclass
1132 </dd>
1133 </dl>
1134 <dl>
1135 <dt>Return Type:</dt>
1136 <dd>
1137 bool
1138 </dd>
1139 </dl>
1140 <a NAME="BugBearVisitor.__walkList" ID="BugBearVisitor.__walkList"></a>
1141 <h4>BugBearVisitor.__walkList</h4>
1142 <b>__walkList</b>(<i>nodes</i>)
1143 <p>
1144 Private method to walk a given list of nodes.
1145 </p>
1146
1147 <dl>
1148
1149 <dt><i>nodes</i> (list of ast.Node)</dt>
1150 <dd>
1151 list of nodes to walk
1152 </dd>
1153 </dl>
1154 <dl>
1155 <dt>Yield:</dt>
1156 <dd>
1157 node references as determined by the ast.walk() function
1158 </dd>
1159 </dl>
1160 <dl>
1161 <dt>Yield Type:</dt>
1162 <dd>
1163 ast.Node
1164 </dd>
1165 </dl>
1166 <a NAME="BugBearVisitor._loop" ID="BugBearVisitor._loop"></a>
1167 <h4>BugBearVisitor._loop</h4>
1168 <b>_loop</b>(<i>badNodeTypes</i>)
1169
1170 <a NAME="BugBearVisitor.check" ID="BugBearVisitor.check"></a>
1171 <h4>BugBearVisitor.check</h4>
1172 <b>check</b>(<i>paramName</i>)
1173
1174 <a NAME="BugBearVisitor.convertToValue" ID="BugBearVisitor.convertToValue"></a>
1175 <h4>BugBearVisitor.convertToValue</h4>
1176 <b>convertToValue</b>(<i></i>)
1177 <p>
1178 Function to extract the value of a given item.
1179 </p>
1180
1181 <dl>
1182
1183 <dt><i>item</i> (ast.Ast)</dt>
1184 <dd>
1185 node to extract value from
1186 </dd>
1187 </dl>
1188 <dl>
1189 <dt>Return:</dt>
1190 <dd>
1191 value of the node
1192 </dd>
1193 </dl>
1194 <dl>
1195 <dt>Return Type:</dt>
1196 <dd>
1197 Any
1198 </dd>
1199 </dl>
1200 <a NAME="BugBearVisitor.emptyBody" ID="BugBearVisitor.emptyBody"></a>
1201 <h4>BugBearVisitor.emptyBody</h4>
1202 <b>emptyBody</b>(<i></i>)
1203
1204 <a NAME="BugBearVisitor.isAbcClass" ID="BugBearVisitor.isAbcClass"></a>
1205 <h4>BugBearVisitor.isAbcClass</h4>
1206 <b>isAbcClass</b>(<i>name="ABC"</i>)
1207
1208 <a NAME="BugBearVisitor.isAbstractDecorator" ID="BugBearVisitor.isAbstractDecorator"></a>
1209 <h4>BugBearVisitor.isAbstractDecorator</h4>
1210 <b>isAbstractDecorator</b>(<i></i>)
1211
1212 <a NAME="BugBearVisitor.isOverload" ID="BugBearVisitor.isOverload"></a>
1213 <h4>BugBearVisitor.isOverload</h4>
1214 <b>isOverload</b>(<i></i>)
1215
1216 <a NAME="BugBearVisitor.isStrOrEllipsis" ID="BugBearVisitor.isStrOrEllipsis"></a>
1217 <h4>BugBearVisitor.isStrOrEllipsis</h4>
1218 <b>isStrOrEllipsis</b>(<i></i>)
1219
1220 <a NAME="BugBearVisitor.nodeStack" ID="BugBearVisitor.nodeStack"></a>
1221 <h4>BugBearVisitor.nodeStack</h4>
1222 <b>nodeStack</b>(<i></i>)
1223 <p>
1224 Public method to get a reference to the most recent node stack.
1225 </p>
1226
1227 <dl>
1228 <dt>Return:</dt>
1229 <dd>
1230 reference to the most recent node stack
1231 </dd>
1232 </dl>
1233 <dl>
1234 <dt>Return Type:</dt>
1235 <dd>
1236 list
1237 </dd>
1238 </dl>
1239 <a NAME="BugBearVisitor.superwalk" ID="BugBearVisitor.superwalk"></a>
1240 <h4>BugBearVisitor.superwalk</h4>
1241 <b>superwalk</b>(<i></i>)
1242 <p>
1243 Function to walk an AST node or a list of AST nodes.
1244 </p>
1245
1246 <dl>
1247
1248 <dt><i>node</i> (ast.AST or list[ast.AST])</dt>
1249 <dd>
1250 reference to the node or a list of nodes to be processed
1251 </dd>
1252 </dl>
1253 <dl>
1254 <dt>Yield:</dt>
1255 <dd>
1256 next node to be processed
1257 </dd>
1258 </dl>
1259 <dl>
1260 <dt>Yield Type:</dt>
1261 <dd>
1262 ast.AST
1263 </dd>
1264 </dl>
1265 <a NAME="BugBearVisitor.toNameStr" ID="BugBearVisitor.toNameStr"></a>
1266 <h4>BugBearVisitor.toNameStr</h4>
1267 <b>toNameStr</b>(<i>node</i>)
1268 <p>
1269 Public method to turn Name and Attribute nodes to strings, handling any
1270 depth of attribute accesses.
1271 </p>
1272 <p>
1273
1274 </p>
1275
1276 <dl>
1277
1278 <dt><i>node</i> (ast.Name or ast.Attribute)</dt>
1279 <dd>
1280 reference to the node
1281 </dd>
1282 </dl>
1283 <dl>
1284 <dt>Return:</dt>
1285 <dd>
1286 string representation
1287 </dd>
1288 </dl>
1289 <dl>
1290 <dt>Return Type:</dt>
1291 <dd>
1292 str
1293 </dd>
1294 </dl>
1295 <a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a>
1296 <h4>BugBearVisitor.visit</h4>
1297 <b>visit</b>(<i>node</i>)
1298 <p>
1299 Public method to traverse a given AST node.
1300 </p>
1301
1302 <dl>
1303
1304 <dt><i>node</i> (ast.Node)</dt>
1305 <dd>
1306 AST node to be traversed
1307 </dd>
1308 </dl>
1309 <a NAME="BugBearVisitor.visit_AnnAssign" ID="BugBearVisitor.visit_AnnAssign"></a>
1310 <h4>BugBearVisitor.visit_AnnAssign</h4>
1311 <b>visit_AnnAssign</b>(<i>node</i>)
1312 <p>
1313 Public method to check annotated assign statements.
1314 </p>
1315
1316 <dl>
1317
1318 <dt><i>node</i> (ast.AnnAssign)</dt>
1319 <dd>
1320 reference to the node to be processed
1321 </dd>
1322 </dl>
1323 <a NAME="BugBearVisitor.visit_Assert" ID="BugBearVisitor.visit_Assert"></a>
1324 <h4>BugBearVisitor.visit_Assert</h4>
1325 <b>visit_Assert</b>(<i>node</i>)
1326 <p>
1327 Public method to handle 'assert' statements.
1328 </p>
1329
1330 <dl>
1331
1332 <dt><i>node</i> (ast.Assert)</dt>
1333 <dd>
1334 reference to the node to be processed
1335 </dd>
1336 </dl>
1337 <a NAME="BugBearVisitor.visit_Assign" ID="BugBearVisitor.visit_Assign"></a>
1338 <h4>BugBearVisitor.visit_Assign</h4>
1339 <b>visit_Assign</b>(<i>node</i>)
1340 <p>
1341 Public method to handle assignments.
1342 </p>
1343
1344 <dl>
1345
1346 <dt><i>node</i> (ast.Assign)</dt>
1347 <dd>
1348 reference to the node to be processed
1349 </dd>
1350 </dl>
1351 <a NAME="BugBearVisitor.visit_AsyncFor" ID="BugBearVisitor.visit_AsyncFor"></a>
1352 <h4>BugBearVisitor.visit_AsyncFor</h4>
1353 <b>visit_AsyncFor</b>(<i>node</i>)
1354 <p>
1355 Public method to handle 'for' statements.
1356 </p>
1357
1358 <dl>
1359
1360 <dt><i>node</i> (ast.AsyncFor)</dt>
1361 <dd>
1362 reference to the node to be processed
1363 </dd>
1364 </dl>
1365 <a NAME="BugBearVisitor.visit_AsyncFunctionDef" ID="BugBearVisitor.visit_AsyncFunctionDef"></a>
1366 <h4>BugBearVisitor.visit_AsyncFunctionDef</h4>
1367 <b>visit_AsyncFunctionDef</b>(<i>node</i>)
1368 <p>
1369 Public method to handle async function definitions.
1370 </p>
1371
1372 <dl>
1373
1374 <dt><i>node</i> (ast.AsyncFunctionDef)</dt>
1375 <dd>
1376 reference to the node to be processed
1377 </dd>
1378 </dl>
1379 <a NAME="BugBearVisitor.visit_Call" ID="BugBearVisitor.visit_Call"></a>
1380 <h4>BugBearVisitor.visit_Call</h4>
1381 <b>visit_Call</b>(<i>node</i>)
1382 <p>
1383 Public method to handle a function call.
1384 </p>
1385
1386 <dl>
1387
1388 <dt><i>node</i> (ast.Call)</dt>
1389 <dd>
1390 reference to the node to be processed
1391 </dd>
1392 </dl>
1393 <a NAME="BugBearVisitor.visit_ClassDef" ID="BugBearVisitor.visit_ClassDef"></a>
1394 <h4>BugBearVisitor.visit_ClassDef</h4>
1395 <b>visit_ClassDef</b>(<i>node</i>)
1396 <p>
1397 Public method to handle class definitions.
1398 </p>
1399
1400 <dl>
1401
1402 <dt><i>node</i> (ast.ClassDef)</dt>
1403 <dd>
1404 reference to the node to be processed
1405 </dd>
1406 </dl>
1407 <a NAME="BugBearVisitor.visit_Compare" ID="BugBearVisitor.visit_Compare"></a>
1408 <h4>BugBearVisitor.visit_Compare</h4>
1409 <b>visit_Compare</b>(<i>node</i>)
1410 <p>
1411 Public method to handle comparison statements.
1412 </p>
1413
1414 <dl>
1415
1416 <dt><i>node</i> (ast.Compare)</dt>
1417 <dd>
1418 reference to the node to be processed
1419 </dd>
1420 </dl>
1421 <a NAME="BugBearVisitor.visit_Dict" ID="BugBearVisitor.visit_Dict"></a>
1422 <h4>BugBearVisitor.visit_Dict</h4>
1423 <b>visit_Dict</b>(<i>node</i>)
1424 <p>
1425 Public method to check a dictionary.
1426 </p>
1427
1428 <dl>
1429
1430 <dt><i>node</i> (ast.Dict)</dt>
1431 <dd>
1432 reference to the node to be processed
1433 </dd>
1434 </dl>
1435 <a NAME="BugBearVisitor.visit_DictComp" ID="BugBearVisitor.visit_DictComp"></a>
1436 <h4>BugBearVisitor.visit_DictComp</h4>
1437 <b>visit_DictComp</b>(<i>node</i>)
1438 <p>
1439 Public method to handle dictionary comprehensions.
1440 </p>
1441
1442 <dl>
1443
1444 <dt><i>node</i> (ast.DictComp)</dt>
1445 <dd>
1446 reference to the node to be processed
1447 </dd>
1448 </dl>
1449 <a NAME="BugBearVisitor.visit_ExceptHandler" ID="BugBearVisitor.visit_ExceptHandler"></a>
1450 <h4>BugBearVisitor.visit_ExceptHandler</h4>
1451 <b>visit_ExceptHandler</b>(<i>node</i>)
1452 <p>
1453 Public method to handle exception handlers.
1454 </p>
1455
1456 <dl>
1457
1458 <dt><i>node</i> (ast.ExceptHandler)</dt>
1459 <dd>
1460 reference to the node to be processed
1461 </dd>
1462 </dl>
1463 <a NAME="BugBearVisitor.visit_For" ID="BugBearVisitor.visit_For"></a>
1464 <h4>BugBearVisitor.visit_For</h4>
1465 <b>visit_For</b>(<i>node</i>)
1466 <p>
1467 Public method to handle 'for' statements.
1468 </p>
1469
1470 <dl>
1471
1472 <dt><i>node</i> (ast.For)</dt>
1473 <dd>
1474 reference to the node to be processed
1475 </dd>
1476 </dl>
1477 <a NAME="BugBearVisitor.visit_FunctionDef" ID="BugBearVisitor.visit_FunctionDef"></a>
1478 <h4>BugBearVisitor.visit_FunctionDef</h4>
1479 <b>visit_FunctionDef</b>(<i>node</i>)
1480 <p>
1481 Public method to handle function definitions.
1482 </p>
1483
1484 <dl>
1485
1486 <dt><i>node</i> (ast.FunctionDef)</dt>
1487 <dd>
1488 reference to the node to be processed
1489 </dd>
1490 </dl>
1491 <a NAME="BugBearVisitor.visit_GeneratorExp" ID="BugBearVisitor.visit_GeneratorExp"></a>
1492 <h4>BugBearVisitor.visit_GeneratorExp</h4>
1493 <b>visit_GeneratorExp</b>(<i>node</i>)
1494 <p>
1495 Public method to handle generator expressions.
1496 </p>
1497
1498 <dl>
1499
1500 <dt><i>node</i> (ast.GeneratorExp)</dt>
1501 <dd>
1502 reference to the node to be processed
1503 </dd>
1504 </dl>
1505 <a NAME="BugBearVisitor.visit_Import" ID="BugBearVisitor.visit_Import"></a>
1506 <h4>BugBearVisitor.visit_Import</h4>
1507 <b>visit_Import</b>(<i>node</i>)
1508 <p>
1509 Public method to check imports.
1510 </p>
1511
1512 <dl>
1513
1514 <dt><i>node</i> (ast.Import)</dt>
1515 <dd>
1516 reference to the node to be processed
1517 </dd>
1518 </dl>
1519 <a NAME="BugBearVisitor.visit_ImportFrom" ID="BugBearVisitor.visit_ImportFrom"></a>
1520 <h4>BugBearVisitor.visit_ImportFrom</h4>
1521 <b>visit_ImportFrom</b>(<i>node</i>)
1522 <p>
1523 Public method to check from imports.
1524 </p>
1525
1526 <dl>
1527
1528 <dt><i>node</i> (ast.Import)</dt>
1529 <dd>
1530 reference to the node to be processed
1531 </dd>
1532 </dl>
1533 <a NAME="BugBearVisitor.visit_JoinedStr" ID="BugBearVisitor.visit_JoinedStr"></a>
1534 <h4>BugBearVisitor.visit_JoinedStr</h4>
1535 <b>visit_JoinedStr</b>(<i>node</i>)
1536 <p>
1537 Public method to handle f-string arguments.
1538 </p>
1539
1540 <dl>
1541
1542 <dt><i>node</i> (ast.JoinedStr)</dt>
1543 <dd>
1544 reference to the node to be processed
1545 </dd>
1546 </dl>
1547 <a NAME="BugBearVisitor.visit_ListComp" ID="BugBearVisitor.visit_ListComp"></a>
1548 <h4>BugBearVisitor.visit_ListComp</h4>
1549 <b>visit_ListComp</b>(<i>node</i>)
1550 <p>
1551 Public method to handle list comprehensions.
1552 </p>
1553
1554 <dl>
1555
1556 <dt><i>node</i> (ast.ListComp)</dt>
1557 <dd>
1558 reference to the node to be processed
1559 </dd>
1560 </dl>
1561 <a NAME="BugBearVisitor.visit_Module" ID="BugBearVisitor.visit_Module"></a>
1562 <h4>BugBearVisitor.visit_Module</h4>
1563 <b>visit_Module</b>(<i>node</i>)
1564 <p>
1565 Public method to handle a module node.
1566 </p>
1567
1568 <dl>
1569
1570 <dt><i>node</i> (ast.Module)</dt>
1571 <dd>
1572 reference to the node to be processed
1573 </dd>
1574 </dl>
1575 <a NAME="BugBearVisitor.visit_Raise" ID="BugBearVisitor.visit_Raise"></a>
1576 <h4>BugBearVisitor.visit_Raise</h4>
1577 <b>visit_Raise</b>(<i>node</i>)
1578 <p>
1579 Public method to handle 'raise' statements.
1580 </p>
1581
1582 <dl>
1583
1584 <dt><i>node</i> (ast.Raise)</dt>
1585 <dd>
1586 reference to the node to be processed
1587 </dd>
1588 </dl>
1589 <a NAME="BugBearVisitor.visit_Return" ID="BugBearVisitor.visit_Return"></a>
1590 <h4>BugBearVisitor.visit_Return</h4>
1591 <b>visit_Return</b>(<i>node</i>)
1592 <p>
1593 Public method to handle 'Return' nodes.
1594 </p>
1595
1596 <dl>
1597
1598 <dt><i>node</i> (ast.Return)</dt>
1599 <dd>
1600 reference to the node to be processed
1601 </dd>
1602 </dl>
1603 <a NAME="BugBearVisitor.visit_Set" ID="BugBearVisitor.visit_Set"></a>
1604 <h4>BugBearVisitor.visit_Set</h4>
1605 <b>visit_Set</b>(<i>node</i>)
1606 <p>
1607 Public method to check a set.
1608 </p>
1609
1610 <dl>
1611
1612 <dt><i>node</i> (ast.Set)</dt>
1613 <dd>
1614 reference to the node to be processed
1615 </dd>
1616 </dl>
1617 <a NAME="BugBearVisitor.visit_SetComp" ID="BugBearVisitor.visit_SetComp"></a>
1618 <h4>BugBearVisitor.visit_SetComp</h4>
1619 <b>visit_SetComp</b>(<i>node</i>)
1620 <p>
1621 Public method to handle set comprehensions.
1622 </p>
1623
1624 <dl>
1625
1626 <dt><i>node</i> (ast.SetComp)</dt>
1627 <dd>
1628 reference to the node to be processed
1629 </dd>
1630 </dl>
1631 <a NAME="BugBearVisitor.visit_Try" ID="BugBearVisitor.visit_Try"></a>
1632 <h4>BugBearVisitor.visit_Try</h4>
1633 <b>visit_Try</b>(<i>node</i>)
1634 <p>
1635 Public method to handle 'try' statements.
1636 </p>
1637
1638 <dl>
1639
1640 <dt><i>node</i> (ast.Try)</dt>
1641 <dd>
1642 reference to the node to be processed
1643 </dd>
1644 </dl>
1645 <a NAME="BugBearVisitor.visit_TryStar" ID="BugBearVisitor.visit_TryStar"></a>
1646 <h4>BugBearVisitor.visit_TryStar</h4>
1647 <b>visit_TryStar</b>(<i>node</i>)
1648 <p>
1649 Public method to handle 'except*' statements.
1650 </p>
1651
1652 <dl>
1653
1654 <dt><i>node</i> (ast.TryStar)</dt>
1655 <dd>
1656 reference to the node to be processed
1657 </dd>
1658 </dl>
1659 <a NAME="BugBearVisitor.visit_UAdd" ID="BugBearVisitor.visit_UAdd"></a>
1660 <h4>BugBearVisitor.visit_UAdd</h4>
1661 <b>visit_UAdd</b>(<i>node</i>)
1662 <p>
1663 Public method to handle unary additions.
1664 </p>
1665
1666 <dl>
1667
1668 <dt><i>node</i> (ast.UAdd)</dt>
1669 <dd>
1670 reference to the node to be processed
1671 </dd>
1672 </dl>
1673 <a NAME="BugBearVisitor.visit_While" ID="BugBearVisitor.visit_While"></a>
1674 <h4>BugBearVisitor.visit_While</h4>
1675 <b>visit_While</b>(<i>node</i>)
1676 <p>
1677 Public method to handle 'while' statements.
1678 </p>
1679
1680 <dl>
1681
1682 <dt><i>node</i> (ast.While)</dt>
1683 <dd>
1684 reference to the node to be processed
1685 </dd>
1686 </dl>
1687 <a NAME="BugBearVisitor.visit_With" ID="BugBearVisitor.visit_With"></a>
1688 <h4>BugBearVisitor.visit_With</h4>
1689 <b>visit_With</b>(<i>node</i>)
1690 <p>
1691 Public method to handle 'with' statements.
1692 </p>
1693
1694 <dl>
1695
1696 <dt><i>node</i> (ast.With)</dt>
1697 <dd>
1698 reference to the node to be processed
1699 </dd>
1700 </dl>
1701 <a NAME="BugBearVisitor.visit_Yield" ID="BugBearVisitor.visit_Yield"></a>
1702 <h4>BugBearVisitor.visit_Yield</h4>
1703 <b>visit_Yield</b>(<i>node</i>)
1704 <p>
1705 Public method to handle 'Yield' nodes.
1706 </p>
1707
1708 <dl>
1709
1710 <dt><i>node</i> (ast.Yield)</dt>
1711 <dd>
1712 reference to the node to be processed
1713 </dd>
1714 </dl>
1715 <a NAME="BugBearVisitor.visit_YieldFrom" ID="BugBearVisitor.visit_YieldFrom"></a>
1716 <h4>BugBearVisitor.visit_YieldFrom</h4>
1717 <b>visit_YieldFrom</b>(<i>node</i>)
1718 <p>
1719 Public method to handle 'YieldFrom' nodes.
1720 </p>
1721
1722 <dl>
1723
1724 <dt><i>node</i> (ast.YieldFrom)</dt>
1725 <dd>
1726 reference to the node to be processed
1727 </dd>
1728 </dl>
1729 <div align="right"><a href="#top">Up</a></div>
1730 <hr />
1731 <hr />
1732 <a NAME="ExceptBaseExceptionVisitor" ID="ExceptBaseExceptionVisitor"></a>
1733 <h2>ExceptBaseExceptionVisitor</h2>
1734 <p>
1735 Class to determine, if a 'BaseException' is re-raised.
1736 </p>
1737
1738 <h3>Derived from</h3>
1739 ast.NodeVisitor
1740 <h3>Class Attributes</h3>
1741 <table>
1742 <tr><td>None</td></tr>
1743 </table>
1744
1745 <h3>Class Methods</h3>
1746 <table>
1747 <tr><td>None</td></tr>
1748 </table>
1749
1750 <h3>Methods</h3>
1751 <table>
1752 <tr>
1753 <td><a href="#ExceptBaseExceptionVisitor.__init__">ExceptBaseExceptionVisitor</a></td>
1754 <td>Constructor</td>
1755 </tr>
1756 <tr>
1757 <td><a href="#ExceptBaseExceptionVisitor.reRaised">reRaised</a></td>
1758 <td>Public method to check, if the exception is re-raised.</td>
1759 </tr>
1760 <tr>
1761 <td><a href="#ExceptBaseExceptionVisitor.visit_ExceptHandler">visit_ExceptHandler</a></td>
1762 <td>Public method to handle 'ExceptHandler' nodes.</td>
1763 </tr>
1764 <tr>
1765 <td><a href="#ExceptBaseExceptionVisitor.visit_Raise">visit_Raise</a></td>
1766 <td>Public method to handle 'Raise' nodes.</td>
1767 </tr>
1768 </table>
1769
1770 <h3>Static Methods</h3>
1771 <table>
1772 <tr><td>None</td></tr>
1773 </table>
1774
1775
1776 <a NAME="ExceptBaseExceptionVisitor.__init__" ID="ExceptBaseExceptionVisitor.__init__"></a>
1777 <h4>ExceptBaseExceptionVisitor (Constructor)</h4>
1778 <b>ExceptBaseExceptionVisitor</b>(<i>exceptNode</i>)
1779 <p>
1780 Constructor
1781 </p>
1782
1783 <dl>
1784
1785 <dt><i>exceptNode</i> (ast.ExceptHandler)</dt>
1786 <dd>
1787 exception node to be inspected
1788 </dd>
1789 </dl>
1790 <a NAME="ExceptBaseExceptionVisitor.reRaised" ID="ExceptBaseExceptionVisitor.reRaised"></a>
1791 <h4>ExceptBaseExceptionVisitor.reRaised</h4>
1792 <b>reRaised</b>(<i></i>)
1793 <p>
1794 Public method to check, if the exception is re-raised.
1795 </p>
1796
1797 <dl>
1798 <dt>Return:</dt>
1799 <dd>
1800 flag indicating a re-raised exception
1801 </dd>
1802 </dl>
1803 <dl>
1804 <dt>Return Type:</dt>
1805 <dd>
1806 bool
1807 </dd>
1808 </dl>
1809 <a NAME="ExceptBaseExceptionVisitor.visit_ExceptHandler" ID="ExceptBaseExceptionVisitor.visit_ExceptHandler"></a>
1810 <h4>ExceptBaseExceptionVisitor.visit_ExceptHandler</h4>
1811 <b>visit_ExceptHandler</b>(<i>node: ast.ExceptHandler</i>)
1812 <p>
1813 Public method to handle 'ExceptHandler' nodes.
1814 </p>
1815
1816 <dl>
1817
1818 <dt><i>node</i> (ast.ExceptHandler)</dt>
1819 <dd>
1820 reference to the node to be processed
1821 </dd>
1822 </dl>
1823 <a NAME="ExceptBaseExceptionVisitor.visit_Raise" ID="ExceptBaseExceptionVisitor.visit_Raise"></a>
1824 <h4>ExceptBaseExceptionVisitor.visit_Raise</h4>
1825 <b>visit_Raise</b>(<i>node</i>)
1826 <p>
1827 Public method to handle 'Raise' nodes.
1828 </p>
1829 <p>
1830 If we find a corresponding `raise` or `raise e` where e was from
1831 `except BaseException as e:` then we mark re_raised as True and can
1832 stop scanning.
1833 </p>
1834
1835 <dl>
1836
1837 <dt><i>node</i> (ast.Raise)</dt>
1838 <dd>
1839 reference to the node to be processed
1840 </dd>
1841 </dl>
1842 <div align="right"><a href="#top">Up</a></div>
1843 <hr />
1844 <hr />
1845 <a NAME="FunctionDefDefaultsVisitor" ID="FunctionDefDefaultsVisitor"></a>
1846 <h2>FunctionDefDefaultsVisitor</h2>
1847 <p>
1848 Class used by M506, M508 and M539.
1849 </p>
1850
1851 <h3>Derived from</h3>
1852 ast.NodeVisitor
1853 <h3>Class Attributes</h3>
1854 <table>
1855 <tr><td>None</td></tr>
1856 </table>
1857
1858 <h3>Class Methods</h3>
1859 <table>
1860 <tr><td>None</td></tr>
1861 </table>
1862
1863 <h3>Methods</h3>
1864 <table>
1865 <tr>
1866 <td><a href="#FunctionDefDefaultsVisitor.__init__">FunctionDefDefaultsVisitor</a></td>
1867 <td>Constructor</td>
1868 </tr>
1869 <tr>
1870 <td><a href="#FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension">__visitMutableLiteralOrComprehension</a></td>
1871 <td>Private method to flag mutable literals and comprehensions.</td>
1872 </tr>
1873 <tr>
1874 <td><a href="#FunctionDefDefaultsVisitor.visit">visit</a></td>
1875 <td>Public method to traverse an AST node or a list of AST nodes.</td>
1876 </tr>
1877 <tr>
1878 <td><a href="#FunctionDefDefaultsVisitor.visit_Call">visit_Call</a></td>
1879 <td>Public method to process Call nodes.</td>
1880 </tr>
1881 <tr>
1882 <td><a href="#FunctionDefDefaultsVisitor.visit_Lambda">visit_Lambda</a></td>
1883 <td>Public method to process Lambda nodes.</td>
1884 </tr>
1885 </table>
1886
1887 <h3>Static Methods</h3>
1888 <table>
1889 <tr><td>None</td></tr>
1890 </table>
1891
1892
1893 <a NAME="FunctionDefDefaultsVisitor.__init__" ID="FunctionDefDefaultsVisitor.__init__"></a>
1894 <h4>FunctionDefDefaultsVisitor (Constructor)</h4>
1895 <b>FunctionDefDefaultsVisitor</b>(<i>errorCodeCalls, errorCodeLiterals, </i>)
1896 <p>
1897 Constructor
1898 </p>
1899
1900 <dl>
1901
1902 <dt><i>errorCodeCalls</i> (str)</dt>
1903 <dd>
1904 error code for ast.Call nodes
1905 </dd>
1906 <dt><i>errorCodeLiterals</i> (str)</dt>
1907 <dd>
1908 error code for literal nodes
1909 </dd>
1910 </dl>
1911 <a NAME="FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension" ID="FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension"></a>
1912 <h4>FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension</h4>
1913 <b>__visitMutableLiteralOrComprehension</b>(<i>node</i>)
1914 <p>
1915 Private method to flag mutable literals and comprehensions.
1916 </p>
1917
1918 <dl>
1919
1920 <dt><i>node</i> (ast.Dict, ast.List, ast.Set, ast.ListComp, ast.DictComp or ast.SetComp)</dt>
1921 <dd>
1922 AST node to be processed
1923 </dd>
1924 </dl>
1925 <a NAME="FunctionDefDefaultsVisitor.visit" ID="FunctionDefDefaultsVisitor.visit"></a>
1926 <h4>FunctionDefDefaultsVisitor.visit</h4>
1927 <b>visit</b>(<i>node</i>)
1928 <p>
1929 Public method to traverse an AST node or a list of AST nodes.
1930 </p>
1931 <p>
1932 This is an extended method that can also handle a list of AST nodes.
1933 </p>
1934
1935 <dl>
1936
1937 <dt><i>node</i> (ast.AST or list of ast.AST)</dt>
1938 <dd>
1939 AST node or list of AST nodes to be processed
1940 </dd>
1941 </dl>
1942 <a NAME="FunctionDefDefaultsVisitor.visit_Call" ID="FunctionDefDefaultsVisitor.visit_Call"></a>
1943 <h4>FunctionDefDefaultsVisitor.visit_Call</h4>
1944 <b>visit_Call</b>(<i>node</i>)
1945 <p>
1946 Public method to process Call nodes.
1947 </p>
1948
1949 <dl>
1950
1951 <dt><i>node</i> (ast.Call)</dt>
1952 <dd>
1953 AST node to be processed
1954 </dd>
1955 </dl>
1956 <a NAME="FunctionDefDefaultsVisitor.visit_Lambda" ID="FunctionDefDefaultsVisitor.visit_Lambda"></a>
1957 <h4>FunctionDefDefaultsVisitor.visit_Lambda</h4>
1958 <b>visit_Lambda</b>(<i>node</i>)
1959 <p>
1960 Public method to process Lambda nodes.
1961 </p>
1962
1963 <dl>
1964
1965 <dt><i>node</i> (ast.Lambda)</dt>
1966 <dd>
1967 AST node to be processed
1968 </dd>
1969 </dl>
1970 <div align="right"><a href="#top">Up</a></div>
1971 <hr />
1972 <hr />
1973 <a NAME="M520NameFinder" ID="M520NameFinder"></a>
1974 <h2>M520NameFinder</h2>
1975 <p>
1976 Class to extract a name out of a tree of nodes ignoring names defined within the
1977 local scope of a comprehension.
1978 </p>
1979
1980 <h3>Derived from</h3>
1981 NameFinder
1982 <h3>Class Attributes</h3>
1983 <table>
1984 <tr><td>None</td></tr>
1985 </table>
1986
1987 <h3>Class Methods</h3>
1988 <table>
1989 <tr><td>None</td></tr>
1990 </table>
1991
1992 <h3>Methods</h3>
1993 <table>
1994 <tr>
1995 <td><a href="#M520NameFinder.visit_DictComp">visit_DictComp</a></td>
1996 <td>Public method to handle a dictionary comprehension.</td>
1997 </tr>
1998 <tr>
1999 <td><a href="#M520NameFinder.visit_GeneratorExp">visit_GeneratorExp</a></td>
2000 <td>Public method to handle a generator expressions.</td>
2001 </tr>
2002 <tr>
2003 <td><a href="#M520NameFinder.visit_Lambda">visit_Lambda</a></td>
2004 <td>Public method to handle a Lambda function.</td>
2005 </tr>
2006 <tr>
2007 <td><a href="#M520NameFinder.visit_ListComp">visit_ListComp</a></td>
2008 <td>Public method to handle a list comprehension.</td>
2009 </tr>
2010 <tr>
2011 <td><a href="#M520NameFinder.visit_comprehension">visit_comprehension</a></td>
2012 <td>Public method to handle the 'for' of a comprehension.</td>
2013 </tr>
2014 </table>
2015
2016 <h3>Static Methods</h3>
2017 <table>
2018 <tr><td>None</td></tr>
2019 </table>
2020
2021
2022 <a NAME="M520NameFinder.visit_DictComp" ID="M520NameFinder.visit_DictComp"></a>
2023 <h4>M520NameFinder.visit_DictComp</h4>
2024 <b>visit_DictComp</b>(<i>node</i>)
2025 <p>
2026 Public method to handle a dictionary comprehension.
2027 </p>
2028
2029 <dl>
2030
2031 <dt><i>node</i> (TYPE)</dt>
2032 <dd>
2033 reference to the node to be processed
2034 </dd>
2035 </dl>
2036 <a NAME="M520NameFinder.visit_GeneratorExp" ID="M520NameFinder.visit_GeneratorExp"></a>
2037 <h4>M520NameFinder.visit_GeneratorExp</h4>
2038 <b>visit_GeneratorExp</b>(<i>node</i>)
2039 <p>
2040 Public method to handle a generator expressions.
2041 </p>
2042
2043 <dl>
2044
2045 <dt><i>node</i> (ast.GeneratorExp)</dt>
2046 <dd>
2047 reference to the node to be processed
2048 </dd>
2049 </dl>
2050 <a NAME="M520NameFinder.visit_Lambda" ID="M520NameFinder.visit_Lambda"></a>
2051 <h4>M520NameFinder.visit_Lambda</h4>
2052 <b>visit_Lambda</b>(<i>node</i>)
2053 <p>
2054 Public method to handle a Lambda function.
2055 </p>
2056
2057 <dl>
2058
2059 <dt><i>node</i> (ast.Lambda)</dt>
2060 <dd>
2061 reference to the node to be processed
2062 </dd>
2063 </dl>
2064 <a NAME="M520NameFinder.visit_ListComp" ID="M520NameFinder.visit_ListComp"></a>
2065 <h4>M520NameFinder.visit_ListComp</h4>
2066 <b>visit_ListComp</b>(<i>node</i>)
2067 <p>
2068 Public method to handle a list comprehension.
2069 </p>
2070
2071 <dl>
2072
2073 <dt><i>node</i> (TYPE)</dt>
2074 <dd>
2075 reference to the node to be processed
2076 </dd>
2077 </dl>
2078 <a NAME="M520NameFinder.visit_comprehension" ID="M520NameFinder.visit_comprehension"></a>
2079 <h4>M520NameFinder.visit_comprehension</h4>
2080 <b>visit_comprehension</b>(<i>node</i>)
2081 <p>
2082 Public method to handle the 'for' of a comprehension.
2083 </p>
2084
2085 <dl>
2086
2087 <dt><i>node</i> (ast.comprehension)</dt>
2088 <dd>
2089 reference to the node to be processed
2090 </dd>
2091 </dl>
2092 <div align="right"><a href="#top">Up</a></div>
2093 <hr />
2094 <hr />
2095 <a NAME="M540CaughtException" ID="M540CaughtException"></a>
2096 <h2>M540CaughtException</h2>
2097 <p>
2098 Class to hold the data for a caught exception.
2099 </p>
2100
2101 <h3>Derived from</h3>
2102 None
2103 <h3>Class Attributes</h3>
2104 <table>
2105 <tr><td>hasNote</td></tr>
2106 <tr><td>name</td></tr>
2107 </table>
2108
2109 <h3>Class Methods</h3>
2110 <table>
2111 <tr><td>None</td></tr>
2112 </table>
2113
2114 <h3>Methods</h3>
2115 <table>
2116 <tr><td>None</td></tr>
2117 </table>
2118
2119 <h3>Static Methods</h3>
2120 <table>
2121 <tr><td>None</td></tr>
2122 </table>
2123
2124
2125 <div align="right"><a href="#top">Up</a></div>
2126 <hr />
2127 <hr />
2128 <a NAME="M541UnhandledKeyType" ID="M541UnhandledKeyType"></a>
2129 <h2>M541UnhandledKeyType</h2>
2130 <p>
2131 Class to hold a dictionary key of a type that we do not check for duplicates.
2132 </p>
2133
2134 <h3>Derived from</h3>
2135 None
2136 <h3>Class Attributes</h3>
2137 <table>
2138 <tr><td>None</td></tr>
2139 </table>
2140
2141 <h3>Class Methods</h3>
2142 <table>
2143 <tr><td>None</td></tr>
2144 </table>
2145
2146 <h3>Methods</h3>
2147 <table>
2148 <tr><td>None</td></tr>
2149 </table>
2150
2151 <h3>Static Methods</h3>
2152 <table>
2153 <tr><td>None</td></tr>
2154 </table>
2155
2156
2157 <div align="right"><a href="#top">Up</a></div>
2158 <hr />
2159 <hr />
2160 <a NAME="M541VariableKeyType" ID="M541VariableKeyType"></a>
2161 <h2>M541VariableKeyType</h2>
2162 <p>
2163 Class to hold the name of a variable key type.
2164 </p>
2165
2166 <h3>Derived from</h3>
2167 None
2168 <h3>Class Attributes</h3>
2169 <table>
2170 <tr><td>None</td></tr>
2171 </table>
2172
2173 <h3>Class Methods</h3>
2174 <table>
2175 <tr><td>None</td></tr>
2176 </table>
2177
2178 <h3>Methods</h3>
2179 <table>
2180 <tr>
2181 <td><a href="#M541VariableKeyType.__init__">M541VariableKeyType</a></td>
2182 <td>Constructor</td>
2183 </tr>
2184 </table>
2185
2186 <h3>Static Methods</h3>
2187 <table>
2188 <tr><td>None</td></tr>
2189 </table>
2190
2191
2192 <a NAME="M541VariableKeyType.__init__" ID="M541VariableKeyType.__init__"></a>
2193 <h4>M541VariableKeyType (Constructor)</h4>
2194 <b>M541VariableKeyType</b>(<i>name</i>)
2195 <p>
2196 Constructor
2197 </p>
2198
2199 <dl>
2200
2201 <dt><i>name</i> (str)</dt>
2202 <dd>
2203 name of the variable key type
2204 </dd>
2205 </dl>
2206 <div align="right"><a href="#top">Up</a></div>
2207 <hr />
2208 <hr />
2209 <a NAME="M569Checker" ID="M569Checker"></a>
2210 <h2>M569Checker</h2>
2211 <p>
2212 Class traversing a 'for' loop body to check for modifications to a loop's
2213 mutable iterable.
2214 </p>
2215
2216 <h3>Derived from</h3>
2217 ast.NodeVisitor
2218 <h3>Class Attributes</h3>
2219 <table>
2220 <tr><td>MUTATING_FUNCTIONS</td></tr>
2221 </table>
2222
2223 <h3>Class Methods</h3>
2224 <table>
2225 <tr><td>None</td></tr>
2226 </table>
2227
2228 <h3>Methods</h3>
2229 <table>
2230 <tr>
2231 <td><a href="#M569Checker.__init__">M569Checker</a></td>
2232 <td>Constructor</td>
2233 </tr>
2234 <tr>
2235 <td><a href="#M569Checker.visit">visit</a></td>
2236 <td>Public method to inspect an ast node.</td>
2237 </tr>
2238 <tr>
2239 <td><a href="#M569Checker.visit_Call">visit_Call</a></td>
2240 <td>Public method handling 'Call' nodes.</td>
2241 </tr>
2242 <tr>
2243 <td><a href="#M569Checker.visit_Delete">visit_Delete</a></td>
2244 <td>Public method handling 'Delete' nodes.</td>
2245 </tr>
2246 </table>
2247
2248 <h3>Static Methods</h3>
2249 <table>
2250 <tr><td>None</td></tr>
2251 </table>
2252
2253
2254 <a NAME="M569Checker.__init__" ID="M569Checker.__init__"></a>
2255 <h4>M569Checker (Constructor)</h4>
2256 <b>M569Checker</b>(<i>name, bugbear</i>)
2257 <p>
2258 Constructor
2259 </p>
2260
2261 <dl>
2262
2263 <dt><i>name</i> (str)</dt>
2264 <dd>
2265 name of the iterator
2266 </dd>
2267 <dt><i>bugbear</i> (BugBearVisitor)</dt>
2268 <dd>
2269 reference to the bugbear visitor
2270 </dd>
2271 </dl>
2272 <a NAME="M569Checker.visit" ID="M569Checker.visit"></a>
2273 <h4>M569Checker.visit</h4>
2274 <b>visit</b>(<i>node</i>)
2275 <p>
2276 Public method to inspect an ast node.
2277 </p>
2278 <p>
2279 Like super-visit but supports iteration over lists.
2280 </p>
2281
2282 <dl>
2283
2284 <dt><i>node</i> (TYPE)</dt>
2285 <dd>
2286 AST node to be traversed
2287 </dd>
2288 </dl>
2289 <dl>
2290 <dt>Return:</dt>
2291 <dd>
2292 reference to the last processed node
2293 </dd>
2294 </dl>
2295 <dl>
2296 <dt>Return Type:</dt>
2297 <dd>
2298 ast.Node
2299 </dd>
2300 </dl>
2301 <a NAME="M569Checker.visit_Call" ID="M569Checker.visit_Call"></a>
2302 <h4>M569Checker.visit_Call</h4>
2303 <b>visit_Call</b>(<i>node</i>)
2304 <p>
2305 Public method handling 'Call' nodes.
2306 </p>
2307
2308 <dl>
2309
2310 <dt><i>node</i> (ast.Call)</dt>
2311 <dd>
2312 reference to the node to be processed
2313 </dd>
2314 </dl>
2315 <a NAME="M569Checker.visit_Delete" ID="M569Checker.visit_Delete"></a>
2316 <h4>M569Checker.visit_Delete</h4>
2317 <b>visit_Delete</b>(<i>node</i>)
2318 <p>
2319 Public method handling 'Delete' nodes.
2320 </p>
2321
2322 <dl>
2323
2324 <dt><i>node</i> (ast.Delete)</dt>
2325 <dd>
2326 reference to the node to be processed
2327 </dd>
2328 </dl>
2329 <div align="right"><a href="#top">Up</a></div>
2330 <hr />
2331 <hr />
2332 <a NAME="NameFinder" ID="NameFinder"></a>
2333 <h2>NameFinder</h2>
2334 <p>
2335 Class to extract a name out of a tree of nodes.
2336 </p>
2337
2338 <h3>Derived from</h3>
2339 ast.NodeVisitor
2340 <h3>Class Attributes</h3>
2341 <table>
2342 <tr><td>None</td></tr>
2343 </table>
2344
2345 <h3>Class Methods</h3>
2346 <table>
2347 <tr><td>None</td></tr>
2348 </table>
2349
2350 <h3>Methods</h3>
2351 <table>
2352 <tr>
2353 <td><a href="#NameFinder.__init__">NameFinder</a></td>
2354 <td>Constructor</td>
2355 </tr>
2356 <tr>
2357 <td><a href="#NameFinder.getNames">getNames</a></td>
2358 <td>Public method to return the extracted names and Name nodes.</td>
2359 </tr>
2360 <tr>
2361 <td><a href="#NameFinder.visit">visit</a></td>
2362 <td>Public method to traverse a given AST node.</td>
2363 </tr>
2364 <tr>
2365 <td><a href="#NameFinder.visit_Name">visit_Name</a></td>
2366 <td>Public method to handle 'Name' nodes.</td>
2367 </tr>
2368 </table>
2369
2370 <h3>Static Methods</h3>
2371 <table>
2372 <tr><td>None</td></tr>
2373 </table>
2374
2375
2376 <a NAME="NameFinder.__init__" ID="NameFinder.__init__"></a>
2377 <h4>NameFinder (Constructor)</h4>
2378 <b>NameFinder</b>(<i></i>)
2379 <p>
2380 Constructor
2381 </p>
2382
2383 <a NAME="NameFinder.getNames" ID="NameFinder.getNames"></a>
2384 <h4>NameFinder.getNames</h4>
2385 <b>getNames</b>(<i></i>)
2386 <p>
2387 Public method to return the extracted names and Name nodes.
2388 </p>
2389
2390 <dl>
2391 <dt>Return:</dt>
2392 <dd>
2393 dictionary containing the names as keys and the list of nodes
2394 </dd>
2395 </dl>
2396 <dl>
2397 <dt>Return Type:</dt>
2398 <dd>
2399 dict
2400 </dd>
2401 </dl>
2402 <a NAME="NameFinder.visit" ID="NameFinder.visit"></a>
2403 <h4>NameFinder.visit</h4>
2404 <b>visit</b>(<i>node</i>)
2405 <p>
2406 Public method to traverse a given AST node.
2407 </p>
2408
2409 <dl>
2410
2411 <dt><i>node</i> (ast.Node)</dt>
2412 <dd>
2413 AST node to be traversed
2414 </dd>
2415 </dl>
2416 <dl>
2417 <dt>Return:</dt>
2418 <dd>
2419 reference to the last processed node
2420 </dd>
2421 </dl>
2422 <dl>
2423 <dt>Return Type:</dt>
2424 <dd>
2425 ast.Node
2426 </dd>
2427 </dl>
2428 <a NAME="NameFinder.visit_Name" ID="NameFinder.visit_Name"></a>
2429 <h4>NameFinder.visit_Name</h4>
2430 <b>visit_Name</b>(<i>node</i>)
2431 <p>
2432 Public method to handle 'Name' nodes.
2433 </p>
2434
2435 <dl>
2436
2437 <dt><i>node</i> (ast.Name)</dt>
2438 <dd>
2439 reference to the node to be processed
2440 </dd>
2441 </dl>
2442 <div align="right"><a href="#top">Up</a></div>
2443 <hr />
2444 <hr />
2445 <a NAME="NamedExprFinder" ID="NamedExprFinder"></a>
2446 <h2>NamedExprFinder</h2>
2447 <p>
2448 Class to extract names defined through an ast.NamedExpr.
2449 </p>
2450
2451 <h3>Derived from</h3>
2452 ast.NodeVisitor
2453 <h3>Class Attributes</h3>
2454 <table>
2455 <tr><td>None</td></tr>
2456 </table>
2457
2458 <h3>Class Methods</h3>
2459 <table>
2460 <tr><td>None</td></tr>
2461 </table>
2462
2463 <h3>Methods</h3>
2464 <table>
2465 <tr>
2466 <td><a href="#NamedExprFinder.__init__">NamedExprFinder</a></td>
2467 <td>Constructor</td>
2468 </tr>
2469 <tr>
2470 <td><a href="#NamedExprFinder.getNames">getNames</a></td>
2471 <td>Public method to return the extracted names and Name nodes.</td>
2472 </tr>
2473 <tr>
2474 <td><a href="#NamedExprFinder.visit">visit</a></td>
2475 <td>Public method to traverse a given AST node.</td>
2476 </tr>
2477 <tr>
2478 <td><a href="#NamedExprFinder.visit_NamedExpr">visit_NamedExpr</a></td>
2479 <td>Public method handling 'NamedExpr' nodes.</td>
2480 </tr>
2481 </table>
2482
2483 <h3>Static Methods</h3>
2484 <table>
2485 <tr><td>None</td></tr>
2486 </table>
2487
2488
2489 <a NAME="NamedExprFinder.__init__" ID="NamedExprFinder.__init__"></a>
2490 <h4>NamedExprFinder (Constructor)</h4>
2491 <b>NamedExprFinder</b>(<i></i>)
2492 <p>
2493 Constructor
2494 </p>
2495
2496 <a NAME="NamedExprFinder.getNames" ID="NamedExprFinder.getNames"></a>
2497 <h4>NamedExprFinder.getNames</h4>
2498 <b>getNames</b>(<i></i>)
2499 <p>
2500 Public method to return the extracted names and Name nodes.
2501 </p>
2502
2503 <dl>
2504 <dt>Return:</dt>
2505 <dd>
2506 dictionary containing the names as keys and the list of nodes
2507 </dd>
2508 </dl>
2509 <dl>
2510 <dt>Return Type:</dt>
2511 <dd>
2512 dict
2513 </dd>
2514 </dl>
2515 <a NAME="NamedExprFinder.visit" ID="NamedExprFinder.visit"></a>
2516 <h4>NamedExprFinder.visit</h4>
2517 <b>visit</b>(<i>node</i>)
2518 <p>
2519 Public method to traverse a given AST node.
2520 </p>
2521 <p>
2522 Like super-visit but supports iteration over lists.
2523 </p>
2524
2525 <dl>
2526
2527 <dt><i>node</i> (TYPE)</dt>
2528 <dd>
2529 AST node to be traversed
2530 </dd>
2531 </dl>
2532 <dl>
2533 <dt>Return:</dt>
2534 <dd>
2535 reference to the last processed node
2536 </dd>
2537 </dl>
2538 <dl>
2539 <dt>Return Type:</dt>
2540 <dd>
2541 ast.Node
2542 </dd>
2543 </dl>
2544 <a NAME="NamedExprFinder.visit_NamedExpr" ID="NamedExprFinder.visit_NamedExpr"></a>
2545 <h4>NamedExprFinder.visit_NamedExpr</h4>
2546 <b>visit_NamedExpr</b>(<i>node: ast.NamedExpr</i>)
2547 <p>
2548 Public method handling 'NamedExpr' nodes.
2549 </p>
2550
2551 <dl>
2552
2553 <dt><i>node</i> (ast.NamedExpr)</dt>
2554 <dd>
2555 reference to the node to be processed
2556 </dd>
2557 </dl>
2558 <div align="right"><a href="#top">Up</a></div>
2559 <hr />
2560 <hr />
2561 <a NAME="composeCallPath" ID="composeCallPath"></a>
2562 <h2>composeCallPath</h2>
2563 <b>composeCallPath</b>(<i>node</i>)
2564 <p>
2565 Generator function to assemble the call path of a given node.
2566 </p>
2567
2568 <dl>
2569
2570 <dt><i>node</i> (ast.Node)</dt>
2571 <dd>
2572 node to assemble call path for
2573 </dd>
2574 </dl>
2575 <dl>
2576 <dt>Yield:</dt>
2577 <dd>
2578 call path components
2579 </dd>
2580 </dl>
2581 <dl>
2582 <dt>Yield Type:</dt>
2583 <dd>
2584 str
2585 </dd>
2586 </dl>
2587 <div align="right"><a href="#top">Up</a></div>
2588 <hr />
2589 </body></html>

eric ide

mercurial