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

branch
eric7
changeset 11150
73d80859079c
parent 11140
b823386f7591
equal deleted inserted replaced
11149:fc45672fae42 11150:73d80859079c
11 Module implementing a checker for miscellaneous checks. 11 Module implementing a checker for miscellaneous checks.
12 </p> 12 </p>
13 13
14 <h3>Global Attributes</h3> 14 <h3>Global Attributes</h3>
15 <table> 15 <table>
16 <tr><td>BugBearContext</td></tr> 16 <tr><td>None</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> 17 </table>
22 18
23 <h3>Classes</h3> 19 <h3>Classes</h3>
24 <table> 20 <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="#DateTimeVisitor">DateTimeVisitor</a></td>
31 <td>Class implementing a node visitor to check datetime function calls.</td>
32 </tr>
33 <tr>
34 <td><a href="#DefaultMatchCaseVisitor">DefaultMatchCaseVisitor</a></td>
35 <td>Class implementing a node visitor to check default match cases.</td>
36 </tr>
37 <tr>
38 <td><a href="#ExceptBaseExceptionVisitor">ExceptBaseExceptionVisitor</a></td>
39 <td>Class to determine, if a 'BaseException' is re-raised.</td>
40 </tr>
41 <tr>
42 <td><a href="#FunctionDefDefaultsVisitor">FunctionDefDefaultsVisitor</a></td>
43 <td>Class used by M506, M508 and M539.</td>
44 </tr>
45 <tr>
46 <td><a href="#M520NameFinder">M520NameFinder</a></td>
47 <td>Class to extract a name out of a tree of nodes ignoring names defined within the local scope of a comprehension.</td>
48 </tr>
49 <tr>
50 <td><a href="#M540CaughtException">M540CaughtException</a></td>
51 <td>Class to hold the data for a caught exception.</td>
52 </tr>
53 <tr>
54 <td><a href="#M541UnhandledKeyType">M541UnhandledKeyType</a></td>
55 <td>Class to hold a dictionary key of a type that we do not check for duplicates.</td>
56 </tr>
57 <tr>
58 <td><a href="#M541VariableKeyType">M541VariableKeyType</a></td>
59 <td>Class to hold the name of a variable key type.</td>
60 </tr>
61 <tr>
62 <td><a href="#M569Checker">M569Checker</a></td>
63 <td>Class traversing a 'for' loop body to check for modifications to a loop's mutable iterable.</td>
64 </tr>
65 <tr> 21 <tr>
66 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> 22 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td>
67 <td>Class implementing a checker for miscellaneous checks.</td> 23 <td>Class implementing a checker for miscellaneous checks.</td>
68 </tr> 24 </tr>
69 <tr>
70 <td><a href="#NameFinder">NameFinder</a></td>
71 <td>Class to extract a name out of a tree of nodes.</td>
72 </tr>
73 <tr>
74 <td><a href="#NamedExprFinder">NamedExprFinder</a></td>
75 <td>Class to extract names defined through an ast.NamedExpr.</td>
76 </tr>
77 <tr>
78 <td><a href="#ReturnVisitor">ReturnVisitor</a></td>
79 <td>Class implementing a node visitor to check return statements.</td>
80 </tr>
81 <tr>
82 <td><a href="#SysVersionVisitor">SysVersionVisitor</a></td>
83 <td>Class implementing a node visitor to check the use of sys.version and sys.version_info.</td>
84 </tr>
85 <tr>
86 <td><a href="#TextVisitor">TextVisitor</a></td>
87 <td>Class implementing a node visitor for bytes and str instances.</td>
88 </tr>
89 </table> 25 </table>
90 26
91 <h3>Functions</h3> 27 <h3>Functions</h3>
92 <table> 28 <table>
93 <tr>
94 <td><a href="#composeCallPath">composeCallPath</a></td>
95 <td>Generator function to assemble the call path of a given node.</td>
96 </tr>
97 <tr> 29 <tr>
98 <td><a href="#pairwise">pairwise</a></td> 30 <td><a href="#pairwise">pairwise</a></td>
99 <td></td> 31 <td></td>
100 </tr> 32 </tr>
101 </table> 33 </table>
102 34
103 <hr />
104 <hr />
105 <a NAME="BugBearVisitor" ID="BugBearVisitor"></a>
106 <h2>BugBearVisitor</h2>
107 <p>
108 Class implementing a node visitor to check for various topics.
109 </p>
110
111 <h3>Derived from</h3>
112 ast.NodeVisitor
113 <h3>Class Attributes</h3>
114 <table>
115 <tr><td>CONTEXTFUL_NODES</td></tr>
116 <tr><td>FUNCTION_NODES</td></tr>
117 <tr><td>NodeWindowSize</td></tr>
118 </table>
119
120 <h3>Class Methods</h3>
121 <table>
122 <tr><td>None</td></tr>
123 </table>
124
125 <h3>Methods</h3>
126 <table>
127 <tr>
128 <td><a href="#BugBearVisitor.__init__">BugBearVisitor</a></td>
129 <td>Constructor</td>
130 </tr>
131 <tr>
132 <td><a href="#BugBearVisitor.__checkForM505">__checkForM505</a></td>
133 <td>Private method to check the use of *strip().</td>
134 </tr>
135 <tr>
136 <td><a href="#BugBearVisitor.__checkForM506_M508">__checkForM506_M508</a></td>
137 <td>Private method to check the use of mutable literals, comprehensions and calls.</td>
138 </tr>
139 <tr>
140 <td><a href="#BugBearVisitor.__checkForM507">__checkForM507</a></td>
141 <td>Private method to check for unused loop variables.</td>
142 </tr>
143 <tr>
144 <td><a href="#BugBearVisitor.__checkForM512">__checkForM512</a></td>
145 <td>Private method to check for return/continue/break inside finally blocks.</td>
146 </tr>
147 <tr>
148 <td><a href="#BugBearVisitor.__checkForM513_M514_M529_M530">__checkForM513_M514_M529_M530</a></td>
149 <td>Private method to check various exception handler situations.</td>
150 </tr>
151 <tr>
152 <td><a href="#BugBearVisitor.__checkForM515">__checkForM515</a></td>
153 <td>Private method to check for pointless comparisons.</td>
154 </tr>
155 <tr>
156 <td><a href="#BugBearVisitor.__checkForM516">__checkForM516</a></td>
157 <td>Private method to check for raising a literal instead of an exception.</td>
158 </tr>
159 <tr>
160 <td><a href="#BugBearVisitor.__checkForM517">__checkForM517</a></td>
161 <td>Private method to check for use of the evil syntax 'with assertRaises(Exception): or 'with pytest.raises(Exception):'.</td>
162 </tr>
163 <tr>
164 <td><a href="#BugBearVisitor.__checkForM518">__checkForM518</a></td>
165 <td>Private method to check for useless expressions.</td>
166 </tr>
167 <tr>
168 <td><a href="#BugBearVisitor.__checkForM519">__checkForM519</a></td>
169 <td>Private method to check for use of 'functools.lru_cache' or 'functools.cache'.</td>
170 </tr>
171 <tr>
172 <td><a href="#BugBearVisitor.__checkForM520">__checkForM520</a></td>
173 <td>Private method to check for a loop that modifies its iterable.</td>
174 </tr>
175 <tr>
176 <td><a href="#BugBearVisitor.__checkForM521">__checkForM521</a></td>
177 <td>Private method to check for use of an f-string as docstring.</td>
178 </tr>
179 <tr>
180 <td><a href="#BugBearVisitor.__checkForM522">__checkForM522</a></td>
181 <td>Private method to check for use of an f-string as docstring.</td>
182 </tr>
183 <tr>
184 <td><a href="#BugBearVisitor.__checkForM523">__checkForM523</a></td>
185 <td>Private method to check that functions (including lambdas) do not use loop variables.</td>
186 </tr>
187 <tr>
188 <td><a href="#BugBearVisitor.__checkForM524_M527">__checkForM524_M527</a></td>
189 <td>Private method to check for inheritance from abstract classes in abc and lack of any methods decorated with abstract*.</td>
190 </tr>
191 <tr>
192 <td><a href="#BugBearVisitor.__checkForM525">__checkForM525</a></td>
193 <td>Private method to check for exceptions being handled multiple times.</td>
194 </tr>
195 <tr>
196 <td><a href="#BugBearVisitor.__checkForM526">__checkForM526</a></td>
197 <td>Private method to check for Star-arg unpacking after keyword argument.</td>
198 </tr>
199 <tr>
200 <td><a href="#BugBearVisitor.__checkForM528">__checkForM528</a></td>
201 <td>Private method to check for warn without stacklevel.</td>
202 </tr>
203 <tr>
204 <td><a href="#BugBearVisitor.__checkForM531">__checkForM531</a></td>
205 <td>Private method to check that 'itertools.groupby' isn't iterated over more than once.</td>
206 </tr>
207 <tr>
208 <td><a href="#BugBearVisitor.__checkForM532">__checkForM532</a></td>
209 <td>Private method to check for possible unintentional typing annotation.</td>
210 </tr>
211 <tr>
212 <td><a href="#BugBearVisitor.__checkForM533">__checkForM533</a></td>
213 <td>Private method to check a set for duplicate items.</td>
214 </tr>
215 <tr>
216 <td><a href="#BugBearVisitor.__checkForM534">__checkForM534</a></td>
217 <td>Private method to check that re.sub/subn/split arguments flags/count/maxsplit are passed as keyword arguments.</td>
218 </tr>
219 <tr>
220 <td><a href="#BugBearVisitor.__checkForM535">__checkForM535</a></td>
221 <td>Private method to check that a static key isn't used in a dict comprehension.</td>
222 </tr>
223 <tr>
224 <td><a href="#BugBearVisitor.__checkForM539">__checkForM539</a></td>
225 <td>Private method to check for correct ContextVar usage.</td>
226 </tr>
227 <tr>
228 <td><a href="#BugBearVisitor.__checkForM540AddNote">__checkForM540AddNote</a></td>
229 <td>Private method to check add_note usage.</td>
230 </tr>
231 <tr>
232 <td><a href="#BugBearVisitor.__checkForM540Usage">__checkForM540Usage</a></td>
233 <td>Private method to check the usage of exceptions with added note.</td>
234 </tr>
235 <tr>
236 <td><a href="#BugBearVisitor.__checkForM541">__checkForM541</a></td>
237 <td>Private method to check for duplicate key value pairs in a dictionary literal.</td>
238 </tr>
239 <tr>
240 <td><a href="#BugBearVisitor.__checkForM569">__checkForM569</a></td>
241 <td>Private method to check for changes to a loop's mutable iterable.</td>
242 </tr>
243 <tr>
244 <td><a href="#BugBearVisitor.__checkRedundantExcepthandlers">__checkRedundantExcepthandlers</a></td>
245 <td>Private method to check for redundant exception types in an exception handler.</td>
246 </tr>
247 <tr>
248 <td><a href="#BugBearVisitor.__childrenInScope">__childrenInScope</a></td>
249 <td>Private method to get all child nodes in the given scope.</td>
250 </tr>
251 <tr>
252 <td><a href="#BugBearVisitor.__flattenExcepthandler">__flattenExcepthandler</a></td>
253 <td>Private method to flatten the list of exceptions handled by an except handler.</td>
254 </tr>
255 <tr>
256 <td><a href="#BugBearVisitor.__getAssignedNames">__getAssignedNames</a></td>
257 <td>Private method to get the names of a for loop.</td>
258 </tr>
259 <tr>
260 <td><a href="#BugBearVisitor.__getDictCompLoopAndNamedExprVarNames">__getDictCompLoopAndNamedExprVarNames</a></td>
261 <td>Private method to get the names of comprehension loop variables.</td>
262 </tr>
263 <tr>
264 <td><a href="#BugBearVisitor.__getNamesFromTuple">__getNamesFromTuple</a></td>
265 <td>Private method to get the names from an ast.Tuple node.</td>
266 </tr>
267 <tr>
268 <td><a href="#BugBearVisitor.__inClassInit">__inClassInit</a></td>
269 <td>Private method to check, if we are inside an '__init__' method.</td>
270 </tr>
271 <tr>
272 <td><a href="#BugBearVisitor.__isIdentifier">__isIdentifier</a></td>
273 <td>Private method to check if arg is a valid identifier.</td>
274 </tr>
275 <tr>
276 <td><a href="#BugBearVisitor.__namesFromAssignments">__namesFromAssignments</a></td>
277 <td>Private method to get names of an assignment.</td>
278 </tr>
279 <tr>
280 <td><a href="#BugBearVisitor.__typesafeIssubclass">__typesafeIssubclass</a></td>
281 <td>Private method implementing a type safe issubclass() function.</td>
282 </tr>
283 <tr>
284 <td><a href="#BugBearVisitor.__walkList">__walkList</a></td>
285 <td>Private method to walk a given list of nodes.</td>
286 </tr>
287 <tr>
288 <td><a href="#BugBearVisitor._loop">_loop</a></td>
289 <td></td>
290 </tr>
291 <tr>
292 <td><a href="#BugBearVisitor.check">check</a></td>
293 <td></td>
294 </tr>
295 <tr>
296 <td><a href="#BugBearVisitor.convertToValue">convertToValue</a></td>
297 <td>Function to extract the value of a given item.</td>
298 </tr>
299 <tr>
300 <td><a href="#BugBearVisitor.emptyBody">emptyBody</a></td>
301 <td></td>
302 </tr>
303 <tr>
304 <td><a href="#BugBearVisitor.isAbcClass">isAbcClass</a></td>
305 <td></td>
306 </tr>
307 <tr>
308 <td><a href="#BugBearVisitor.isAbstractDecorator">isAbstractDecorator</a></td>
309 <td></td>
310 </tr>
311 <tr>
312 <td><a href="#BugBearVisitor.isOverload">isOverload</a></td>
313 <td></td>
314 </tr>
315 <tr>
316 <td><a href="#BugBearVisitor.isStrOrEllipsis">isStrOrEllipsis</a></td>
317 <td></td>
318 </tr>
319 <tr>
320 <td><a href="#BugBearVisitor.nodeStack">nodeStack</a></td>
321 <td>Public method to get a reference to the most recent node stack.</td>
322 </tr>
323 <tr>
324 <td><a href="#BugBearVisitor.superwalk">superwalk</a></td>
325 <td>Function to walk an AST node or a list of AST nodes.</td>
326 </tr>
327 <tr>
328 <td><a href="#BugBearVisitor.toNameStr">toNameStr</a></td>
329 <td>Public method to turn Name and Attribute nodes to strings, handling any depth of attribute accesses.</td>
330 </tr>
331 <tr>
332 <td><a href="#BugBearVisitor.visit">visit</a></td>
333 <td>Public method to traverse a given AST node.</td>
334 </tr>
335 <tr>
336 <td><a href="#BugBearVisitor.visit_AnnAssign">visit_AnnAssign</a></td>
337 <td>Public method to check annotated assign statements.</td>
338 </tr>
339 <tr>
340 <td><a href="#BugBearVisitor.visit_Assert">visit_Assert</a></td>
341 <td>Public method to handle 'assert' statements.</td>
342 </tr>
343 <tr>
344 <td><a href="#BugBearVisitor.visit_Assign">visit_Assign</a></td>
345 <td>Public method to handle assignments.</td>
346 </tr>
347 <tr>
348 <td><a href="#BugBearVisitor.visit_AsyncFor">visit_AsyncFor</a></td>
349 <td>Public method to handle 'for' statements.</td>
350 </tr>
351 <tr>
352 <td><a href="#BugBearVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
353 <td>Public method to handle async function definitions.</td>
354 </tr>
355 <tr>
356 <td><a href="#BugBearVisitor.visit_Call">visit_Call</a></td>
357 <td>Public method to handle a function call.</td>
358 </tr>
359 <tr>
360 <td><a href="#BugBearVisitor.visit_ClassDef">visit_ClassDef</a></td>
361 <td>Public method to handle class definitions.</td>
362 </tr>
363 <tr>
364 <td><a href="#BugBearVisitor.visit_Compare">visit_Compare</a></td>
365 <td>Public method to handle comparison statements.</td>
366 </tr>
367 <tr>
368 <td><a href="#BugBearVisitor.visit_Dict">visit_Dict</a></td>
369 <td>Public method to check a dictionary.</td>
370 </tr>
371 <tr>
372 <td><a href="#BugBearVisitor.visit_DictComp">visit_DictComp</a></td>
373 <td>Public method to handle dictionary comprehensions.</td>
374 </tr>
375 <tr>
376 <td><a href="#BugBearVisitor.visit_ExceptHandler">visit_ExceptHandler</a></td>
377 <td>Public method to handle exception handlers.</td>
378 </tr>
379 <tr>
380 <td><a href="#BugBearVisitor.visit_For">visit_For</a></td>
381 <td>Public method to handle 'for' statements.</td>
382 </tr>
383 <tr>
384 <td><a href="#BugBearVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
385 <td>Public method to handle function definitions.</td>
386 </tr>
387 <tr>
388 <td><a href="#BugBearVisitor.visit_GeneratorExp">visit_GeneratorExp</a></td>
389 <td>Public method to handle generator expressions.</td>
390 </tr>
391 <tr>
392 <td><a href="#BugBearVisitor.visit_Import">visit_Import</a></td>
393 <td>Public method to check imports.</td>
394 </tr>
395 <tr>
396 <td><a href="#BugBearVisitor.visit_ImportFrom">visit_ImportFrom</a></td>
397 <td>Public method to check from imports.</td>
398 </tr>
399 <tr>
400 <td><a href="#BugBearVisitor.visit_JoinedStr">visit_JoinedStr</a></td>
401 <td>Public method to handle f-string arguments.</td>
402 </tr>
403 <tr>
404 <td><a href="#BugBearVisitor.visit_ListComp">visit_ListComp</a></td>
405 <td>Public method to handle list comprehensions.</td>
406 </tr>
407 <tr>
408 <td><a href="#BugBearVisitor.visit_Module">visit_Module</a></td>
409 <td>Public method to handle a module node.</td>
410 </tr>
411 <tr>
412 <td><a href="#BugBearVisitor.visit_Raise">visit_Raise</a></td>
413 <td>Public method to handle 'raise' statements.</td>
414 </tr>
415 <tr>
416 <td><a href="#BugBearVisitor.visit_Return">visit_Return</a></td>
417 <td>Public method to handle 'Return' nodes.</td>
418 </tr>
419 <tr>
420 <td><a href="#BugBearVisitor.visit_Set">visit_Set</a></td>
421 <td>Public method to check a set.</td>
422 </tr>
423 <tr>
424 <td><a href="#BugBearVisitor.visit_SetComp">visit_SetComp</a></td>
425 <td>Public method to handle set comprehensions.</td>
426 </tr>
427 <tr>
428 <td><a href="#BugBearVisitor.visit_Try">visit_Try</a></td>
429 <td>Public method to handle 'try' statements.</td>
430 </tr>
431 <tr>
432 <td><a href="#BugBearVisitor.visit_TryStar">visit_TryStar</a></td>
433 <td>Public method to handle 'except*' statements.</td>
434 </tr>
435 <tr>
436 <td><a href="#BugBearVisitor.visit_UAdd">visit_UAdd</a></td>
437 <td>Public method to handle unary additions.</td>
438 </tr>
439 <tr>
440 <td><a href="#BugBearVisitor.visit_While">visit_While</a></td>
441 <td>Public method to handle 'while' statements.</td>
442 </tr>
443 <tr>
444 <td><a href="#BugBearVisitor.visit_With">visit_With</a></td>
445 <td>Public method to handle 'with' statements.</td>
446 </tr>
447 <tr>
448 <td><a href="#BugBearVisitor.visit_Yield">visit_Yield</a></td>
449 <td>Public method to handle 'Yield' nodes.</td>
450 </tr>
451 <tr>
452 <td><a href="#BugBearVisitor.visit_YieldFrom">visit_YieldFrom</a></td>
453 <td>Public method to handle 'YieldFrom' nodes.</td>
454 </tr>
455 </table>
456
457 <h3>Static Methods</h3>
458 <table>
459 <tr><td>None</td></tr>
460 </table>
461
462
463 <a NAME="BugBearVisitor.__init__" ID="BugBearVisitor.__init__"></a>
464 <h4>BugBearVisitor (Constructor)</h4>
465 <b>BugBearVisitor</b>(<i></i>)
466 <p>
467 Constructor
468 </p>
469
470 <a NAME="BugBearVisitor.__checkForM505" ID="BugBearVisitor.__checkForM505"></a>
471 <h4>BugBearVisitor.__checkForM505</h4>
472 <b>__checkForM505</b>(<i>node</i>)
473 <p>
474 Private method to check the use of *strip().
475 </p>
476
477 <dl>
478
479 <dt><i>node</i> (ast.Call)</dt>
480 <dd>
481 reference to the node to be processed
482 </dd>
483 </dl>
484 <a NAME="BugBearVisitor.__checkForM506_M508" ID="BugBearVisitor.__checkForM506_M508"></a>
485 <h4>BugBearVisitor.__checkForM506_M508</h4>
486 <b>__checkForM506_M508</b>(<i>node</i>)
487 <p>
488 Private method to check the use of mutable literals, comprehensions and calls.
489 </p>
490
491 <dl>
492
493 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
494 <dd>
495 reference to the node to be processed
496 </dd>
497 </dl>
498 <a NAME="BugBearVisitor.__checkForM507" ID="BugBearVisitor.__checkForM507"></a>
499 <h4>BugBearVisitor.__checkForM507</h4>
500 <b>__checkForM507</b>(<i>node</i>)
501 <p>
502 Private method to check for unused loop variables.
503 </p>
504
505 <dl>
506
507 <dt><i>node</i> (ast.For or ast.AsyncFor)</dt>
508 <dd>
509 reference to the node to be processed
510 </dd>
511 </dl>
512 <a NAME="BugBearVisitor.__checkForM512" ID="BugBearVisitor.__checkForM512"></a>
513 <h4>BugBearVisitor.__checkForM512</h4>
514 <b>__checkForM512</b>(<i>node</i>)
515 <p>
516 Private method to check for return/continue/break inside finally blocks.
517 </p>
518
519 <dl>
520
521 <dt><i>node</i> (ast.Try)</dt>
522 <dd>
523 reference to the node to be processed
524 </dd>
525 </dl>
526 <a NAME="BugBearVisitor.__checkForM513_M514_M529_M530" ID="BugBearVisitor.__checkForM513_M514_M529_M530"></a>
527 <h4>BugBearVisitor.__checkForM513_M514_M529_M530</h4>
528 <b>__checkForM513_M514_M529_M530</b>(<i>node</i>)
529 <p>
530 Private method to check various exception handler situations.
531 </p>
532
533 <dl>
534
535 <dt><i>node</i> (ast.ExceptHandler)</dt>
536 <dd>
537 reference to the node to be processed
538 </dd>
539 </dl>
540 <dl>
541 <dt>Return:</dt>
542 <dd>
543 list of exception handler names
544 </dd>
545 </dl>
546 <dl>
547 <dt>Return Type:</dt>
548 <dd>
549 list of str
550 </dd>
551 </dl>
552 <a NAME="BugBearVisitor.__checkForM515" ID="BugBearVisitor.__checkForM515"></a>
553 <h4>BugBearVisitor.__checkForM515</h4>
554 <b>__checkForM515</b>(<i>node</i>)
555 <p>
556 Private method to check for pointless comparisons.
557 </p>
558
559 <dl>
560
561 <dt><i>node</i> (ast.Compare)</dt>
562 <dd>
563 reference to the node to be processed
564 </dd>
565 </dl>
566 <a NAME="BugBearVisitor.__checkForM516" ID="BugBearVisitor.__checkForM516"></a>
567 <h4>BugBearVisitor.__checkForM516</h4>
568 <b>__checkForM516</b>(<i>node</i>)
569 <p>
570 Private method to check for raising a literal instead of an exception.
571 </p>
572
573 <dl>
574
575 <dt><i>node</i> (ast.Raise)</dt>
576 <dd>
577 reference to the node to be processed
578 </dd>
579 </dl>
580 <a NAME="BugBearVisitor.__checkForM517" ID="BugBearVisitor.__checkForM517"></a>
581 <h4>BugBearVisitor.__checkForM517</h4>
582 <b>__checkForM517</b>(<i>node</i>)
583 <p>
584 Private method to check for use of the evil syntax
585 'with assertRaises(Exception): or 'with pytest.raises(Exception):'.
586 </p>
587
588 <dl>
589
590 <dt><i>node</i> (ast.With)</dt>
591 <dd>
592 reference to the node to be processed
593 </dd>
594 </dl>
595 <a NAME="BugBearVisitor.__checkForM518" ID="BugBearVisitor.__checkForM518"></a>
596 <h4>BugBearVisitor.__checkForM518</h4>
597 <b>__checkForM518</b>(<i>node</i>)
598 <p>
599 Private method to check for useless expressions.
600 </p>
601
602 <dl>
603
604 <dt><i>node</i> (ast.FunctionDef)</dt>
605 <dd>
606 reference to the node to be processed
607 </dd>
608 </dl>
609 <a NAME="BugBearVisitor.__checkForM519" ID="BugBearVisitor.__checkForM519"></a>
610 <h4>BugBearVisitor.__checkForM519</h4>
611 <b>__checkForM519</b>(<i>node</i>)
612 <p>
613 Private method to check for use of 'functools.lru_cache' or 'functools.cache'.
614 </p>
615
616 <dl>
617
618 <dt><i>node</i> (ast.FunctionDef)</dt>
619 <dd>
620 reference to the node to be processed
621 </dd>
622 </dl>
623 <a NAME="BugBearVisitor.__checkForM520" ID="BugBearVisitor.__checkForM520"></a>
624 <h4>BugBearVisitor.__checkForM520</h4>
625 <b>__checkForM520</b>(<i>node</i>)
626 <p>
627 Private method to check for a loop that modifies its iterable.
628 </p>
629
630 <dl>
631
632 <dt><i>node</i> (ast.For or ast.AsyncFor)</dt>
633 <dd>
634 reference to the node to be processed
635 </dd>
636 </dl>
637 <a NAME="BugBearVisitor.__checkForM521" ID="BugBearVisitor.__checkForM521"></a>
638 <h4>BugBearVisitor.__checkForM521</h4>
639 <b>__checkForM521</b>(<i>node</i>)
640 <p>
641 Private method to check for use of an f-string as docstring.
642 </p>
643
644 <dl>
645
646 <dt><i>node</i> (ast.FunctionDef or ast.ClassDef)</dt>
647 <dd>
648 reference to the node to be processed
649 </dd>
650 </dl>
651 <a NAME="BugBearVisitor.__checkForM522" ID="BugBearVisitor.__checkForM522"></a>
652 <h4>BugBearVisitor.__checkForM522</h4>
653 <b>__checkForM522</b>(<i>node</i>)
654 <p>
655 Private method to check for use of an f-string as docstring.
656 </p>
657
658 <dl>
659
660 <dt><i>node</i> (ast.With)</dt>
661 <dd>
662 reference to the node to be processed
663 </dd>
664 </dl>
665 <a NAME="BugBearVisitor.__checkForM523" ID="BugBearVisitor.__checkForM523"></a>
666 <h4>BugBearVisitor.__checkForM523</h4>
667 <b>__checkForM523</b>(<i>loopNode</i>)
668 <p>
669 Private method to check that functions (including lambdas) do not use loop
670 variables.
671 </p>
672
673 <dl>
674
675 <dt><i>loopNode</i> (ast.For, ast.AsyncFor, ast.While, ast.ListComp, ast.SetComp,ast.DictComp,)</dt>
676 <dd>
677 reference to the node to be processed
678 or ast.GeneratorExp
679 </dd>
680 </dl>
681 <a NAME="BugBearVisitor.__checkForM524_M527" ID="BugBearVisitor.__checkForM524_M527"></a>
682 <h4>BugBearVisitor.__checkForM524_M527</h4>
683 <b>__checkForM524_M527</b>(<i>node</i>)
684 <p>
685 Private method to check for inheritance from abstract classes in abc and lack of
686 any methods decorated with abstract*.
687 </p>
688
689 <dl>
690
691 <dt><i>node</i> (ast.ClassDef)</dt>
692 <dd>
693 reference to the node to be processed
694 </dd>
695 </dl>
696 <a NAME="BugBearVisitor.__checkForM525" ID="BugBearVisitor.__checkForM525"></a>
697 <h4>BugBearVisitor.__checkForM525</h4>
698 <b>__checkForM525</b>(<i>node</i>)
699 <p>
700 Private method to check for exceptions being handled multiple times.
701 </p>
702
703 <dl>
704
705 <dt><i>node</i> (ast.Try)</dt>
706 <dd>
707 reference to the node to be processed
708 </dd>
709 </dl>
710 <a NAME="BugBearVisitor.__checkForM526" ID="BugBearVisitor.__checkForM526"></a>
711 <h4>BugBearVisitor.__checkForM526</h4>
712 <b>__checkForM526</b>(<i>node</i>)
713 <p>
714 Private method to check for Star-arg unpacking after keyword argument.
715 </p>
716
717 <dl>
718
719 <dt><i>node</i> (ast.Call)</dt>
720 <dd>
721 reference to the node to be processed
722 </dd>
723 </dl>
724 <a NAME="BugBearVisitor.__checkForM528" ID="BugBearVisitor.__checkForM528"></a>
725 <h4>BugBearVisitor.__checkForM528</h4>
726 <b>__checkForM528</b>(<i>node</i>)
727 <p>
728 Private method to check for warn without stacklevel.
729 </p>
730
731 <dl>
732
733 <dt><i>node</i> (ast.Call)</dt>
734 <dd>
735 reference to the node to be processed
736 </dd>
737 </dl>
738 <a NAME="BugBearVisitor.__checkForM531" ID="BugBearVisitor.__checkForM531"></a>
739 <h4>BugBearVisitor.__checkForM531</h4>
740 <b>__checkForM531</b>(<i>loopNode</i>)
741 <p>
742 Private method to check that 'itertools.groupby' isn't iterated over more than
743 once.
744 </p>
745 <p>
746 A warning is emitted when the generator returned by 'groupby()' is used
747 more than once inside a loop body or when it's used in a nested loop.
748 </p>
749
750 <dl>
751
752 <dt><i>loopNode</i> (ast.For or ast.AsyncFor)</dt>
753 <dd>
754 reference to the node to be processed
755 </dd>
756 </dl>
757 <a NAME="BugBearVisitor.__checkForM532" ID="BugBearVisitor.__checkForM532"></a>
758 <h4>BugBearVisitor.__checkForM532</h4>
759 <b>__checkForM532</b>(<i>node</i>)
760 <p>
761 Private method to check for possible unintentional typing annotation.
762 </p>
763
764 <dl>
765
766 <dt><i>node</i> (ast.AnnAssign)</dt>
767 <dd>
768 reference to the node to be processed
769 </dd>
770 </dl>
771 <a NAME="BugBearVisitor.__checkForM533" ID="BugBearVisitor.__checkForM533"></a>
772 <h4>BugBearVisitor.__checkForM533</h4>
773 <b>__checkForM533</b>(<i>node</i>)
774 <p>
775 Private method to check a set for duplicate items.
776 </p>
777
778 <dl>
779
780 <dt><i>node</i> (ast.Set)</dt>
781 <dd>
782 reference to the node to be processed
783 </dd>
784 </dl>
785 <a NAME="BugBearVisitor.__checkForM534" ID="BugBearVisitor.__checkForM534"></a>
786 <h4>BugBearVisitor.__checkForM534</h4>
787 <b>__checkForM534</b>(<i>node</i>)
788 <p>
789 Private method to check that re.sub/subn/split arguments flags/count/maxsplit
790 are passed as keyword arguments.
791 </p>
792
793 <dl>
794
795 <dt><i>node</i> (ast.Call)</dt>
796 <dd>
797 reference to the node to be processed
798 </dd>
799 </dl>
800 <a NAME="BugBearVisitor.__checkForM535" ID="BugBearVisitor.__checkForM535"></a>
801 <h4>BugBearVisitor.__checkForM535</h4>
802 <b>__checkForM535</b>(<i>node</i>)
803 <p>
804 Private method to check that a static key isn't used in a dict comprehension.
805 </p>
806 <p>
807 Record a warning if a likely unchanging key is used - either a constant,
808 or a variable that isn't coming from the generator expression.
809 </p>
810
811 <dl>
812
813 <dt><i>node</i> (ast.DictComp)</dt>
814 <dd>
815 reference to the node to be processed
816 </dd>
817 </dl>
818 <a NAME="BugBearVisitor.__checkForM539" ID="BugBearVisitor.__checkForM539"></a>
819 <h4>BugBearVisitor.__checkForM539</h4>
820 <b>__checkForM539</b>(<i>node</i>)
821 <p>
822 Private method to check for correct ContextVar usage.
823 </p>
824
825 <dl>
826
827 <dt><i>node</i> (ast.Call)</dt>
828 <dd>
829 reference to the node to be processed
830 </dd>
831 </dl>
832 <a NAME="BugBearVisitor.__checkForM540AddNote" ID="BugBearVisitor.__checkForM540AddNote"></a>
833 <h4>BugBearVisitor.__checkForM540AddNote</h4>
834 <b>__checkForM540AddNote</b>(<i>node</i>)
835 <p>
836 Private method to check add_note usage.
837 </p>
838
839 <dl>
840
841 <dt><i>node</i> (ast.Attribute)</dt>
842 <dd>
843 reference to the node to be processed
844 </dd>
845 </dl>
846 <dl>
847 <dt>Return:</dt>
848 <dd>
849 flag
850 </dd>
851 </dl>
852 <dl>
853 <dt>Return Type:</dt>
854 <dd>
855 bool
856 </dd>
857 </dl>
858 <a NAME="BugBearVisitor.__checkForM540Usage" ID="BugBearVisitor.__checkForM540Usage"></a>
859 <h4>BugBearVisitor.__checkForM540Usage</h4>
860 <b>__checkForM540Usage</b>(<i>node</i>)
861 <p>
862 Private method to check the usage of exceptions with added note.
863 </p>
864
865 <dl>
866
867 <dt><i>node</i> (ast.expr or None)</dt>
868 <dd>
869 reference to the node to be processed
870 </dd>
871 </dl>
872 <a NAME="BugBearVisitor.__checkForM541" ID="BugBearVisitor.__checkForM541"></a>
873 <h4>BugBearVisitor.__checkForM541</h4>
874 <b>__checkForM541</b>(<i>node</i>)
875 <p>
876 Private method to check for duplicate key value pairs in a dictionary literal.
877 </p>
878
879 <dl>
880
881 <dt><i>node</i> (ast.Dict)</dt>
882 <dd>
883 reference to the node to be processed
884 </dd>
885 </dl>
886 <a NAME="BugBearVisitor.__checkForM569" ID="BugBearVisitor.__checkForM569"></a>
887 <h4>BugBearVisitor.__checkForM569</h4>
888 <b>__checkForM569</b>(<i>node</i>)
889 <p>
890 Private method to check for changes to a loop's mutable iterable.
891 </p>
892
893 <dl>
894
895 <dt><i>node</i> (ast.For)</dt>
896 <dd>
897 loop node to be checked
898 </dd>
899 </dl>
900 <a NAME="BugBearVisitor.__checkRedundantExcepthandlers" ID="BugBearVisitor.__checkRedundantExcepthandlers"></a>
901 <h4>BugBearVisitor.__checkRedundantExcepthandlers</h4>
902 <b>__checkRedundantExcepthandlers</b>(<i>names, node, inTryStar</i>)
903 <p>
904 Private method to check for redundant exception types in an exception handler.
905 </p>
906
907 <dl>
908
909 <dt><i>names</i> (list of ast.Name)</dt>
910 <dd>
911 list of exception types to be checked
912 </dd>
913 <dt><i>node</i> (ast.ExceptionHandler)</dt>
914 <dd>
915 reference to the exception handler node
916 </dd>
917 <dt><i>inTryStar</i> (str)</dt>
918 <dd>
919 character indicating an 'except*' handler
920 </dd>
921 </dl>
922 <dl>
923 <dt>Return:</dt>
924 <dd>
925 tuple containing the error data
926 </dd>
927 </dl>
928 <dl>
929 <dt>Return Type:</dt>
930 <dd>
931 tuple of (ast.Node, str, str, str, str)
932 </dd>
933 </dl>
934 <a NAME="BugBearVisitor.__childrenInScope" ID="BugBearVisitor.__childrenInScope"></a>
935 <h4>BugBearVisitor.__childrenInScope</h4>
936 <b>__childrenInScope</b>(<i>node</i>)
937 <p>
938 Private method to get all child nodes in the given scope.
939 </p>
940
941 <dl>
942
943 <dt><i>node</i> (ast.Node)</dt>
944 <dd>
945 reference to the node to be processed
946 </dd>
947 </dl>
948 <dl>
949 <dt>Yield:</dt>
950 <dd>
951 reference to a child node
952 </dd>
953 </dl>
954 <dl>
955 <dt>Yield Type:</dt>
956 <dd>
957 ast.Node
958 </dd>
959 </dl>
960 <a NAME="BugBearVisitor.__flattenExcepthandler" ID="BugBearVisitor.__flattenExcepthandler"></a>
961 <h4>BugBearVisitor.__flattenExcepthandler</h4>
962 <b>__flattenExcepthandler</b>(<i>node</i>)
963 <p>
964 Private method to flatten the list of exceptions handled by an except handler.
965 </p>
966
967 <dl>
968
969 <dt><i>node</i> (ast.Node)</dt>
970 <dd>
971 reference to the node to be processed
972 </dd>
973 </dl>
974 <dl>
975 <dt>Yield:</dt>
976 <dd>
977 reference to the exception type node
978 </dd>
979 </dl>
980 <dl>
981 <dt>Yield Type:</dt>
982 <dd>
983 ast.Node
984 </dd>
985 </dl>
986 <a NAME="BugBearVisitor.__getAssignedNames" ID="BugBearVisitor.__getAssignedNames"></a>
987 <h4>BugBearVisitor.__getAssignedNames</h4>
988 <b>__getAssignedNames</b>(<i>loopNode</i>)
989 <p>
990 Private method to get the names of a for loop.
991 </p>
992
993 <dl>
994
995 <dt><i>loopNode</i> (ast.For)</dt>
996 <dd>
997 reference to the node to be processed
998 </dd>
999 </dl>
1000 <dl>
1001 <dt>Yield:</dt>
1002 <dd>
1003 DESCRIPTION
1004 </dd>
1005 </dl>
1006 <dl>
1007 <dt>Yield Type:</dt>
1008 <dd>
1009 TYPE
1010 </dd>
1011 </dl>
1012 <a NAME="BugBearVisitor.__getDictCompLoopAndNamedExprVarNames" ID="BugBearVisitor.__getDictCompLoopAndNamedExprVarNames"></a>
1013 <h4>BugBearVisitor.__getDictCompLoopAndNamedExprVarNames</h4>
1014 <b>__getDictCompLoopAndNamedExprVarNames</b>(<i>node</i>)
1015 <p>
1016 Private method to get the names of comprehension loop variables.
1017 </p>
1018
1019 <dl>
1020
1021 <dt><i>node</i> (ast.DictComp)</dt>
1022 <dd>
1023 ast node to be processed
1024 </dd>
1025 </dl>
1026 <dl>
1027 <dt>Yield:</dt>
1028 <dd>
1029 loop variable names
1030 </dd>
1031 </dl>
1032 <dl>
1033 <dt>Yield Type:</dt>
1034 <dd>
1035 str
1036 </dd>
1037 </dl>
1038 <a NAME="BugBearVisitor.__getNamesFromTuple" ID="BugBearVisitor.__getNamesFromTuple"></a>
1039 <h4>BugBearVisitor.__getNamesFromTuple</h4>
1040 <b>__getNamesFromTuple</b>(<i>node</i>)
1041 <p>
1042 Private method to get the names from an ast.Tuple node.
1043 </p>
1044
1045 <dl>
1046
1047 <dt><i>node</i> (ast.Tuple)</dt>
1048 <dd>
1049 ast node to be processed
1050 </dd>
1051 </dl>
1052 <dl>
1053 <dt>Yield:</dt>
1054 <dd>
1055 names
1056 </dd>
1057 </dl>
1058 <dl>
1059 <dt>Yield Type:</dt>
1060 <dd>
1061 str
1062 </dd>
1063 </dl>
1064 <a NAME="BugBearVisitor.__inClassInit" ID="BugBearVisitor.__inClassInit"></a>
1065 <h4>BugBearVisitor.__inClassInit</h4>
1066 <b>__inClassInit</b>(<i></i>)
1067 <p>
1068 Private method to check, if we are inside an '__init__' method.
1069 </p>
1070
1071 <dl>
1072 <dt>Return:</dt>
1073 <dd>
1074 flag indicating being within the '__init__' method
1075 </dd>
1076 </dl>
1077 <dl>
1078 <dt>Return Type:</dt>
1079 <dd>
1080 bool
1081 </dd>
1082 </dl>
1083 <a NAME="BugBearVisitor.__isIdentifier" ID="BugBearVisitor.__isIdentifier"></a>
1084 <h4>BugBearVisitor.__isIdentifier</h4>
1085 <b>__isIdentifier</b>(<i>arg</i>)
1086 <p>
1087 Private method to check if arg is a valid identifier.
1088 </p>
1089 <p>
1090 See https://docs.python.org/2/reference/lexical_analysis.html#identifiers
1091 </p>
1092
1093 <dl>
1094
1095 <dt><i>arg</i> (ast.Node)</dt>
1096 <dd>
1097 reference to an argument node
1098 </dd>
1099 </dl>
1100 <dl>
1101 <dt>Return:</dt>
1102 <dd>
1103 flag indicating a valid identifier
1104 </dd>
1105 </dl>
1106 <dl>
1107 <dt>Return Type:</dt>
1108 <dd>
1109 TYPE
1110 </dd>
1111 </dl>
1112 <a NAME="BugBearVisitor.__namesFromAssignments" ID="BugBearVisitor.__namesFromAssignments"></a>
1113 <h4>BugBearVisitor.__namesFromAssignments</h4>
1114 <b>__namesFromAssignments</b>(<i>assignTarget</i>)
1115 <p>
1116 Private method to get names of an assignment.
1117 </p>
1118
1119 <dl>
1120
1121 <dt><i>assignTarget</i> (ast.Node)</dt>
1122 <dd>
1123 reference to the node to be processed
1124 </dd>
1125 </dl>
1126 <dl>
1127 <dt>Yield:</dt>
1128 <dd>
1129 name of the assignment
1130 </dd>
1131 </dl>
1132 <dl>
1133 <dt>Yield Type:</dt>
1134 <dd>
1135 str
1136 </dd>
1137 </dl>
1138 <a NAME="BugBearVisitor.__typesafeIssubclass" ID="BugBearVisitor.__typesafeIssubclass"></a>
1139 <h4>BugBearVisitor.__typesafeIssubclass</h4>
1140 <b>__typesafeIssubclass</b>(<i>obj, classOrTuple</i>)
1141 <p>
1142 Private method implementing a type safe issubclass() function.
1143 </p>
1144
1145 <dl>
1146
1147 <dt><i>obj</i> (Any)</dt>
1148 <dd>
1149 reference to the object to be tested
1150 </dd>
1151 <dt><i>classOrTuple</i> (type)</dt>
1152 <dd>
1153 type to check against
1154 </dd>
1155 </dl>
1156 <dl>
1157 <dt>Return:</dt>
1158 <dd>
1159 flag indicating a subclass
1160 </dd>
1161 </dl>
1162 <dl>
1163 <dt>Return Type:</dt>
1164 <dd>
1165 bool
1166 </dd>
1167 </dl>
1168 <a NAME="BugBearVisitor.__walkList" ID="BugBearVisitor.__walkList"></a>
1169 <h4>BugBearVisitor.__walkList</h4>
1170 <b>__walkList</b>(<i>nodes</i>)
1171 <p>
1172 Private method to walk a given list of nodes.
1173 </p>
1174
1175 <dl>
1176
1177 <dt><i>nodes</i> (list of ast.Node)</dt>
1178 <dd>
1179 list of nodes to walk
1180 </dd>
1181 </dl>
1182 <dl>
1183 <dt>Yield:</dt>
1184 <dd>
1185 node references as determined by the ast.walk() function
1186 </dd>
1187 </dl>
1188 <dl>
1189 <dt>Yield Type:</dt>
1190 <dd>
1191 ast.Node
1192 </dd>
1193 </dl>
1194 <a NAME="BugBearVisitor._loop" ID="BugBearVisitor._loop"></a>
1195 <h4>BugBearVisitor._loop</h4>
1196 <b>_loop</b>(<i>badNodeTypes</i>)
1197
1198 <a NAME="BugBearVisitor.check" ID="BugBearVisitor.check"></a>
1199 <h4>BugBearVisitor.check</h4>
1200 <b>check</b>(<i>paramName</i>)
1201
1202 <a NAME="BugBearVisitor.convertToValue" ID="BugBearVisitor.convertToValue"></a>
1203 <h4>BugBearVisitor.convertToValue</h4>
1204 <b>convertToValue</b>(<i></i>)
1205 <p>
1206 Function to extract the value of a given item.
1207 </p>
1208
1209 <dl>
1210
1211 <dt><i>item</i> (ast.Ast)</dt>
1212 <dd>
1213 node to extract value from
1214 </dd>
1215 </dl>
1216 <dl>
1217 <dt>Return:</dt>
1218 <dd>
1219 value of the node
1220 </dd>
1221 </dl>
1222 <dl>
1223 <dt>Return Type:</dt>
1224 <dd>
1225 Any
1226 </dd>
1227 </dl>
1228 <a NAME="BugBearVisitor.emptyBody" ID="BugBearVisitor.emptyBody"></a>
1229 <h4>BugBearVisitor.emptyBody</h4>
1230 <b>emptyBody</b>(<i></i>)
1231
1232 <a NAME="BugBearVisitor.isAbcClass" ID="BugBearVisitor.isAbcClass"></a>
1233 <h4>BugBearVisitor.isAbcClass</h4>
1234 <b>isAbcClass</b>(<i>name="ABC"</i>)
1235
1236 <a NAME="BugBearVisitor.isAbstractDecorator" ID="BugBearVisitor.isAbstractDecorator"></a>
1237 <h4>BugBearVisitor.isAbstractDecorator</h4>
1238 <b>isAbstractDecorator</b>(<i></i>)
1239
1240 <a NAME="BugBearVisitor.isOverload" ID="BugBearVisitor.isOverload"></a>
1241 <h4>BugBearVisitor.isOverload</h4>
1242 <b>isOverload</b>(<i></i>)
1243
1244 <a NAME="BugBearVisitor.isStrOrEllipsis" ID="BugBearVisitor.isStrOrEllipsis"></a>
1245 <h4>BugBearVisitor.isStrOrEllipsis</h4>
1246 <b>isStrOrEllipsis</b>(<i></i>)
1247
1248 <a NAME="BugBearVisitor.nodeStack" ID="BugBearVisitor.nodeStack"></a>
1249 <h4>BugBearVisitor.nodeStack</h4>
1250 <b>nodeStack</b>(<i></i>)
1251 <p>
1252 Public method to get a reference to the most recent node stack.
1253 </p>
1254
1255 <dl>
1256 <dt>Return:</dt>
1257 <dd>
1258 reference to the most recent node stack
1259 </dd>
1260 </dl>
1261 <dl>
1262 <dt>Return Type:</dt>
1263 <dd>
1264 list
1265 </dd>
1266 </dl>
1267 <a NAME="BugBearVisitor.superwalk" ID="BugBearVisitor.superwalk"></a>
1268 <h4>BugBearVisitor.superwalk</h4>
1269 <b>superwalk</b>(<i></i>)
1270 <p>
1271 Function to walk an AST node or a list of AST nodes.
1272 </p>
1273
1274 <dl>
1275
1276 <dt><i>node</i> (ast.AST or list[ast.AST])</dt>
1277 <dd>
1278 reference to the node or a list of nodes to be processed
1279 </dd>
1280 </dl>
1281 <dl>
1282 <dt>Yield:</dt>
1283 <dd>
1284 next node to be processed
1285 </dd>
1286 </dl>
1287 <dl>
1288 <dt>Yield Type:</dt>
1289 <dd>
1290 ast.AST
1291 </dd>
1292 </dl>
1293 <a NAME="BugBearVisitor.toNameStr" ID="BugBearVisitor.toNameStr"></a>
1294 <h4>BugBearVisitor.toNameStr</h4>
1295 <b>toNameStr</b>(<i>node</i>)
1296 <p>
1297 Public method to turn Name and Attribute nodes to strings, handling any
1298 depth of attribute accesses.
1299 </p>
1300 <p>
1301
1302 </p>
1303
1304 <dl>
1305
1306 <dt><i>node</i> (ast.Name or ast.Attribute)</dt>
1307 <dd>
1308 reference to the node
1309 </dd>
1310 </dl>
1311 <dl>
1312 <dt>Return:</dt>
1313 <dd>
1314 string representation
1315 </dd>
1316 </dl>
1317 <dl>
1318 <dt>Return Type:</dt>
1319 <dd>
1320 str
1321 </dd>
1322 </dl>
1323 <a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a>
1324 <h4>BugBearVisitor.visit</h4>
1325 <b>visit</b>(<i>node</i>)
1326 <p>
1327 Public method to traverse a given AST node.
1328 </p>
1329
1330 <dl>
1331
1332 <dt><i>node</i> (ast.Node)</dt>
1333 <dd>
1334 AST node to be traversed
1335 </dd>
1336 </dl>
1337 <a NAME="BugBearVisitor.visit_AnnAssign" ID="BugBearVisitor.visit_AnnAssign"></a>
1338 <h4>BugBearVisitor.visit_AnnAssign</h4>
1339 <b>visit_AnnAssign</b>(<i>node</i>)
1340 <p>
1341 Public method to check annotated assign statements.
1342 </p>
1343
1344 <dl>
1345
1346 <dt><i>node</i> (ast.AnnAssign)</dt>
1347 <dd>
1348 reference to the node to be processed
1349 </dd>
1350 </dl>
1351 <a NAME="BugBearVisitor.visit_Assert" ID="BugBearVisitor.visit_Assert"></a>
1352 <h4>BugBearVisitor.visit_Assert</h4>
1353 <b>visit_Assert</b>(<i>node</i>)
1354 <p>
1355 Public method to handle 'assert' statements.
1356 </p>
1357
1358 <dl>
1359
1360 <dt><i>node</i> (ast.Assert)</dt>
1361 <dd>
1362 reference to the node to be processed
1363 </dd>
1364 </dl>
1365 <a NAME="BugBearVisitor.visit_Assign" ID="BugBearVisitor.visit_Assign"></a>
1366 <h4>BugBearVisitor.visit_Assign</h4>
1367 <b>visit_Assign</b>(<i>node</i>)
1368 <p>
1369 Public method to handle assignments.
1370 </p>
1371
1372 <dl>
1373
1374 <dt><i>node</i> (ast.Assign)</dt>
1375 <dd>
1376 reference to the node to be processed
1377 </dd>
1378 </dl>
1379 <a NAME="BugBearVisitor.visit_AsyncFor" ID="BugBearVisitor.visit_AsyncFor"></a>
1380 <h4>BugBearVisitor.visit_AsyncFor</h4>
1381 <b>visit_AsyncFor</b>(<i>node</i>)
1382 <p>
1383 Public method to handle 'for' statements.
1384 </p>
1385
1386 <dl>
1387
1388 <dt><i>node</i> (ast.AsyncFor)</dt>
1389 <dd>
1390 reference to the node to be processed
1391 </dd>
1392 </dl>
1393 <a NAME="BugBearVisitor.visit_AsyncFunctionDef" ID="BugBearVisitor.visit_AsyncFunctionDef"></a>
1394 <h4>BugBearVisitor.visit_AsyncFunctionDef</h4>
1395 <b>visit_AsyncFunctionDef</b>(<i>node</i>)
1396 <p>
1397 Public method to handle async function definitions.
1398 </p>
1399
1400 <dl>
1401
1402 <dt><i>node</i> (ast.AsyncFunctionDef)</dt>
1403 <dd>
1404 reference to the node to be processed
1405 </dd>
1406 </dl>
1407 <a NAME="BugBearVisitor.visit_Call" ID="BugBearVisitor.visit_Call"></a>
1408 <h4>BugBearVisitor.visit_Call</h4>
1409 <b>visit_Call</b>(<i>node</i>)
1410 <p>
1411 Public method to handle a function call.
1412 </p>
1413
1414 <dl>
1415
1416 <dt><i>node</i> (ast.Call)</dt>
1417 <dd>
1418 reference to the node to be processed
1419 </dd>
1420 </dl>
1421 <a NAME="BugBearVisitor.visit_ClassDef" ID="BugBearVisitor.visit_ClassDef"></a>
1422 <h4>BugBearVisitor.visit_ClassDef</h4>
1423 <b>visit_ClassDef</b>(<i>node</i>)
1424 <p>
1425 Public method to handle class definitions.
1426 </p>
1427
1428 <dl>
1429
1430 <dt><i>node</i> (ast.ClassDef)</dt>
1431 <dd>
1432 reference to the node to be processed
1433 </dd>
1434 </dl>
1435 <a NAME="BugBearVisitor.visit_Compare" ID="BugBearVisitor.visit_Compare"></a>
1436 <h4>BugBearVisitor.visit_Compare</h4>
1437 <b>visit_Compare</b>(<i>node</i>)
1438 <p>
1439 Public method to handle comparison statements.
1440 </p>
1441
1442 <dl>
1443
1444 <dt><i>node</i> (ast.Compare)</dt>
1445 <dd>
1446 reference to the node to be processed
1447 </dd>
1448 </dl>
1449 <a NAME="BugBearVisitor.visit_Dict" ID="BugBearVisitor.visit_Dict"></a>
1450 <h4>BugBearVisitor.visit_Dict</h4>
1451 <b>visit_Dict</b>(<i>node</i>)
1452 <p>
1453 Public method to check a dictionary.
1454 </p>
1455
1456 <dl>
1457
1458 <dt><i>node</i> (ast.Dict)</dt>
1459 <dd>
1460 reference to the node to be processed
1461 </dd>
1462 </dl>
1463 <a NAME="BugBearVisitor.visit_DictComp" ID="BugBearVisitor.visit_DictComp"></a>
1464 <h4>BugBearVisitor.visit_DictComp</h4>
1465 <b>visit_DictComp</b>(<i>node</i>)
1466 <p>
1467 Public method to handle dictionary comprehensions.
1468 </p>
1469
1470 <dl>
1471
1472 <dt><i>node</i> (ast.DictComp)</dt>
1473 <dd>
1474 reference to the node to be processed
1475 </dd>
1476 </dl>
1477 <a NAME="BugBearVisitor.visit_ExceptHandler" ID="BugBearVisitor.visit_ExceptHandler"></a>
1478 <h4>BugBearVisitor.visit_ExceptHandler</h4>
1479 <b>visit_ExceptHandler</b>(<i>node</i>)
1480 <p>
1481 Public method to handle exception handlers.
1482 </p>
1483
1484 <dl>
1485
1486 <dt><i>node</i> (ast.ExceptHandler)</dt>
1487 <dd>
1488 reference to the node to be processed
1489 </dd>
1490 </dl>
1491 <a NAME="BugBearVisitor.visit_For" ID="BugBearVisitor.visit_For"></a>
1492 <h4>BugBearVisitor.visit_For</h4>
1493 <b>visit_For</b>(<i>node</i>)
1494 <p>
1495 Public method to handle 'for' statements.
1496 </p>
1497
1498 <dl>
1499
1500 <dt><i>node</i> (ast.For)</dt>
1501 <dd>
1502 reference to the node to be processed
1503 </dd>
1504 </dl>
1505 <a NAME="BugBearVisitor.visit_FunctionDef" ID="BugBearVisitor.visit_FunctionDef"></a>
1506 <h4>BugBearVisitor.visit_FunctionDef</h4>
1507 <b>visit_FunctionDef</b>(<i>node</i>)
1508 <p>
1509 Public method to handle function definitions.
1510 </p>
1511
1512 <dl>
1513
1514 <dt><i>node</i> (ast.FunctionDef)</dt>
1515 <dd>
1516 reference to the node to be processed
1517 </dd>
1518 </dl>
1519 <a NAME="BugBearVisitor.visit_GeneratorExp" ID="BugBearVisitor.visit_GeneratorExp"></a>
1520 <h4>BugBearVisitor.visit_GeneratorExp</h4>
1521 <b>visit_GeneratorExp</b>(<i>node</i>)
1522 <p>
1523 Public method to handle generator expressions.
1524 </p>
1525
1526 <dl>
1527
1528 <dt><i>node</i> (ast.GeneratorExp)</dt>
1529 <dd>
1530 reference to the node to be processed
1531 </dd>
1532 </dl>
1533 <a NAME="BugBearVisitor.visit_Import" ID="BugBearVisitor.visit_Import"></a>
1534 <h4>BugBearVisitor.visit_Import</h4>
1535 <b>visit_Import</b>(<i>node</i>)
1536 <p>
1537 Public method to check imports.
1538 </p>
1539
1540 <dl>
1541
1542 <dt><i>node</i> (ast.Import)</dt>
1543 <dd>
1544 reference to the node to be processed
1545 </dd>
1546 </dl>
1547 <a NAME="BugBearVisitor.visit_ImportFrom" ID="BugBearVisitor.visit_ImportFrom"></a>
1548 <h4>BugBearVisitor.visit_ImportFrom</h4>
1549 <b>visit_ImportFrom</b>(<i>node</i>)
1550 <p>
1551 Public method to check from imports.
1552 </p>
1553
1554 <dl>
1555
1556 <dt><i>node</i> (ast.Import)</dt>
1557 <dd>
1558 reference to the node to be processed
1559 </dd>
1560 </dl>
1561 <a NAME="BugBearVisitor.visit_JoinedStr" ID="BugBearVisitor.visit_JoinedStr"></a>
1562 <h4>BugBearVisitor.visit_JoinedStr</h4>
1563 <b>visit_JoinedStr</b>(<i>node</i>)
1564 <p>
1565 Public method to handle f-string arguments.
1566 </p>
1567
1568 <dl>
1569
1570 <dt><i>node</i> (ast.JoinedStr)</dt>
1571 <dd>
1572 reference to the node to be processed
1573 </dd>
1574 </dl>
1575 <a NAME="BugBearVisitor.visit_ListComp" ID="BugBearVisitor.visit_ListComp"></a>
1576 <h4>BugBearVisitor.visit_ListComp</h4>
1577 <b>visit_ListComp</b>(<i>node</i>)
1578 <p>
1579 Public method to handle list comprehensions.
1580 </p>
1581
1582 <dl>
1583
1584 <dt><i>node</i> (ast.ListComp)</dt>
1585 <dd>
1586 reference to the node to be processed
1587 </dd>
1588 </dl>
1589 <a NAME="BugBearVisitor.visit_Module" ID="BugBearVisitor.visit_Module"></a>
1590 <h4>BugBearVisitor.visit_Module</h4>
1591 <b>visit_Module</b>(<i>node</i>)
1592 <p>
1593 Public method to handle a module node.
1594 </p>
1595
1596 <dl>
1597
1598 <dt><i>node</i> (ast.Module)</dt>
1599 <dd>
1600 reference to the node to be processed
1601 </dd>
1602 </dl>
1603 <a NAME="BugBearVisitor.visit_Raise" ID="BugBearVisitor.visit_Raise"></a>
1604 <h4>BugBearVisitor.visit_Raise</h4>
1605 <b>visit_Raise</b>(<i>node</i>)
1606 <p>
1607 Public method to handle 'raise' statements.
1608 </p>
1609
1610 <dl>
1611
1612 <dt><i>node</i> (ast.Raise)</dt>
1613 <dd>
1614 reference to the node to be processed
1615 </dd>
1616 </dl>
1617 <a NAME="BugBearVisitor.visit_Return" ID="BugBearVisitor.visit_Return"></a>
1618 <h4>BugBearVisitor.visit_Return</h4>
1619 <b>visit_Return</b>(<i>node</i>)
1620 <p>
1621 Public method to handle 'Return' nodes.
1622 </p>
1623
1624 <dl>
1625
1626 <dt><i>node</i> (ast.Return)</dt>
1627 <dd>
1628 reference to the node to be processed
1629 </dd>
1630 </dl>
1631 <a NAME="BugBearVisitor.visit_Set" ID="BugBearVisitor.visit_Set"></a>
1632 <h4>BugBearVisitor.visit_Set</h4>
1633 <b>visit_Set</b>(<i>node</i>)
1634 <p>
1635 Public method to check a set.
1636 </p>
1637
1638 <dl>
1639
1640 <dt><i>node</i> (ast.Set)</dt>
1641 <dd>
1642 reference to the node to be processed
1643 </dd>
1644 </dl>
1645 <a NAME="BugBearVisitor.visit_SetComp" ID="BugBearVisitor.visit_SetComp"></a>
1646 <h4>BugBearVisitor.visit_SetComp</h4>
1647 <b>visit_SetComp</b>(<i>node</i>)
1648 <p>
1649 Public method to handle set comprehensions.
1650 </p>
1651
1652 <dl>
1653
1654 <dt><i>node</i> (ast.SetComp)</dt>
1655 <dd>
1656 reference to the node to be processed
1657 </dd>
1658 </dl>
1659 <a NAME="BugBearVisitor.visit_Try" ID="BugBearVisitor.visit_Try"></a>
1660 <h4>BugBearVisitor.visit_Try</h4>
1661 <b>visit_Try</b>(<i>node</i>)
1662 <p>
1663 Public method to handle 'try' statements.
1664 </p>
1665
1666 <dl>
1667
1668 <dt><i>node</i> (ast.Try)</dt>
1669 <dd>
1670 reference to the node to be processed
1671 </dd>
1672 </dl>
1673 <a NAME="BugBearVisitor.visit_TryStar" ID="BugBearVisitor.visit_TryStar"></a>
1674 <h4>BugBearVisitor.visit_TryStar</h4>
1675 <b>visit_TryStar</b>(<i>node</i>)
1676 <p>
1677 Public method to handle 'except*' statements.
1678 </p>
1679
1680 <dl>
1681
1682 <dt><i>node</i> (ast.TryStar)</dt>
1683 <dd>
1684 reference to the node to be processed
1685 </dd>
1686 </dl>
1687 <a NAME="BugBearVisitor.visit_UAdd" ID="BugBearVisitor.visit_UAdd"></a>
1688 <h4>BugBearVisitor.visit_UAdd</h4>
1689 <b>visit_UAdd</b>(<i>node</i>)
1690 <p>
1691 Public method to handle unary additions.
1692 </p>
1693
1694 <dl>
1695
1696 <dt><i>node</i> (ast.UAdd)</dt>
1697 <dd>
1698 reference to the node to be processed
1699 </dd>
1700 </dl>
1701 <a NAME="BugBearVisitor.visit_While" ID="BugBearVisitor.visit_While"></a>
1702 <h4>BugBearVisitor.visit_While</h4>
1703 <b>visit_While</b>(<i>node</i>)
1704 <p>
1705 Public method to handle 'while' statements.
1706 </p>
1707
1708 <dl>
1709
1710 <dt><i>node</i> (ast.While)</dt>
1711 <dd>
1712 reference to the node to be processed
1713 </dd>
1714 </dl>
1715 <a NAME="BugBearVisitor.visit_With" ID="BugBearVisitor.visit_With"></a>
1716 <h4>BugBearVisitor.visit_With</h4>
1717 <b>visit_With</b>(<i>node</i>)
1718 <p>
1719 Public method to handle 'with' statements.
1720 </p>
1721
1722 <dl>
1723
1724 <dt><i>node</i> (ast.With)</dt>
1725 <dd>
1726 reference to the node to be processed
1727 </dd>
1728 </dl>
1729 <a NAME="BugBearVisitor.visit_Yield" ID="BugBearVisitor.visit_Yield"></a>
1730 <h4>BugBearVisitor.visit_Yield</h4>
1731 <b>visit_Yield</b>(<i>node</i>)
1732 <p>
1733 Public method to handle 'Yield' nodes.
1734 </p>
1735
1736 <dl>
1737
1738 <dt><i>node</i> (ast.Yield)</dt>
1739 <dd>
1740 reference to the node to be processed
1741 </dd>
1742 </dl>
1743 <a NAME="BugBearVisitor.visit_YieldFrom" ID="BugBearVisitor.visit_YieldFrom"></a>
1744 <h4>BugBearVisitor.visit_YieldFrom</h4>
1745 <b>visit_YieldFrom</b>(<i>node</i>)
1746 <p>
1747 Public method to handle 'YieldFrom' nodes.
1748 </p>
1749
1750 <dl>
1751
1752 <dt><i>node</i> (ast.YieldFrom)</dt>
1753 <dd>
1754 reference to the node to be processed
1755 </dd>
1756 </dl>
1757 <div align="right"><a href="#top">Up</a></div>
1758 <hr />
1759 <hr />
1760 <a NAME="DateTimeVisitor" ID="DateTimeVisitor"></a>
1761 <h2>DateTimeVisitor</h2>
1762 <p>
1763 Class implementing a node visitor to check datetime function calls.
1764 </p>
1765 <p>
1766 Note: This class is modeled after flake8_datetimez checker.
1767 </p>
1768
1769 <h3>Derived from</h3>
1770 ast.NodeVisitor
1771 <h3>Class Attributes</h3>
1772 <table>
1773 <tr><td>None</td></tr>
1774 </table>
1775
1776 <h3>Class Methods</h3>
1777 <table>
1778 <tr><td>None</td></tr>
1779 </table>
1780
1781 <h3>Methods</h3>
1782 <table>
1783 <tr>
1784 <td><a href="#DateTimeVisitor.__init__">DateTimeVisitor</a></td>
1785 <td>Constructor</td>
1786 </tr>
1787 <tr>
1788 <td><a href="#DateTimeVisitor.__getFromKeywords">__getFromKeywords</a></td>
1789 <td>Private method to get a keyword node given its name.</td>
1790 </tr>
1791 <tr>
1792 <td><a href="#DateTimeVisitor.visit_Call">visit_Call</a></td>
1793 <td>Public method to handle a function call.</td>
1794 </tr>
1795 </table>
1796
1797 <h3>Static Methods</h3>
1798 <table>
1799 <tr><td>None</td></tr>
1800 </table>
1801
1802
1803 <a NAME="DateTimeVisitor.__init__" ID="DateTimeVisitor.__init__"></a>
1804 <h4>DateTimeVisitor (Constructor)</h4>
1805 <b>DateTimeVisitor</b>(<i></i>)
1806 <p>
1807 Constructor
1808 </p>
1809
1810 <a NAME="DateTimeVisitor.__getFromKeywords" ID="DateTimeVisitor.__getFromKeywords"></a>
1811 <h4>DateTimeVisitor.__getFromKeywords</h4>
1812 <b>__getFromKeywords</b>(<i>keywords, name</i>)
1813 <p>
1814 Private method to get a keyword node given its name.
1815 </p>
1816
1817 <dl>
1818
1819 <dt><i>keywords</i> (list of ast.AST)</dt>
1820 <dd>
1821 list of keyword argument nodes
1822 </dd>
1823 <dt><i>name</i> (str)</dt>
1824 <dd>
1825 name of the keyword node
1826 </dd>
1827 </dl>
1828 <dl>
1829 <dt>Return:</dt>
1830 <dd>
1831 keyword node
1832 </dd>
1833 </dl>
1834 <dl>
1835 <dt>Return Type:</dt>
1836 <dd>
1837 ast.AST
1838 </dd>
1839 </dl>
1840 <a NAME="DateTimeVisitor.visit_Call" ID="DateTimeVisitor.visit_Call"></a>
1841 <h4>DateTimeVisitor.visit_Call</h4>
1842 <b>visit_Call</b>(<i>node</i>)
1843 <p>
1844 Public method to handle a function call.
1845 </p>
1846 <p>
1847 Every datetime related function call is check for use of the naive
1848 variant (i.e. use without TZ info).
1849 </p>
1850
1851 <dl>
1852
1853 <dt><i>node</i> (ast.Call)</dt>
1854 <dd>
1855 reference to the node to be processed
1856 </dd>
1857 </dl>
1858 <div align="right"><a href="#top">Up</a></div>
1859 <hr />
1860 <hr />
1861 <a NAME="DefaultMatchCaseVisitor" ID="DefaultMatchCaseVisitor"></a>
1862 <h2>DefaultMatchCaseVisitor</h2>
1863 <p>
1864 Class implementing a node visitor to check default match cases.
1865 </p>
1866 <p>
1867 Note: This class is modeled after flake8-spm v0.0.1.
1868 </p>
1869
1870 <h3>Derived from</h3>
1871 ast.NodeVisitor
1872 <h3>Class Attributes</h3>
1873 <table>
1874 <tr><td>None</td></tr>
1875 </table>
1876
1877 <h3>Class Methods</h3>
1878 <table>
1879 <tr><td>None</td></tr>
1880 </table>
1881
1882 <h3>Methods</h3>
1883 <table>
1884 <tr>
1885 <td><a href="#DefaultMatchCaseVisitor.__init__">DefaultMatchCaseVisitor</a></td>
1886 <td>Constructor</td>
1887 </tr>
1888 <tr>
1889 <td><a href="#DefaultMatchCaseVisitor.__badNodes">__badNodes</a></td>
1890 <td>Private method to yield bad match nodes.</td>
1891 </tr>
1892 <tr>
1893 <td><a href="#DefaultMatchCaseVisitor.__emptyMatchDefault">__emptyMatchDefault</a></td>
1894 <td>Private method to check for an empty default match case.</td>
1895 </tr>
1896 <tr>
1897 <td><a href="#DefaultMatchCaseVisitor.__findBadNode">__findBadNode</a></td>
1898 <td>Private method returning a reference to the bad node of a case node.</td>
1899 </tr>
1900 <tr>
1901 <td><a href="#DefaultMatchCaseVisitor.__lastStatementDoesNotRaise">__lastStatementDoesNotRaise</a></td>
1902 <td>Private method to check that the last case statement does not raise an exception.</td>
1903 </tr>
1904 <tr>
1905 <td><a href="#DefaultMatchCaseVisitor.__returnPrecedesExceptionRaising">__returnPrecedesExceptionRaising</a></td>
1906 <td>Private method to check that no return precedes an exception raising.</td>
1907 </tr>
1908 <tr>
1909 <td><a href="#DefaultMatchCaseVisitor.visit_Match">visit_Match</a></td>
1910 <td>Public method to handle Match nodes.</td>
1911 </tr>
1912 </table>
1913
1914 <h3>Static Methods</h3>
1915 <table>
1916 <tr><td>None</td></tr>
1917 </table>
1918
1919
1920 <a NAME="DefaultMatchCaseVisitor.__init__" ID="DefaultMatchCaseVisitor.__init__"></a>
1921 <h4>DefaultMatchCaseVisitor (Constructor)</h4>
1922 <b>DefaultMatchCaseVisitor</b>(<i></i>)
1923 <p>
1924 Constructor
1925 </p>
1926
1927 <a NAME="DefaultMatchCaseVisitor.__badNodes" ID="DefaultMatchCaseVisitor.__badNodes"></a>
1928 <h4>DefaultMatchCaseVisitor.__badNodes</h4>
1929 <b>__badNodes</b>(<i>node</i>)
1930 <p>
1931 Private method to yield bad match nodes.
1932 </p>
1933
1934 <dl>
1935
1936 <dt><i>node</i> (ast.Match)</dt>
1937 <dd>
1938 reference to the node to be processed
1939 </dd>
1940 </dl>
1941 <dl>
1942 <dt>Yield:</dt>
1943 <dd>
1944 tuple containing a reference to bad match case node and the corresponding
1945 issue code
1946 </dd>
1947 </dl>
1948 <dl>
1949 <dt>Yield Type:</dt>
1950 <dd>
1951 tyuple of (ast.AST, str)
1952 </dd>
1953 </dl>
1954 <a NAME="DefaultMatchCaseVisitor.__emptyMatchDefault" ID="DefaultMatchCaseVisitor.__emptyMatchDefault"></a>
1955 <h4>DefaultMatchCaseVisitor.__emptyMatchDefault</h4>
1956 <b>__emptyMatchDefault</b>(<i>case</i>)
1957 <p>
1958 Private method to check for an empty default match case.
1959 </p>
1960
1961 <dl>
1962
1963 <dt><i>case</i> (ast.match_case)</dt>
1964 <dd>
1965 reference to the node to be processed
1966 </dd>
1967 </dl>
1968 <dl>
1969 <dt>Return:</dt>
1970 <dd>
1971 flag indicating an empty default match case
1972 </dd>
1973 </dl>
1974 <dl>
1975 <dt>Return Type:</dt>
1976 <dd>
1977 bool
1978 </dd>
1979 </dl>
1980 <a NAME="DefaultMatchCaseVisitor.__findBadNode" ID="DefaultMatchCaseVisitor.__findBadNode"></a>
1981 <h4>DefaultMatchCaseVisitor.__findBadNode</h4>
1982 <b>__findBadNode</b>(<i>case</i>)
1983 <p>
1984 Private method returning a reference to the bad node of a case node.
1985 </p>
1986
1987 <dl>
1988
1989 <dt><i>case</i> (ast.match_case)</dt>
1990 <dd>
1991 reference to the node to be processed
1992 </dd>
1993 </dl>
1994 <dl>
1995 <dt>Return:</dt>
1996 <dd>
1997 reference to the bad node
1998 </dd>
1999 </dl>
2000 <dl>
2001 <dt>Return Type:</dt>
2002 <dd>
2003 ast.AST
2004 </dd>
2005 </dl>
2006 <a NAME="DefaultMatchCaseVisitor.__lastStatementDoesNotRaise" ID="DefaultMatchCaseVisitor.__lastStatementDoesNotRaise"></a>
2007 <h4>DefaultMatchCaseVisitor.__lastStatementDoesNotRaise</h4>
2008 <b>__lastStatementDoesNotRaise</b>(<i>case</i>)
2009 <p>
2010 Private method to check that the last case statement does not raise an
2011 exception.
2012 </p>
2013
2014 <dl>
2015
2016 <dt><i>case</i> (ast.match_case)</dt>
2017 <dd>
2018 reference to the node to be processed
2019 </dd>
2020 </dl>
2021 <dl>
2022 <dt>Return:</dt>
2023 <dd>
2024 flag indicating that the last case statement does not raise an
2025 exception
2026 </dd>
2027 </dl>
2028 <dl>
2029 <dt>Return Type:</dt>
2030 <dd>
2031 bool
2032 </dd>
2033 </dl>
2034 <a NAME="DefaultMatchCaseVisitor.__returnPrecedesExceptionRaising" ID="DefaultMatchCaseVisitor.__returnPrecedesExceptionRaising"></a>
2035 <h4>DefaultMatchCaseVisitor.__returnPrecedesExceptionRaising</h4>
2036 <b>__returnPrecedesExceptionRaising</b>(<i>case</i>)
2037 <p>
2038 Private method to check that no return precedes an exception raising.
2039 </p>
2040
2041 <dl>
2042
2043 <dt><i>case</i> (ast.match_case)</dt>
2044 <dd>
2045 reference to the node to be processed
2046 </dd>
2047 </dl>
2048 <dl>
2049 <dt>Return:</dt>
2050 <dd>
2051 flag indicating that a return precedes an exception raising
2052 </dd>
2053 </dl>
2054 <dl>
2055 <dt>Return Type:</dt>
2056 <dd>
2057 bool
2058 </dd>
2059 </dl>
2060 <a NAME="DefaultMatchCaseVisitor.visit_Match" ID="DefaultMatchCaseVisitor.visit_Match"></a>
2061 <h4>DefaultMatchCaseVisitor.visit_Match</h4>
2062 <b>visit_Match</b>(<i>node</i>)
2063 <p>
2064 Public method to handle Match nodes.
2065 </p>
2066
2067 <dl>
2068
2069 <dt><i>node</i> (ast.Match)</dt>
2070 <dd>
2071 reference to the node to be processed
2072 </dd>
2073 </dl>
2074 <div align="right"><a href="#top">Up</a></div>
2075 <hr />
2076 <hr />
2077 <a NAME="ExceptBaseExceptionVisitor" ID="ExceptBaseExceptionVisitor"></a>
2078 <h2>ExceptBaseExceptionVisitor</h2>
2079 <p>
2080 Class to determine, if a 'BaseException' is re-raised.
2081 </p>
2082
2083 <h3>Derived from</h3>
2084 ast.NodeVisitor
2085 <h3>Class Attributes</h3>
2086 <table>
2087 <tr><td>None</td></tr>
2088 </table>
2089
2090 <h3>Class Methods</h3>
2091 <table>
2092 <tr><td>None</td></tr>
2093 </table>
2094
2095 <h3>Methods</h3>
2096 <table>
2097 <tr>
2098 <td><a href="#ExceptBaseExceptionVisitor.__init__">ExceptBaseExceptionVisitor</a></td>
2099 <td>Constructor</td>
2100 </tr>
2101 <tr>
2102 <td><a href="#ExceptBaseExceptionVisitor.reRaised">reRaised</a></td>
2103 <td>Public method to check, if the exception is re-raised.</td>
2104 </tr>
2105 <tr>
2106 <td><a href="#ExceptBaseExceptionVisitor.visit_ExceptHandler">visit_ExceptHandler</a></td>
2107 <td>Public method to handle 'ExceptHandler' nodes.</td>
2108 </tr>
2109 <tr>
2110 <td><a href="#ExceptBaseExceptionVisitor.visit_Raise">visit_Raise</a></td>
2111 <td>Public method to handle 'Raise' nodes.</td>
2112 </tr>
2113 </table>
2114
2115 <h3>Static Methods</h3>
2116 <table>
2117 <tr><td>None</td></tr>
2118 </table>
2119
2120
2121 <a NAME="ExceptBaseExceptionVisitor.__init__" ID="ExceptBaseExceptionVisitor.__init__"></a>
2122 <h4>ExceptBaseExceptionVisitor (Constructor)</h4>
2123 <b>ExceptBaseExceptionVisitor</b>(<i>exceptNode</i>)
2124 <p>
2125 Constructor
2126 </p>
2127
2128 <dl>
2129
2130 <dt><i>exceptNode</i> (ast.ExceptHandler)</dt>
2131 <dd>
2132 exception node to be inspected
2133 </dd>
2134 </dl>
2135 <a NAME="ExceptBaseExceptionVisitor.reRaised" ID="ExceptBaseExceptionVisitor.reRaised"></a>
2136 <h4>ExceptBaseExceptionVisitor.reRaised</h4>
2137 <b>reRaised</b>(<i></i>)
2138 <p>
2139 Public method to check, if the exception is re-raised.
2140 </p>
2141
2142 <dl>
2143 <dt>Return:</dt>
2144 <dd>
2145 flag indicating a re-raised exception
2146 </dd>
2147 </dl>
2148 <dl>
2149 <dt>Return Type:</dt>
2150 <dd>
2151 bool
2152 </dd>
2153 </dl>
2154 <a NAME="ExceptBaseExceptionVisitor.visit_ExceptHandler" ID="ExceptBaseExceptionVisitor.visit_ExceptHandler"></a>
2155 <h4>ExceptBaseExceptionVisitor.visit_ExceptHandler</h4>
2156 <b>visit_ExceptHandler</b>(<i>node: ast.ExceptHandler</i>)
2157 <p>
2158 Public method to handle 'ExceptHandler' nodes.
2159 </p>
2160
2161 <dl>
2162
2163 <dt><i>node</i> (ast.ExceptHandler)</dt>
2164 <dd>
2165 reference to the node to be processed
2166 </dd>
2167 </dl>
2168 <a NAME="ExceptBaseExceptionVisitor.visit_Raise" ID="ExceptBaseExceptionVisitor.visit_Raise"></a>
2169 <h4>ExceptBaseExceptionVisitor.visit_Raise</h4>
2170 <b>visit_Raise</b>(<i>node</i>)
2171 <p>
2172 Public method to handle 'Raise' nodes.
2173 </p>
2174 <p>
2175 If we find a corresponding `raise` or `raise e` where e was from
2176 `except BaseException as e:` then we mark re_raised as True and can
2177 stop scanning.
2178 </p>
2179
2180 <dl>
2181
2182 <dt><i>node</i> (ast.Raise)</dt>
2183 <dd>
2184 reference to the node to be processed
2185 </dd>
2186 </dl>
2187 <div align="right"><a href="#top">Up</a></div>
2188 <hr />
2189 <hr />
2190 <a NAME="FunctionDefDefaultsVisitor" ID="FunctionDefDefaultsVisitor"></a>
2191 <h2>FunctionDefDefaultsVisitor</h2>
2192 <p>
2193 Class used by M506, M508 and M539.
2194 </p>
2195
2196 <h3>Derived from</h3>
2197 ast.NodeVisitor
2198 <h3>Class Attributes</h3>
2199 <table>
2200 <tr><td>None</td></tr>
2201 </table>
2202
2203 <h3>Class Methods</h3>
2204 <table>
2205 <tr><td>None</td></tr>
2206 </table>
2207
2208 <h3>Methods</h3>
2209 <table>
2210 <tr>
2211 <td><a href="#FunctionDefDefaultsVisitor.__init__">FunctionDefDefaultsVisitor</a></td>
2212 <td>Constructor</td>
2213 </tr>
2214 <tr>
2215 <td><a href="#FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension">__visitMutableLiteralOrComprehension</a></td>
2216 <td>Private method to flag mutable literals and comprehensions.</td>
2217 </tr>
2218 <tr>
2219 <td><a href="#FunctionDefDefaultsVisitor.visit">visit</a></td>
2220 <td>Public method to traverse an AST node or a list of AST nodes.</td>
2221 </tr>
2222 <tr>
2223 <td><a href="#FunctionDefDefaultsVisitor.visit_Call">visit_Call</a></td>
2224 <td>Public method to process Call nodes.</td>
2225 </tr>
2226 <tr>
2227 <td><a href="#FunctionDefDefaultsVisitor.visit_Lambda">visit_Lambda</a></td>
2228 <td>Public method to process Lambda nodes.</td>
2229 </tr>
2230 </table>
2231
2232 <h3>Static Methods</h3>
2233 <table>
2234 <tr><td>None</td></tr>
2235 </table>
2236
2237
2238 <a NAME="FunctionDefDefaultsVisitor.__init__" ID="FunctionDefDefaultsVisitor.__init__"></a>
2239 <h4>FunctionDefDefaultsVisitor (Constructor)</h4>
2240 <b>FunctionDefDefaultsVisitor</b>(<i>errorCodeCalls, errorCodeLiterals, </i>)
2241 <p>
2242 Constructor
2243 </p>
2244
2245 <dl>
2246
2247 <dt><i>errorCodeCalls</i> (str)</dt>
2248 <dd>
2249 error code for ast.Call nodes
2250 </dd>
2251 <dt><i>errorCodeLiterals</i> (str)</dt>
2252 <dd>
2253 error code for literal nodes
2254 </dd>
2255 </dl>
2256 <a NAME="FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension" ID="FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension"></a>
2257 <h4>FunctionDefDefaultsVisitor.__visitMutableLiteralOrComprehension</h4>
2258 <b>__visitMutableLiteralOrComprehension</b>(<i>node</i>)
2259 <p>
2260 Private method to flag mutable literals and comprehensions.
2261 </p>
2262
2263 <dl>
2264
2265 <dt><i>node</i> (ast.Dict, ast.List, ast.Set, ast.ListComp, ast.DictComp or ast.SetComp)</dt>
2266 <dd>
2267 AST node to be processed
2268 </dd>
2269 </dl>
2270 <a NAME="FunctionDefDefaultsVisitor.visit" ID="FunctionDefDefaultsVisitor.visit"></a>
2271 <h4>FunctionDefDefaultsVisitor.visit</h4>
2272 <b>visit</b>(<i>node</i>)
2273 <p>
2274 Public method to traverse an AST node or a list of AST nodes.
2275 </p>
2276 <p>
2277 This is an extended method that can also handle a list of AST nodes.
2278 </p>
2279
2280 <dl>
2281
2282 <dt><i>node</i> (ast.AST or list of ast.AST)</dt>
2283 <dd>
2284 AST node or list of AST nodes to be processed
2285 </dd>
2286 </dl>
2287 <a NAME="FunctionDefDefaultsVisitor.visit_Call" ID="FunctionDefDefaultsVisitor.visit_Call"></a>
2288 <h4>FunctionDefDefaultsVisitor.visit_Call</h4>
2289 <b>visit_Call</b>(<i>node</i>)
2290 <p>
2291 Public method to process Call nodes.
2292 </p>
2293
2294 <dl>
2295
2296 <dt><i>node</i> (ast.Call)</dt>
2297 <dd>
2298 AST node to be processed
2299 </dd>
2300 </dl>
2301 <a NAME="FunctionDefDefaultsVisitor.visit_Lambda" ID="FunctionDefDefaultsVisitor.visit_Lambda"></a>
2302 <h4>FunctionDefDefaultsVisitor.visit_Lambda</h4>
2303 <b>visit_Lambda</b>(<i>node</i>)
2304 <p>
2305 Public method to process Lambda nodes.
2306 </p>
2307
2308 <dl>
2309
2310 <dt><i>node</i> (ast.Lambda)</dt>
2311 <dd>
2312 AST node to be processed
2313 </dd>
2314 </dl>
2315 <div align="right"><a href="#top">Up</a></div>
2316 <hr />
2317 <hr />
2318 <a NAME="M520NameFinder" ID="M520NameFinder"></a>
2319 <h2>M520NameFinder</h2>
2320 <p>
2321 Class to extract a name out of a tree of nodes ignoring names defined within the
2322 local scope of a comprehension.
2323 </p>
2324
2325 <h3>Derived from</h3>
2326 NameFinder
2327 <h3>Class Attributes</h3>
2328 <table>
2329 <tr><td>None</td></tr>
2330 </table>
2331
2332 <h3>Class Methods</h3>
2333 <table>
2334 <tr><td>None</td></tr>
2335 </table>
2336
2337 <h3>Methods</h3>
2338 <table>
2339 <tr>
2340 <td><a href="#M520NameFinder.visit_DictComp">visit_DictComp</a></td>
2341 <td>Public method to handle a dictionary comprehension.</td>
2342 </tr>
2343 <tr>
2344 <td><a href="#M520NameFinder.visit_GeneratorExp">visit_GeneratorExp</a></td>
2345 <td>Public method to handle a generator expressions.</td>
2346 </tr>
2347 <tr>
2348 <td><a href="#M520NameFinder.visit_Lambda">visit_Lambda</a></td>
2349 <td>Public method to handle a Lambda function.</td>
2350 </tr>
2351 <tr>
2352 <td><a href="#M520NameFinder.visit_ListComp">visit_ListComp</a></td>
2353 <td>Public method to handle a list comprehension.</td>
2354 </tr>
2355 <tr>
2356 <td><a href="#M520NameFinder.visit_comprehension">visit_comprehension</a></td>
2357 <td>Public method to handle the 'for' of a comprehension.</td>
2358 </tr>
2359 </table>
2360
2361 <h3>Static Methods</h3>
2362 <table>
2363 <tr><td>None</td></tr>
2364 </table>
2365
2366
2367 <a NAME="M520NameFinder.visit_DictComp" ID="M520NameFinder.visit_DictComp"></a>
2368 <h4>M520NameFinder.visit_DictComp</h4>
2369 <b>visit_DictComp</b>(<i>node</i>)
2370 <p>
2371 Public method to handle a dictionary comprehension.
2372 </p>
2373
2374 <dl>
2375
2376 <dt><i>node</i> (TYPE)</dt>
2377 <dd>
2378 reference to the node to be processed
2379 </dd>
2380 </dl>
2381 <a NAME="M520NameFinder.visit_GeneratorExp" ID="M520NameFinder.visit_GeneratorExp"></a>
2382 <h4>M520NameFinder.visit_GeneratorExp</h4>
2383 <b>visit_GeneratorExp</b>(<i>node</i>)
2384 <p>
2385 Public method to handle a generator expressions.
2386 </p>
2387
2388 <dl>
2389
2390 <dt><i>node</i> (ast.GeneratorExp)</dt>
2391 <dd>
2392 reference to the node to be processed
2393 </dd>
2394 </dl>
2395 <a NAME="M520NameFinder.visit_Lambda" ID="M520NameFinder.visit_Lambda"></a>
2396 <h4>M520NameFinder.visit_Lambda</h4>
2397 <b>visit_Lambda</b>(<i>node</i>)
2398 <p>
2399 Public method to handle a Lambda function.
2400 </p>
2401
2402 <dl>
2403
2404 <dt><i>node</i> (ast.Lambda)</dt>
2405 <dd>
2406 reference to the node to be processed
2407 </dd>
2408 </dl>
2409 <a NAME="M520NameFinder.visit_ListComp" ID="M520NameFinder.visit_ListComp"></a>
2410 <h4>M520NameFinder.visit_ListComp</h4>
2411 <b>visit_ListComp</b>(<i>node</i>)
2412 <p>
2413 Public method to handle a list comprehension.
2414 </p>
2415
2416 <dl>
2417
2418 <dt><i>node</i> (TYPE)</dt>
2419 <dd>
2420 reference to the node to be processed
2421 </dd>
2422 </dl>
2423 <a NAME="M520NameFinder.visit_comprehension" ID="M520NameFinder.visit_comprehension"></a>
2424 <h4>M520NameFinder.visit_comprehension</h4>
2425 <b>visit_comprehension</b>(<i>node</i>)
2426 <p>
2427 Public method to handle the 'for' of a comprehension.
2428 </p>
2429
2430 <dl>
2431
2432 <dt><i>node</i> (ast.comprehension)</dt>
2433 <dd>
2434 reference to the node to be processed
2435 </dd>
2436 </dl>
2437 <div align="right"><a href="#top">Up</a></div>
2438 <hr />
2439 <hr />
2440 <a NAME="M540CaughtException" ID="M540CaughtException"></a>
2441 <h2>M540CaughtException</h2>
2442 <p>
2443 Class to hold the data for a caught exception.
2444 </p>
2445
2446 <h3>Derived from</h3>
2447 None
2448 <h3>Class Attributes</h3>
2449 <table>
2450 <tr><td>hasNote</td></tr>
2451 <tr><td>name</td></tr>
2452 </table>
2453
2454 <h3>Class Methods</h3>
2455 <table>
2456 <tr><td>None</td></tr>
2457 </table>
2458
2459 <h3>Methods</h3>
2460 <table>
2461 <tr><td>None</td></tr>
2462 </table>
2463
2464 <h3>Static Methods</h3>
2465 <table>
2466 <tr><td>None</td></tr>
2467 </table>
2468
2469
2470 <div align="right"><a href="#top">Up</a></div>
2471 <hr />
2472 <hr />
2473 <a NAME="M541UnhandledKeyType" ID="M541UnhandledKeyType"></a>
2474 <h2>M541UnhandledKeyType</h2>
2475 <p>
2476 Class to hold a dictionary key of a type that we do not check for duplicates.
2477 </p>
2478
2479 <h3>Derived from</h3>
2480 None
2481 <h3>Class Attributes</h3>
2482 <table>
2483 <tr><td>None</td></tr>
2484 </table>
2485
2486 <h3>Class Methods</h3>
2487 <table>
2488 <tr><td>None</td></tr>
2489 </table>
2490
2491 <h3>Methods</h3>
2492 <table>
2493 <tr><td>None</td></tr>
2494 </table>
2495
2496 <h3>Static Methods</h3>
2497 <table>
2498 <tr><td>None</td></tr>
2499 </table>
2500
2501
2502 <div align="right"><a href="#top">Up</a></div>
2503 <hr />
2504 <hr />
2505 <a NAME="M541VariableKeyType" ID="M541VariableKeyType"></a>
2506 <h2>M541VariableKeyType</h2>
2507 <p>
2508 Class to hold the name of a variable key type.
2509 </p>
2510
2511 <h3>Derived from</h3>
2512 None
2513 <h3>Class Attributes</h3>
2514 <table>
2515 <tr><td>None</td></tr>
2516 </table>
2517
2518 <h3>Class Methods</h3>
2519 <table>
2520 <tr><td>None</td></tr>
2521 </table>
2522
2523 <h3>Methods</h3>
2524 <table>
2525 <tr>
2526 <td><a href="#M541VariableKeyType.__init__">M541VariableKeyType</a></td>
2527 <td>Constructor</td>
2528 </tr>
2529 </table>
2530
2531 <h3>Static Methods</h3>
2532 <table>
2533 <tr><td>None</td></tr>
2534 </table>
2535
2536
2537 <a NAME="M541VariableKeyType.__init__" ID="M541VariableKeyType.__init__"></a>
2538 <h4>M541VariableKeyType (Constructor)</h4>
2539 <b>M541VariableKeyType</b>(<i>name</i>)
2540 <p>
2541 Constructor
2542 </p>
2543
2544 <dl>
2545
2546 <dt><i>name</i> (str)</dt>
2547 <dd>
2548 name of the variable key type
2549 </dd>
2550 </dl>
2551 <div align="right"><a href="#top">Up</a></div>
2552 <hr />
2553 <hr />
2554 <a NAME="M569Checker" ID="M569Checker"></a>
2555 <h2>M569Checker</h2>
2556 <p>
2557 Class traversing a 'for' loop body to check for modifications to a loop's
2558 mutable iterable.
2559 </p>
2560
2561 <h3>Derived from</h3>
2562 ast.NodeVisitor
2563 <h3>Class Attributes</h3>
2564 <table>
2565 <tr><td>MUTATING_FUNCTIONS</td></tr>
2566 </table>
2567
2568 <h3>Class Methods</h3>
2569 <table>
2570 <tr><td>None</td></tr>
2571 </table>
2572
2573 <h3>Methods</h3>
2574 <table>
2575 <tr>
2576 <td><a href="#M569Checker.__init__">M569Checker</a></td>
2577 <td>Constructor</td>
2578 </tr>
2579 <tr>
2580 <td><a href="#M569Checker.visit">visit</a></td>
2581 <td>Public method to inspect an ast node.</td>
2582 </tr>
2583 <tr>
2584 <td><a href="#M569Checker.visit_Call">visit_Call</a></td>
2585 <td>Public method handling 'Call' nodes.</td>
2586 </tr>
2587 <tr>
2588 <td><a href="#M569Checker.visit_Delete">visit_Delete</a></td>
2589 <td>Public method handling 'Delete' nodes.</td>
2590 </tr>
2591 </table>
2592
2593 <h3>Static Methods</h3>
2594 <table>
2595 <tr><td>None</td></tr>
2596 </table>
2597
2598
2599 <a NAME="M569Checker.__init__" ID="M569Checker.__init__"></a>
2600 <h4>M569Checker (Constructor)</h4>
2601 <b>M569Checker</b>(<i>name, bugbear</i>)
2602 <p>
2603 Constructor
2604 </p>
2605
2606 <dl>
2607
2608 <dt><i>name</i> (str)</dt>
2609 <dd>
2610 name of the iterator
2611 </dd>
2612 <dt><i>bugbear</i> (BugBearVisitor)</dt>
2613 <dd>
2614 reference to the bugbear visitor
2615 </dd>
2616 </dl>
2617 <a NAME="M569Checker.visit" ID="M569Checker.visit"></a>
2618 <h4>M569Checker.visit</h4>
2619 <b>visit</b>(<i>node</i>)
2620 <p>
2621 Public method to inspect an ast node.
2622 </p>
2623 <p>
2624 Like super-visit but supports iteration over lists.
2625 </p>
2626
2627 <dl>
2628
2629 <dt><i>node</i> (TYPE)</dt>
2630 <dd>
2631 AST node to be traversed
2632 </dd>
2633 </dl>
2634 <dl>
2635 <dt>Return:</dt>
2636 <dd>
2637 reference to the last processed node
2638 </dd>
2639 </dl>
2640 <dl>
2641 <dt>Return Type:</dt>
2642 <dd>
2643 ast.Node
2644 </dd>
2645 </dl>
2646 <a NAME="M569Checker.visit_Call" ID="M569Checker.visit_Call"></a>
2647 <h4>M569Checker.visit_Call</h4>
2648 <b>visit_Call</b>(<i>node</i>)
2649 <p>
2650 Public method handling 'Call' nodes.
2651 </p>
2652
2653 <dl>
2654
2655 <dt><i>node</i> (ast.Call)</dt>
2656 <dd>
2657 reference to the node to be processed
2658 </dd>
2659 </dl>
2660 <a NAME="M569Checker.visit_Delete" ID="M569Checker.visit_Delete"></a>
2661 <h4>M569Checker.visit_Delete</h4>
2662 <b>visit_Delete</b>(<i>node</i>)
2663 <p>
2664 Public method handling 'Delete' nodes.
2665 </p>
2666
2667 <dl>
2668
2669 <dt><i>node</i> (ast.Delete)</dt>
2670 <dd>
2671 reference to the node to be processed
2672 </dd>
2673 </dl>
2674 <div align="right"><a href="#top">Up</a></div>
2675 <hr /> 35 <hr />
2676 <hr /> 36 <hr />
2677 <a NAME="MiscellaneousChecker" ID="MiscellaneousChecker"></a> 37 <a NAME="MiscellaneousChecker" ID="MiscellaneousChecker"></a>
2678 <h2>MiscellaneousChecker</h2> 38 <h2>MiscellaneousChecker</h2>
2679 <p> 39 <p>
2680 Class implementing a checker for miscellaneous checks. 40 Class implementing a checker for miscellaneous checks.
2681 </p> 41 </p>
2682 42
2683 <h3>Derived from</h3> 43 <h3>Derived from</h3>
2684 None 44 CodeStyleTopicChecker
2685 <h3>Class Attributes</h3> 45 <h3>Class Attributes</h3>
2686 <table> 46 <table>
2687 <tr><td>BuiltinsWhiteList</td></tr> 47 <tr><td>BuiltinsWhiteList</td></tr>
48 <tr><td>Category</td></tr>
2688 <tr><td>Codes</td></tr> 49 <tr><td>Codes</td></tr>
2689 <tr><td>FormatFieldRegex</td></tr> 50 <tr><td>FormatFieldRegex</td></tr>
2690 <tr><td>Formatter</td></tr> 51 <tr><td>Formatter</td></tr>
2691 </table> 52 </table>
2692 53
2788 <tr> 149 <tr>
2789 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td> 150 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td>
2790 <td>Private function to test, if the node should be checked.</td> 151 <td>Private function to test, if the node should be checked.</td>
2791 </tr> 152 </tr>
2792 <tr> 153 <tr>
2793 <td><a href="#MiscellaneousChecker.__error">__error</a></td>
2794 <td>Private method to record an issue.</td>
2795 </tr>
2796 <tr>
2797 <td><a href="#MiscellaneousChecker.__getCoding">__getCoding</a></td> 154 <td><a href="#MiscellaneousChecker.__getCoding">__getCoding</a></td>
2798 <td>Private method to get the defined coding of the source.</td> 155 <td>Private method to get the defined coding of the source.</td>
2799 </tr> 156 </tr>
2800 <tr> 157 <tr>
2801 <td><a href="#MiscellaneousChecker.__getFields">__getFields</a></td> 158 <td><a href="#MiscellaneousChecker.__getFields">__getFields</a></td>
2802 <td>Private method to extract the format field information.</td> 159 <td>Private method to extract the format field information.</td>
2803 </tr> 160 </tr>
2804 <tr> 161 <tr>
2805 <td><a href="#MiscellaneousChecker.__ignoreCode">__ignoreCode</a></td>
2806 <td>Private method to check if the message code should be ignored.</td>
2807 </tr>
2808 <tr>
2809 <td><a href="#MiscellaneousChecker.__isImplicitStringConcat">__isImplicitStringConcat</a></td> 162 <td><a href="#MiscellaneousChecker.__isImplicitStringConcat">__isImplicitStringConcat</a></td>
2810 <td>Private method to check, if the given strings indicate an implicit string concatenation.</td> 163 <td>Private method to check, if the given strings indicate an implicit string concatenation.</td>
2811 </tr>
2812 <tr>
2813 <td><a href="#MiscellaneousChecker.run">run</a></td>
2814 <td>Public method to check the given source against miscellaneous conditions.</td>
2815 </tr> 164 </tr>
2816 </table> 165 </table>
2817 166
2818 <h3>Static Methods</h3> 167 <h3>Static Methods</h3>
2819 <table> 168 <table>
3039 <dt>Return Type:</dt> 388 <dt>Return Type:</dt>
3040 <dd> 389 <dd>
3041 bool 390 bool
3042 </dd> 391 </dd>
3043 </dl> 392 </dl>
3044 <a NAME="MiscellaneousChecker.__error" ID="MiscellaneousChecker.__error"></a>
3045 <h4>MiscellaneousChecker.__error</h4>
3046 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
3047 <p>
3048 Private method to record an issue.
3049 </p>
3050
3051 <dl>
3052
3053 <dt><i>lineNumber</i> (int)</dt>
3054 <dd>
3055 line number of the issue
3056 </dd>
3057 <dt><i>offset</i> (int)</dt>
3058 <dd>
3059 position within line of the issue
3060 </dd>
3061 <dt><i>code</i> (str)</dt>
3062 <dd>
3063 message code
3064 </dd>
3065 <dt><i>args</i> (list)</dt>
3066 <dd>
3067 arguments for the message
3068 </dd>
3069 </dl>
3070 <a NAME="MiscellaneousChecker.__getCoding" ID="MiscellaneousChecker.__getCoding"></a> 393 <a NAME="MiscellaneousChecker.__getCoding" ID="MiscellaneousChecker.__getCoding"></a>
3071 <h4>MiscellaneousChecker.__getCoding</h4> 394 <h4>MiscellaneousChecker.__getCoding</h4>
3072 <b>__getCoding</b>(<i></i>) 395 <b>__getCoding</b>(<i></i>)
3073 <p> 396 <p>
3074 Private method to get the defined coding of the source. 397 Private method to get the defined coding of the source.
3111 <dt>Return Type:</dt> 434 <dt>Return Type:</dt>
3112 <dd> 435 <dd>
3113 tuple of set of str, bool, bool 436 tuple of set of str, bool, bool
3114 </dd> 437 </dd>
3115 </dl> 438 </dl>
3116 <a NAME="MiscellaneousChecker.__ignoreCode" ID="MiscellaneousChecker.__ignoreCode"></a>
3117 <h4>MiscellaneousChecker.__ignoreCode</h4>
3118 <b>__ignoreCode</b>(<i>code</i>)
3119 <p>
3120 Private method to check if the message code should be ignored.
3121 </p>
3122
3123 <dl>
3124
3125 <dt><i>code</i> (str)</dt>
3126 <dd>
3127 message code to check for
3128 </dd>
3129 </dl>
3130 <dl>
3131 <dt>Return:</dt>
3132 <dd>
3133 flag indicating to ignore the given code
3134 </dd>
3135 </dl>
3136 <dl>
3137 <dt>Return Type:</dt>
3138 <dd>
3139 bool
3140 </dd>
3141 </dl>
3142 <a NAME="MiscellaneousChecker.__isImplicitStringConcat" ID="MiscellaneousChecker.__isImplicitStringConcat"></a> 439 <a NAME="MiscellaneousChecker.__isImplicitStringConcat" ID="MiscellaneousChecker.__isImplicitStringConcat"></a>
3143 <h4>MiscellaneousChecker.__isImplicitStringConcat</h4> 440 <h4>MiscellaneousChecker.__isImplicitStringConcat</h4>
3144 <b>__isImplicitStringConcat</b>(<i>first, second</i>) 441 <b>__isImplicitStringConcat</b>(<i>first, second</i>)
3145 <p> 442 <p>
3146 Private method to check, if the given strings indicate an implicit string 443 Private method to check, if the given strings indicate an implicit string
3166 </dl> 463 </dl>
3167 <dl> 464 <dl>
3168 <dt>Return Type:</dt> 465 <dt>Return Type:</dt>
3169 <dd> 466 <dd>
3170 bool 467 bool
3171 </dd>
3172 </dl>
3173 <a NAME="MiscellaneousChecker.run" ID="MiscellaneousChecker.run"></a>
3174 <h4>MiscellaneousChecker.run</h4>
3175 <b>run</b>(<i></i>)
3176 <p>
3177 Public method to check the given source against miscellaneous
3178 conditions.
3179 </p>
3180
3181 <div align="right"><a href="#top">Up</a></div>
3182 <hr />
3183 <hr />
3184 <a NAME="NameFinder" ID="NameFinder"></a>
3185 <h2>NameFinder</h2>
3186 <p>
3187 Class to extract a name out of a tree of nodes.
3188 </p>
3189
3190 <h3>Derived from</h3>
3191 ast.NodeVisitor
3192 <h3>Class Attributes</h3>
3193 <table>
3194 <tr><td>None</td></tr>
3195 </table>
3196
3197 <h3>Class Methods</h3>
3198 <table>
3199 <tr><td>None</td></tr>
3200 </table>
3201
3202 <h3>Methods</h3>
3203 <table>
3204 <tr>
3205 <td><a href="#NameFinder.__init__">NameFinder</a></td>
3206 <td>Constructor</td>
3207 </tr>
3208 <tr>
3209 <td><a href="#NameFinder.getNames">getNames</a></td>
3210 <td>Public method to return the extracted names and Name nodes.</td>
3211 </tr>
3212 <tr>
3213 <td><a href="#NameFinder.visit">visit</a></td>
3214 <td>Public method to traverse a given AST node.</td>
3215 </tr>
3216 <tr>
3217 <td><a href="#NameFinder.visit_Name">visit_Name</a></td>
3218 <td>Public method to handle 'Name' nodes.</td>
3219 </tr>
3220 </table>
3221
3222 <h3>Static Methods</h3>
3223 <table>
3224 <tr><td>None</td></tr>
3225 </table>
3226
3227
3228 <a NAME="NameFinder.__init__" ID="NameFinder.__init__"></a>
3229 <h4>NameFinder (Constructor)</h4>
3230 <b>NameFinder</b>(<i></i>)
3231 <p>
3232 Constructor
3233 </p>
3234
3235 <a NAME="NameFinder.getNames" ID="NameFinder.getNames"></a>
3236 <h4>NameFinder.getNames</h4>
3237 <b>getNames</b>(<i></i>)
3238 <p>
3239 Public method to return the extracted names and Name nodes.
3240 </p>
3241
3242 <dl>
3243 <dt>Return:</dt>
3244 <dd>
3245 dictionary containing the names as keys and the list of nodes
3246 </dd>
3247 </dl>
3248 <dl>
3249 <dt>Return Type:</dt>
3250 <dd>
3251 dict
3252 </dd>
3253 </dl>
3254 <a NAME="NameFinder.visit" ID="NameFinder.visit"></a>
3255 <h4>NameFinder.visit</h4>
3256 <b>visit</b>(<i>node</i>)
3257 <p>
3258 Public method to traverse a given AST node.
3259 </p>
3260
3261 <dl>
3262
3263 <dt><i>node</i> (ast.Node)</dt>
3264 <dd>
3265 AST node to be traversed
3266 </dd>
3267 </dl>
3268 <dl>
3269 <dt>Return:</dt>
3270 <dd>
3271 reference to the last processed node
3272 </dd>
3273 </dl>
3274 <dl>
3275 <dt>Return Type:</dt>
3276 <dd>
3277 ast.Node
3278 </dd>
3279 </dl>
3280 <a NAME="NameFinder.visit_Name" ID="NameFinder.visit_Name"></a>
3281 <h4>NameFinder.visit_Name</h4>
3282 <b>visit_Name</b>(<i>node</i>)
3283 <p>
3284 Public method to handle 'Name' nodes.
3285 </p>
3286
3287 <dl>
3288
3289 <dt><i>node</i> (ast.Name)</dt>
3290 <dd>
3291 reference to the node to be processed
3292 </dd>
3293 </dl>
3294 <div align="right"><a href="#top">Up</a></div>
3295 <hr />
3296 <hr />
3297 <a NAME="NamedExprFinder" ID="NamedExprFinder"></a>
3298 <h2>NamedExprFinder</h2>
3299 <p>
3300 Class to extract names defined through an ast.NamedExpr.
3301 </p>
3302
3303 <h3>Derived from</h3>
3304 ast.NodeVisitor
3305 <h3>Class Attributes</h3>
3306 <table>
3307 <tr><td>None</td></tr>
3308 </table>
3309
3310 <h3>Class Methods</h3>
3311 <table>
3312 <tr><td>None</td></tr>
3313 </table>
3314
3315 <h3>Methods</h3>
3316 <table>
3317 <tr>
3318 <td><a href="#NamedExprFinder.__init__">NamedExprFinder</a></td>
3319 <td>Constructor</td>
3320 </tr>
3321 <tr>
3322 <td><a href="#NamedExprFinder.getNames">getNames</a></td>
3323 <td>Public method to return the extracted names and Name nodes.</td>
3324 </tr>
3325 <tr>
3326 <td><a href="#NamedExprFinder.visit">visit</a></td>
3327 <td>Public method to traverse a given AST node.</td>
3328 </tr>
3329 <tr>
3330 <td><a href="#NamedExprFinder.visit_NamedExpr">visit_NamedExpr</a></td>
3331 <td>Public method handling 'NamedExpr' nodes.</td>
3332 </tr>
3333 </table>
3334
3335 <h3>Static Methods</h3>
3336 <table>
3337 <tr><td>None</td></tr>
3338 </table>
3339
3340
3341 <a NAME="NamedExprFinder.__init__" ID="NamedExprFinder.__init__"></a>
3342 <h4>NamedExprFinder (Constructor)</h4>
3343 <b>NamedExprFinder</b>(<i></i>)
3344 <p>
3345 Constructor
3346 </p>
3347
3348 <a NAME="NamedExprFinder.getNames" ID="NamedExprFinder.getNames"></a>
3349 <h4>NamedExprFinder.getNames</h4>
3350 <b>getNames</b>(<i></i>)
3351 <p>
3352 Public method to return the extracted names and Name nodes.
3353 </p>
3354
3355 <dl>
3356 <dt>Return:</dt>
3357 <dd>
3358 dictionary containing the names as keys and the list of nodes
3359 </dd>
3360 </dl>
3361 <dl>
3362 <dt>Return Type:</dt>
3363 <dd>
3364 dict
3365 </dd>
3366 </dl>
3367 <a NAME="NamedExprFinder.visit" ID="NamedExprFinder.visit"></a>
3368 <h4>NamedExprFinder.visit</h4>
3369 <b>visit</b>(<i>node</i>)
3370 <p>
3371 Public method to traverse a given AST node.
3372 </p>
3373 <p>
3374 Like super-visit but supports iteration over lists.
3375 </p>
3376
3377 <dl>
3378
3379 <dt><i>node</i> (TYPE)</dt>
3380 <dd>
3381 AST node to be traversed
3382 </dd>
3383 </dl>
3384 <dl>
3385 <dt>Return:</dt>
3386 <dd>
3387 reference to the last processed node
3388 </dd>
3389 </dl>
3390 <dl>
3391 <dt>Return Type:</dt>
3392 <dd>
3393 ast.Node
3394 </dd>
3395 </dl>
3396 <a NAME="NamedExprFinder.visit_NamedExpr" ID="NamedExprFinder.visit_NamedExpr"></a>
3397 <h4>NamedExprFinder.visit_NamedExpr</h4>
3398 <b>visit_NamedExpr</b>(<i>node: ast.NamedExpr</i>)
3399 <p>
3400 Public method handling 'NamedExpr' nodes.
3401 </p>
3402
3403 <dl>
3404
3405 <dt><i>node</i> (ast.NamedExpr)</dt>
3406 <dd>
3407 reference to the node to be processed
3408 </dd>
3409 </dl>
3410 <div align="right"><a href="#top">Up</a></div>
3411 <hr />
3412 <hr />
3413 <a NAME="ReturnVisitor" ID="ReturnVisitor"></a>
3414 <h2>ReturnVisitor</h2>
3415 <p>
3416 Class implementing a node visitor to check return statements.
3417 </p>
3418
3419 <h3>Derived from</h3>
3420 ast.NodeVisitor
3421 <h3>Class Attributes</h3>
3422 <table>
3423 <tr><td>Assigns</td></tr>
3424 <tr><td>Refs</td></tr>
3425 <tr><td>Returns</td></tr>
3426 </table>
3427
3428 <h3>Class Methods</h3>
3429 <table>
3430 <tr><td>None</td></tr>
3431 </table>
3432
3433 <h3>Methods</h3>
3434 <table>
3435 <tr>
3436 <td><a href="#ReturnVisitor.__init__">ReturnVisitor</a></td>
3437 <td>Constructor</td>
3438 </tr>
3439 <tr>
3440 <td><a href="#ReturnVisitor.__checkFunction">__checkFunction</a></td>
3441 <td>Private method to check a function definition node.</td>
3442 </tr>
3443 <tr>
3444 <td><a href="#ReturnVisitor.__checkImplicitReturn">__checkImplicitReturn</a></td>
3445 <td>Private method to check for an implicit return statement.</td>
3446 </tr>
3447 <tr>
3448 <td><a href="#ReturnVisitor.__checkImplicitReturnValue">__checkImplicitReturnValue</a></td>
3449 <td>Private method to check for implicit return values.</td>
3450 </tr>
3451 <tr>
3452 <td><a href="#ReturnVisitor.__checkUnnecessaryAssign">__checkUnnecessaryAssign</a></td>
3453 <td>Private method to check for an unnecessary assign statement.</td>
3454 </tr>
3455 <tr>
3456 <td><a href="#ReturnVisitor.__checkUnnecessaryReturnNone">__checkUnnecessaryReturnNone</a></td>
3457 <td>Private method to check for an unnecessary 'return None' statement.</td>
3458 </tr>
3459 <tr>
3460 <td><a href="#ReturnVisitor.__hasRefsBeforeNextAssign">__hasRefsBeforeNextAssign</a></td>
3461 <td>Private method to check for references before a following assign statement.</td>
3462 </tr>
3463 <tr>
3464 <td><a href="#ReturnVisitor.__isFalse">__isFalse</a></td>
3465 <td>Private method to check, if a node value is False.</td>
3466 </tr>
3467 <tr>
3468 <td><a href="#ReturnVisitor.__isNone">__isNone</a></td>
3469 <td>Private method to check, if a node value is None.</td>
3470 </tr>
3471 <tr>
3472 <td><a href="#ReturnVisitor.__resultExists">__resultExists</a></td>
3473 <td>Private method to check the existance of a return result.</td>
3474 </tr>
3475 <tr>
3476 <td><a href="#ReturnVisitor.__visitAssignTarget">__visitAssignTarget</a></td>
3477 <td>Private method to handle an assign target node.</td>
3478 </tr>
3479 <tr>
3480 <td><a href="#ReturnVisitor.__visitLoop">__visitLoop</a></td>
3481 <td>Private method to handle loop nodes.</td>
3482 </tr>
3483 <tr>
3484 <td><a href="#ReturnVisitor.__visitWithStack">__visitWithStack</a></td>
3485 <td>Private method to traverse a given function node using a stack.</td>
3486 </tr>
3487 <tr>
3488 <td><a href="#ReturnVisitor.assigns">assigns</a></td>
3489 <td>Public method to get the Assign nodes.</td>
3490 </tr>
3491 <tr>
3492 <td><a href="#ReturnVisitor.refs">refs</a></td>
3493 <td>Public method to get the References nodes.</td>
3494 </tr>
3495 <tr>
3496 <td><a href="#ReturnVisitor.returns">returns</a></td>
3497 <td>Public method to get the Return nodes.</td>
3498 </tr>
3499 <tr>
3500 <td><a href="#ReturnVisitor.visit_Assign">visit_Assign</a></td>
3501 <td>Public method to handle an assign node.</td>
3502 </tr>
3503 <tr>
3504 <td><a href="#ReturnVisitor.visit_AsyncFor">visit_AsyncFor</a></td>
3505 <td>Public method to handle an async for loop.</td>
3506 </tr>
3507 <tr>
3508 <td><a href="#ReturnVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
3509 <td>Public method to handle a function definition.</td>
3510 </tr>
3511 <tr>
3512 <td><a href="#ReturnVisitor.visit_For">visit_For</a></td>
3513 <td>Public method to handle a for loop.</td>
3514 </tr>
3515 <tr>
3516 <td><a href="#ReturnVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
3517 <td>Public method to handle a function definition.</td>
3518 </tr>
3519 <tr>
3520 <td><a href="#ReturnVisitor.visit_Name">visit_Name</a></td>
3521 <td>Public method to handle a name node.</td>
3522 </tr>
3523 <tr>
3524 <td><a href="#ReturnVisitor.visit_Return">visit_Return</a></td>
3525 <td>Public method to handle a return node.</td>
3526 </tr>
3527 <tr>
3528 <td><a href="#ReturnVisitor.visit_While">visit_While</a></td>
3529 <td>Public method to handle a while loop.</td>
3530 </tr>
3531 </table>
3532
3533 <h3>Static Methods</h3>
3534 <table>
3535 <tr><td>None</td></tr>
3536 </table>
3537
3538
3539 <a NAME="ReturnVisitor.__init__" ID="ReturnVisitor.__init__"></a>
3540 <h4>ReturnVisitor (Constructor)</h4>
3541 <b>ReturnVisitor</b>(<i></i>)
3542 <p>
3543 Constructor
3544 </p>
3545
3546 <a NAME="ReturnVisitor.__checkFunction" ID="ReturnVisitor.__checkFunction"></a>
3547 <h4>ReturnVisitor.__checkFunction</h4>
3548 <b>__checkFunction</b>(<i>node</i>)
3549 <p>
3550 Private method to check a function definition node.
3551 </p>
3552
3553 <dl>
3554
3555 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
3556 <dd>
3557 reference to the node to check
3558 </dd>
3559 </dl>
3560 <a NAME="ReturnVisitor.__checkImplicitReturn" ID="ReturnVisitor.__checkImplicitReturn"></a>
3561 <h4>ReturnVisitor.__checkImplicitReturn</h4>
3562 <b>__checkImplicitReturn</b>(<i>node</i>)
3563 <p>
3564 Private method to check for an implicit return statement.
3565 </p>
3566
3567 <dl>
3568
3569 <dt><i>node</i> (ast.AST)</dt>
3570 <dd>
3571 reference to the node to check
3572 </dd>
3573 </dl>
3574 <a NAME="ReturnVisitor.__checkImplicitReturnValue" ID="ReturnVisitor.__checkImplicitReturnValue"></a>
3575 <h4>ReturnVisitor.__checkImplicitReturnValue</h4>
3576 <b>__checkImplicitReturnValue</b>(<i></i>)
3577 <p>
3578 Private method to check for implicit return values.
3579 </p>
3580
3581 <a NAME="ReturnVisitor.__checkUnnecessaryAssign" ID="ReturnVisitor.__checkUnnecessaryAssign"></a>
3582 <h4>ReturnVisitor.__checkUnnecessaryAssign</h4>
3583 <b>__checkUnnecessaryAssign</b>(<i>node</i>)
3584 <p>
3585 Private method to check for an unnecessary assign statement.
3586 </p>
3587
3588 <dl>
3589
3590 <dt><i>node</i> (ast.AST)</dt>
3591 <dd>
3592 reference to the node to check
3593 </dd>
3594 </dl>
3595 <a NAME="ReturnVisitor.__checkUnnecessaryReturnNone" ID="ReturnVisitor.__checkUnnecessaryReturnNone"></a>
3596 <h4>ReturnVisitor.__checkUnnecessaryReturnNone</h4>
3597 <b>__checkUnnecessaryReturnNone</b>(<i></i>)
3598 <p>
3599 Private method to check for an unnecessary 'return None' statement.
3600 </p>
3601
3602 <a NAME="ReturnVisitor.__hasRefsBeforeNextAssign" ID="ReturnVisitor.__hasRefsBeforeNextAssign"></a>
3603 <h4>ReturnVisitor.__hasRefsBeforeNextAssign</h4>
3604 <b>__hasRefsBeforeNextAssign</b>(<i>varname, returnLineno</i>)
3605 <p>
3606 Private method to check for references before a following assign
3607 statement.
3608 </p>
3609
3610 <dl>
3611
3612 <dt><i>varname</i> (str)</dt>
3613 <dd>
3614 variable name to check for
3615 </dd>
3616 <dt><i>returnLineno</i> (int)</dt>
3617 <dd>
3618 line number of the return statement
3619 </dd>
3620 </dl>
3621 <dl>
3622 <dt>Return:</dt>
3623 <dd>
3624 flag indicating the existence of references
3625 </dd>
3626 </dl>
3627 <dl>
3628 <dt>Return Type:</dt>
3629 <dd>
3630 bool
3631 </dd>
3632 </dl>
3633 <a NAME="ReturnVisitor.__isFalse" ID="ReturnVisitor.__isFalse"></a>
3634 <h4>ReturnVisitor.__isFalse</h4>
3635 <b>__isFalse</b>(<i>node</i>)
3636 <p>
3637 Private method to check, if a node value is False.
3638 </p>
3639
3640 <dl>
3641
3642 <dt><i>node</i> (ast.AST)</dt>
3643 <dd>
3644 reference to the node to check
3645 </dd>
3646 </dl>
3647 <dl>
3648 <dt>Return:</dt>
3649 <dd>
3650 flag indicating the node contains a False value
3651 </dd>
3652 </dl>
3653 <dl>
3654 <dt>Return Type:</dt>
3655 <dd>
3656 bool
3657 </dd>
3658 </dl>
3659 <a NAME="ReturnVisitor.__isNone" ID="ReturnVisitor.__isNone"></a>
3660 <h4>ReturnVisitor.__isNone</h4>
3661 <b>__isNone</b>(<i>node</i>)
3662 <p>
3663 Private method to check, if a node value is None.
3664 </p>
3665
3666 <dl>
3667
3668 <dt><i>node</i> (ast.AST)</dt>
3669 <dd>
3670 reference to the node to check
3671 </dd>
3672 </dl>
3673 <dl>
3674 <dt>Return:</dt>
3675 <dd>
3676 flag indicating the node contains a None value
3677 </dd>
3678 </dl>
3679 <dl>
3680 <dt>Return Type:</dt>
3681 <dd>
3682 bool
3683 </dd>
3684 </dl>
3685 <a NAME="ReturnVisitor.__resultExists" ID="ReturnVisitor.__resultExists"></a>
3686 <h4>ReturnVisitor.__resultExists</h4>
3687 <b>__resultExists</b>(<i></i>)
3688 <p>
3689 Private method to check the existance of a return result.
3690 </p>
3691
3692 <dl>
3693 <dt>Return:</dt>
3694 <dd>
3695 flag indicating the existence of a return result
3696 </dd>
3697 </dl>
3698 <dl>
3699 <dt>Return Type:</dt>
3700 <dd>
3701 bool
3702 </dd>
3703 </dl>
3704 <a NAME="ReturnVisitor.__visitAssignTarget" ID="ReturnVisitor.__visitAssignTarget"></a>
3705 <h4>ReturnVisitor.__visitAssignTarget</h4>
3706 <b>__visitAssignTarget</b>(<i>node</i>)
3707 <p>
3708 Private method to handle an assign target node.
3709 </p>
3710
3711 <dl>
3712
3713 <dt><i>node</i> (ast.AST)</dt>
3714 <dd>
3715 reference to the node to handle
3716 </dd>
3717 </dl>
3718 <a NAME="ReturnVisitor.__visitLoop" ID="ReturnVisitor.__visitLoop"></a>
3719 <h4>ReturnVisitor.__visitLoop</h4>
3720 <b>__visitLoop</b>(<i>node</i>)
3721 <p>
3722 Private method to handle loop nodes.
3723 </p>
3724
3725 <dl>
3726
3727 <dt><i>node</i> (ast.For, ast.AsyncFor or ast.While)</dt>
3728 <dd>
3729 reference to the loop node to handle
3730 </dd>
3731 </dl>
3732 <a NAME="ReturnVisitor.__visitWithStack" ID="ReturnVisitor.__visitWithStack"></a>
3733 <h4>ReturnVisitor.__visitWithStack</h4>
3734 <b>__visitWithStack</b>(<i>node</i>)
3735 <p>
3736 Private method to traverse a given function node using a stack.
3737 </p>
3738
3739 <dl>
3740
3741 <dt><i>node</i> (ast.FunctionDef or ast.AsyncFunctionDef)</dt>
3742 <dd>
3743 AST node to be traversed
3744 </dd>
3745 </dl>
3746 <a NAME="ReturnVisitor.assigns" ID="ReturnVisitor.assigns"></a>
3747 <h4>ReturnVisitor.assigns</h4>
3748 <b>assigns</b>(<i></i>)
3749 <p>
3750 Public method to get the Assign nodes.
3751 </p>
3752
3753 <dl>
3754 <dt>Return:</dt>
3755 <dd>
3756 dictionary containing the node name as key and line number
3757 as value
3758 </dd>
3759 </dl>
3760 <dl>
3761 <dt>Return Type:</dt>
3762 <dd>
3763 dict
3764 </dd>
3765 </dl>
3766 <a NAME="ReturnVisitor.refs" ID="ReturnVisitor.refs"></a>
3767 <h4>ReturnVisitor.refs</h4>
3768 <b>refs</b>(<i></i>)
3769 <p>
3770 Public method to get the References nodes.
3771 </p>
3772
3773 <dl>
3774 <dt>Return:</dt>
3775 <dd>
3776 dictionary containing the node name as key and line number
3777 as value
3778 </dd>
3779 </dl>
3780 <dl>
3781 <dt>Return Type:</dt>
3782 <dd>
3783 dict
3784 </dd>
3785 </dl>
3786 <a NAME="ReturnVisitor.returns" ID="ReturnVisitor.returns"></a>
3787 <h4>ReturnVisitor.returns</h4>
3788 <b>returns</b>(<i></i>)
3789 <p>
3790 Public method to get the Return nodes.
3791 </p>
3792
3793 <dl>
3794 <dt>Return:</dt>
3795 <dd>
3796 dictionary containing the node name as key and line number
3797 as value
3798 </dd>
3799 </dl>
3800 <dl>
3801 <dt>Return Type:</dt>
3802 <dd>
3803 dict
3804 </dd>
3805 </dl>
3806 <a NAME="ReturnVisitor.visit_Assign" ID="ReturnVisitor.visit_Assign"></a>
3807 <h4>ReturnVisitor.visit_Assign</h4>
3808 <b>visit_Assign</b>(<i>node</i>)
3809 <p>
3810 Public method to handle an assign node.
3811 </p>
3812
3813 <dl>
3814
3815 <dt><i>node</i> (ast.Assign)</dt>
3816 <dd>
3817 reference to the node to handle
3818 </dd>
3819 </dl>
3820 <a NAME="ReturnVisitor.visit_AsyncFor" ID="ReturnVisitor.visit_AsyncFor"></a>
3821 <h4>ReturnVisitor.visit_AsyncFor</h4>
3822 <b>visit_AsyncFor</b>(<i>node</i>)
3823 <p>
3824 Public method to handle an async for loop.
3825 </p>
3826
3827 <dl>
3828
3829 <dt><i>node</i> (ast.AsyncFor)</dt>
3830 <dd>
3831 reference to the async for node to handle
3832 </dd>
3833 </dl>
3834 <a NAME="ReturnVisitor.visit_AsyncFunctionDef" ID="ReturnVisitor.visit_AsyncFunctionDef"></a>
3835 <h4>ReturnVisitor.visit_AsyncFunctionDef</h4>
3836 <b>visit_AsyncFunctionDef</b>(<i>node</i>)
3837 <p>
3838 Public method to handle a function definition.
3839 </p>
3840
3841 <dl>
3842
3843 <dt><i>node</i> (ast.AsyncFunctionDef)</dt>
3844 <dd>
3845 reference to the node to handle
3846 </dd>
3847 </dl>
3848 <a NAME="ReturnVisitor.visit_For" ID="ReturnVisitor.visit_For"></a>
3849 <h4>ReturnVisitor.visit_For</h4>
3850 <b>visit_For</b>(<i>node</i>)
3851 <p>
3852 Public method to handle a for loop.
3853 </p>
3854
3855 <dl>
3856
3857 <dt><i>node</i> (ast.For)</dt>
3858 <dd>
3859 reference to the for node to handle
3860 </dd>
3861 </dl>
3862 <a NAME="ReturnVisitor.visit_FunctionDef" ID="ReturnVisitor.visit_FunctionDef"></a>
3863 <h4>ReturnVisitor.visit_FunctionDef</h4>
3864 <b>visit_FunctionDef</b>(<i>node</i>)
3865 <p>
3866 Public method to handle a function definition.
3867 </p>
3868
3869 <dl>
3870
3871 <dt><i>node</i> (ast.FunctionDef)</dt>
3872 <dd>
3873 reference to the node to handle
3874 </dd>
3875 </dl>
3876 <a NAME="ReturnVisitor.visit_Name" ID="ReturnVisitor.visit_Name"></a>
3877 <h4>ReturnVisitor.visit_Name</h4>
3878 <b>visit_Name</b>(<i>node</i>)
3879 <p>
3880 Public method to handle a name node.
3881 </p>
3882
3883 <dl>
3884
3885 <dt><i>node</i> (ast.Name)</dt>
3886 <dd>
3887 reference to the node to handle
3888 </dd>
3889 </dl>
3890 <a NAME="ReturnVisitor.visit_Return" ID="ReturnVisitor.visit_Return"></a>
3891 <h4>ReturnVisitor.visit_Return</h4>
3892 <b>visit_Return</b>(<i>node</i>)
3893 <p>
3894 Public method to handle a return node.
3895 </p>
3896
3897 <dl>
3898
3899 <dt><i>node</i> (ast.Return)</dt>
3900 <dd>
3901 reference to the node to handle
3902 </dd>
3903 </dl>
3904 <a NAME="ReturnVisitor.visit_While" ID="ReturnVisitor.visit_While"></a>
3905 <h4>ReturnVisitor.visit_While</h4>
3906 <b>visit_While</b>(<i>node</i>)
3907 <p>
3908 Public method to handle a while loop.
3909 </p>
3910
3911 <dl>
3912
3913 <dt><i>node</i> (ast.While)</dt>
3914 <dd>
3915 reference to the while node to handle
3916 </dd>
3917 </dl>
3918 <div align="right"><a href="#top">Up</a></div>
3919 <hr />
3920 <hr />
3921 <a NAME="SysVersionVisitor" ID="SysVersionVisitor"></a>
3922 <h2>SysVersionVisitor</h2>
3923 <p>
3924 Class implementing a node visitor to check the use of sys.version and
3925 sys.version_info.
3926 </p>
3927 <p>
3928 Note: This class is modeled after flake8-2020 v1.8.1.
3929 </p>
3930
3931 <h3>Derived from</h3>
3932 ast.NodeVisitor
3933 <h3>Class Attributes</h3>
3934 <table>
3935 <tr><td>None</td></tr>
3936 </table>
3937
3938 <h3>Class Methods</h3>
3939 <table>
3940 <tr><td>None</td></tr>
3941 </table>
3942
3943 <h3>Methods</h3>
3944 <table>
3945 <tr>
3946 <td><a href="#SysVersionVisitor.__init__">SysVersionVisitor</a></td>
3947 <td>Constructor</td>
3948 </tr>
3949 <tr>
3950 <td><a href="#SysVersionVisitor.__isSys">__isSys</a></td>
3951 <td>Private method to check for a reference to sys attribute.</td>
3952 </tr>
3953 <tr>
3954 <td><a href="#SysVersionVisitor.__isSysVersionUpperSlice">__isSysVersionUpperSlice</a></td>
3955 <td>Private method to check the upper slice of sys.version.</td>
3956 </tr>
3957 <tr>
3958 <td><a href="#SysVersionVisitor.visit_Attribute">visit_Attribute</a></td>
3959 <td>Public method to handle an attribute.</td>
3960 </tr>
3961 <tr>
3962 <td><a href="#SysVersionVisitor.visit_Compare">visit_Compare</a></td>
3963 <td>Public method to handle a comparison.</td>
3964 </tr>
3965 <tr>
3966 <td><a href="#SysVersionVisitor.visit_ImportFrom">visit_ImportFrom</a></td>
3967 <td>Public method to handle a from ...</td>
3968 </tr>
3969 <tr>
3970 <td><a href="#SysVersionVisitor.visit_Name">visit_Name</a></td>
3971 <td>Public method to handle an name.</td>
3972 </tr>
3973 <tr>
3974 <td><a href="#SysVersionVisitor.visit_Subscript">visit_Subscript</a></td>
3975 <td>Public method to handle a subscript.</td>
3976 </tr>
3977 </table>
3978
3979 <h3>Static Methods</h3>
3980 <table>
3981 <tr><td>None</td></tr>
3982 </table>
3983
3984
3985 <a NAME="SysVersionVisitor.__init__" ID="SysVersionVisitor.__init__"></a>
3986 <h4>SysVersionVisitor (Constructor)</h4>
3987 <b>SysVersionVisitor</b>(<i></i>)
3988 <p>
3989 Constructor
3990 </p>
3991
3992 <a NAME="SysVersionVisitor.__isSys" ID="SysVersionVisitor.__isSys"></a>
3993 <h4>SysVersionVisitor.__isSys</h4>
3994 <b>__isSys</b>(<i>attr, node</i>)
3995 <p>
3996 Private method to check for a reference to sys attribute.
3997 </p>
3998
3999 <dl>
4000
4001 <dt><i>attr</i> (str)</dt>
4002 <dd>
4003 attribute name
4004 </dd>
4005 <dt><i>node</i> (ast.Node)</dt>
4006 <dd>
4007 reference to the node to be checked
4008 </dd>
4009 </dl>
4010 <dl>
4011 <dt>Return:</dt>
4012 <dd>
4013 flag indicating a match
4014 </dd>
4015 </dl>
4016 <dl>
4017 <dt>Return Type:</dt>
4018 <dd>
4019 bool
4020 </dd>
4021 </dl>
4022 <a NAME="SysVersionVisitor.__isSysVersionUpperSlice" ID="SysVersionVisitor.__isSysVersionUpperSlice"></a>
4023 <h4>SysVersionVisitor.__isSysVersionUpperSlice</h4>
4024 <b>__isSysVersionUpperSlice</b>(<i>node, n</i>)
4025 <p>
4026 Private method to check the upper slice of sys.version.
4027 </p>
4028
4029 <dl>
4030
4031 <dt><i>node</i> (ast.Node)</dt>
4032 <dd>
4033 reference to the node to be checked
4034 </dd>
4035 <dt><i>n</i> (int)</dt>
4036 <dd>
4037 slice value to check against
4038 </dd>
4039 </dl>
4040 <dl>
4041 <dt>Return:</dt>
4042 <dd>
4043 flag indicating a match
4044 </dd>
4045 </dl>
4046 <dl>
4047 <dt>Return Type:</dt>
4048 <dd>
4049 bool
4050 </dd>
4051 </dl>
4052 <a NAME="SysVersionVisitor.visit_Attribute" ID="SysVersionVisitor.visit_Attribute"></a>
4053 <h4>SysVersionVisitor.visit_Attribute</h4>
4054 <b>visit_Attribute</b>(<i>node</i>)
4055 <p>
4056 Public method to handle an attribute.
4057 </p>
4058
4059 <dl>
4060
4061 <dt><i>node</i> (ast.Attribute)</dt>
4062 <dd>
4063 reference to the node to be processed
4064 </dd>
4065 </dl>
4066 <a NAME="SysVersionVisitor.visit_Compare" ID="SysVersionVisitor.visit_Compare"></a>
4067 <h4>SysVersionVisitor.visit_Compare</h4>
4068 <b>visit_Compare</b>(<i>node</i>)
4069 <p>
4070 Public method to handle a comparison.
4071 </p>
4072
4073 <dl>
4074
4075 <dt><i>node</i> (ast.Compare)</dt>
4076 <dd>
4077 reference to the node to be processed
4078 </dd>
4079 </dl>
4080 <a NAME="SysVersionVisitor.visit_ImportFrom" ID="SysVersionVisitor.visit_ImportFrom"></a>
4081 <h4>SysVersionVisitor.visit_ImportFrom</h4>
4082 <b>visit_ImportFrom</b>(<i>node</i>)
4083 <p>
4084 Public method to handle a from ... import ... statement.
4085 </p>
4086
4087 <dl>
4088
4089 <dt><i>node</i> (ast.ImportFrom)</dt>
4090 <dd>
4091 reference to the node to be processed
4092 </dd>
4093 </dl>
4094 <a NAME="SysVersionVisitor.visit_Name" ID="SysVersionVisitor.visit_Name"></a>
4095 <h4>SysVersionVisitor.visit_Name</h4>
4096 <b>visit_Name</b>(<i>node</i>)
4097 <p>
4098 Public method to handle an name.
4099 </p>
4100
4101 <dl>
4102
4103 <dt><i>node</i> (ast.Name)</dt>
4104 <dd>
4105 reference to the node to be processed
4106 </dd>
4107 </dl>
4108 <a NAME="SysVersionVisitor.visit_Subscript" ID="SysVersionVisitor.visit_Subscript"></a>
4109 <h4>SysVersionVisitor.visit_Subscript</h4>
4110 <b>visit_Subscript</b>(<i>node</i>)
4111 <p>
4112 Public method to handle a subscript.
4113 </p>
4114
4115 <dl>
4116
4117 <dt><i>node</i> (ast.Subscript)</dt>
4118 <dd>
4119 reference to the node to be processed
4120 </dd>
4121 </dl>
4122 <div align="right"><a href="#top">Up</a></div>
4123 <hr />
4124 <hr />
4125 <a NAME="TextVisitor" ID="TextVisitor"></a>
4126 <h2>TextVisitor</h2>
4127 <p>
4128 Class implementing a node visitor for bytes and str instances.
4129 </p>
4130 <p>
4131 It tries to detect docstrings as string of the first expression of each
4132 module, class or function.
4133 </p>
4134
4135 <h3>Derived from</h3>
4136 ast.NodeVisitor
4137 <h3>Class Attributes</h3>
4138 <table>
4139 <tr><td>None</td></tr>
4140 </table>
4141
4142 <h3>Class Methods</h3>
4143 <table>
4144 <tr><td>None</td></tr>
4145 </table>
4146
4147 <h3>Methods</h3>
4148 <table>
4149 <tr>
4150 <td><a href="#TextVisitor.__init__">TextVisitor</a></td>
4151 <td>Constructor</td>
4152 </tr>
4153 <tr>
4154 <td><a href="#TextVisitor.__addNode">__addNode</a></td>
4155 <td>Private method to add a node to our list of nodes.</td>
4156 </tr>
4157 <tr>
4158 <td><a href="#TextVisitor.__visitBody">__visitBody</a></td>
4159 <td>Private method to traverse the body of the node manually.</td>
4160 </tr>
4161 <tr>
4162 <td><a href="#TextVisitor.__visitDefinition">__visitDefinition</a></td>
4163 <td>Private method handling class and function definitions.</td>
4164 </tr>
4165 <tr>
4166 <td><a href="#TextVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
4167 <td>Public method to handle an asynchronous function definition.</td>
4168 </tr>
4169 <tr>
4170 <td><a href="#TextVisitor.visit_Call">visit_Call</a></td>
4171 <td>Public method to handle a function call.</td>
4172 </tr>
4173 <tr>
4174 <td><a href="#TextVisitor.visit_ClassDef">visit_ClassDef</a></td>
4175 <td>Public method to handle a class definition.</td>
4176 </tr>
4177 <tr>
4178 <td><a href="#TextVisitor.visit_Constant">visit_Constant</a></td>
4179 <td>Public method to handle constant nodes.</td>
4180 </tr>
4181 <tr>
4182 <td><a href="#TextVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
4183 <td>Public method to handle a function definition.</td>
4184 </tr>
4185 <tr>
4186 <td><a href="#TextVisitor.visit_Module">visit_Module</a></td>
4187 <td>Public method to handle a module.</td>
4188 </tr>
4189 </table>
4190
4191 <h3>Static Methods</h3>
4192 <table>
4193 <tr><td>None</td></tr>
4194 </table>
4195
4196
4197 <a NAME="TextVisitor.__init__" ID="TextVisitor.__init__"></a>
4198 <h4>TextVisitor (Constructor)</h4>
4199 <b>TextVisitor</b>(<i></i>)
4200 <p>
4201 Constructor
4202 </p>
4203
4204 <a NAME="TextVisitor.__addNode" ID="TextVisitor.__addNode"></a>
4205 <h4>TextVisitor.__addNode</h4>
4206 <b>__addNode</b>(<i>node</i>)
4207 <p>
4208 Private method to add a node to our list of nodes.
4209 </p>
4210
4211 <dl>
4212
4213 <dt><i>node</i> (ast.AST)</dt>
4214 <dd>
4215 reference to the node to add
4216 </dd>
4217 </dl>
4218 <a NAME="TextVisitor.__visitBody" ID="TextVisitor.__visitBody"></a>
4219 <h4>TextVisitor.__visitBody</h4>
4220 <b>__visitBody</b>(<i>node</i>)
4221 <p>
4222 Private method to traverse the body of the node manually.
4223 </p>
4224 <p>
4225 If the first node is an expression which contains a string or bytes it
4226 marks that as a docstring.
4227 </p>
4228
4229 <dl>
4230
4231 <dt><i>node</i> (ast.AST)</dt>
4232 <dd>
4233 reference to the node to traverse
4234 </dd>
4235 </dl>
4236 <a NAME="TextVisitor.__visitDefinition" ID="TextVisitor.__visitDefinition"></a>
4237 <h4>TextVisitor.__visitDefinition</h4>
4238 <b>__visitDefinition</b>(<i>node</i>)
4239 <p>
4240 Private method handling class and function definitions.
4241 </p>
4242
4243 <dl>
4244
4245 <dt><i>node</i> (ast.FunctionDef, ast.AsyncFunctionDef or ast.ClassDef)</dt>
4246 <dd>
4247 reference to the node to handle
4248 </dd>
4249 </dl>
4250 <a NAME="TextVisitor.visit_AsyncFunctionDef" ID="TextVisitor.visit_AsyncFunctionDef"></a>
4251 <h4>TextVisitor.visit_AsyncFunctionDef</h4>
4252 <b>visit_AsyncFunctionDef</b>(<i>node</i>)
4253 <p>
4254 Public method to handle an asynchronous function definition.
4255 </p>
4256
4257 <dl>
4258
4259 <dt><i>node</i> (ast.AsyncFunctionDef)</dt>
4260 <dd>
4261 reference to the node to handle
4262 </dd>
4263 </dl>
4264 <a NAME="TextVisitor.visit_Call" ID="TextVisitor.visit_Call"></a>
4265 <h4>TextVisitor.visit_Call</h4>
4266 <b>visit_Call</b>(<i>node</i>)
4267 <p>
4268 Public method to handle a function call.
4269 </p>
4270
4271 <dl>
4272
4273 <dt><i>node</i> (ast.Call)</dt>
4274 <dd>
4275 reference to the node to handle
4276 </dd>
4277 </dl>
4278 <a NAME="TextVisitor.visit_ClassDef" ID="TextVisitor.visit_ClassDef"></a>
4279 <h4>TextVisitor.visit_ClassDef</h4>
4280 <b>visit_ClassDef</b>(<i>node</i>)
4281 <p>
4282 Public method to handle a class definition.
4283 </p>
4284
4285 <dl>
4286
4287 <dt><i>node</i> (ast.ClassDef)</dt>
4288 <dd>
4289 reference to the node to handle
4290 </dd>
4291 </dl>
4292 <a NAME="TextVisitor.visit_Constant" ID="TextVisitor.visit_Constant"></a>
4293 <h4>TextVisitor.visit_Constant</h4>
4294 <b>visit_Constant</b>(<i>node</i>)
4295 <p>
4296 Public method to handle constant nodes.
4297 </p>
4298
4299 <dl>
4300
4301 <dt><i>node</i> (ast.Constant)</dt>
4302 <dd>
4303 reference to the bytes node
4304 </dd>
4305 </dl>
4306 <a NAME="TextVisitor.visit_FunctionDef" ID="TextVisitor.visit_FunctionDef"></a>
4307 <h4>TextVisitor.visit_FunctionDef</h4>
4308 <b>visit_FunctionDef</b>(<i>node</i>)
4309 <p>
4310 Public method to handle a function definition.
4311 </p>
4312
4313 <dl>
4314
4315 <dt><i>node</i> (ast.FunctionDef)</dt>
4316 <dd>
4317 reference to the node to handle
4318 </dd>
4319 </dl>
4320 <a NAME="TextVisitor.visit_Module" ID="TextVisitor.visit_Module"></a>
4321 <h4>TextVisitor.visit_Module</h4>
4322 <b>visit_Module</b>(<i>node</i>)
4323 <p>
4324 Public method to handle a module.
4325 </p>
4326
4327 <dl>
4328
4329 <dt><i>node</i> (ast.Module)</dt>
4330 <dd>
4331 reference to the node to handle
4332 </dd>
4333 </dl>
4334 <div align="right"><a href="#top">Up</a></div>
4335 <hr />
4336 <hr />
4337 <a NAME="composeCallPath" ID="composeCallPath"></a>
4338 <h2>composeCallPath</h2>
4339 <b>composeCallPath</b>(<i>node</i>)
4340 <p>
4341 Generator function to assemble the call path of a given node.
4342 </p>
4343
4344 <dl>
4345
4346 <dt><i>node</i> (ast.Node)</dt>
4347 <dd>
4348 node to assemble call path for
4349 </dd>
4350 </dl>
4351 <dl>
4352 <dt>Yield:</dt>
4353 <dd>
4354 call path components
4355 </dd>
4356 </dl>
4357 <dl>
4358 <dt>Yield Type:</dt>
4359 <dd>
4360 str
4361 </dd> 468 </dd>
4362 </dl> 469 </dl>
4363 <div align="right"><a href="#top">Up</a></div> 470 <div align="right"><a href="#top">Up</a></div>
4364 <hr /> 471 <hr />
4365 <hr /> 472 <hr />

eric ide

mercurial