|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker</h1> |
|
23 <p> |
|
24 Module implementing a checker for miscellaneous checks. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>None</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#BugBearVisitor">BugBearVisitor</a></td> |
|
34 <td>Class implementing a node visitor to check for various topics.</td> |
|
35 </tr><tr> |
|
36 <td><a href="#LoggingVisitor">LoggingVisitor</a></td> |
|
37 <td>Class implementing a node visitor to check logging statements.</td> |
|
38 </tr><tr> |
|
39 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> |
|
40 <td>Class implementing a checker for miscellaneous checks.</td> |
|
41 </tr><tr> |
|
42 <td><a href="#NameFinder">NameFinder</a></td> |
|
43 <td>Class to extract a name out of a tree of nodes.</td> |
|
44 </tr><tr> |
|
45 <td><a href="#ReturnVisitor">ReturnVisitor</a></td> |
|
46 <td>Class implementing a node visitor to check return statements.</td> |
|
47 </tr><tr> |
|
48 <td><a href="#TextVisitor">TextVisitor</a></td> |
|
49 <td>Class implementing a node visitor for bytes and str instances.</td> |
|
50 </tr> |
|
51 </table> |
|
52 <h3>Functions</h3> |
|
53 <table> |
|
54 <tr> |
|
55 <td><a href="#composeCallPath">composeCallPath</a></td> |
|
56 <td>Generator function to assemble the call path of a given node.</td> |
|
57 </tr> |
|
58 </table> |
|
59 <hr /><hr /> |
|
60 <a NAME="BugBearVisitor" ID="BugBearVisitor"></a> |
|
61 <h2>BugBearVisitor</h2> |
|
62 <p> |
|
63 Class implementing a node visitor to check for various topics. |
|
64 </p> |
|
65 <h3>Derived from</h3> |
|
66 ast.NodeVisitor |
|
67 <h3>Class Attributes</h3> |
|
68 <table> |
|
69 <tr><td>NodeWindowSize</td></tr> |
|
70 </table> |
|
71 <h3>Class Methods</h3> |
|
72 <table> |
|
73 <tr><td>None</td></tr> |
|
74 </table> |
|
75 <h3>Methods</h3> |
|
76 <table> |
|
77 <tr> |
|
78 <td><a href="#BugBearVisitor.__init__">BugBearVisitor</a></td> |
|
79 <td>Constructor</td> |
|
80 </tr><tr> |
|
81 <td><a href="#BugBearVisitor.__checkForM502">__checkForM502</a></td> |
|
82 <td>Private method to check the use of *strip().</td> |
|
83 </tr><tr> |
|
84 <td><a href="#BugBearVisitor.__checkForM507">__checkForM507</a></td> |
|
85 <td>Private method to check for unused loop variables.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#BugBearVisitor.visit">visit</a></td> |
|
88 <td>Public method to traverse a given AST node.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#BugBearVisitor.visit_Assign">visit_Assign</a></td> |
|
91 <td>Public method to handle assignments.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#BugBearVisitor.visit_Attribute">visit_Attribute</a></td> |
|
94 <td>Public method to handle attributes.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#BugBearVisitor.visit_Call">visit_Call</a></td> |
|
97 <td>Public method to handle a function call.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#BugBearVisitor.visit_For">visit_For</a></td> |
|
100 <td>Public method to handle 'for' statements.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#BugBearVisitor.visit_UAdd">visit_UAdd</a></td> |
|
103 <td>Public method to handle unary additions.</td> |
|
104 </tr> |
|
105 </table> |
|
106 <h3>Static Methods</h3> |
|
107 <table> |
|
108 <tr><td>None</td></tr> |
|
109 </table> |
|
110 <a NAME="BugBearVisitor.__init__" ID="BugBearVisitor.__init__"></a> |
|
111 <h4>BugBearVisitor (Constructor)</h4> |
|
112 <b>BugBearVisitor</b>(<i></i>) |
|
113 <p> |
|
114 Constructor |
|
115 </p><a NAME="BugBearVisitor.__checkForM502" ID="BugBearVisitor.__checkForM502"></a> |
|
116 <h4>BugBearVisitor.__checkForM502</h4> |
|
117 <b>__checkForM502</b>(<i>node</i>) |
|
118 <p> |
|
119 Private method to check the use of *strip(). |
|
120 </p><dl> |
|
121 <dt><i>node</i> (ast.Call)</dt> |
|
122 <dd> |
|
123 reference to the node to be processed |
|
124 </dd> |
|
125 </dl><a NAME="BugBearVisitor.__checkForM507" ID="BugBearVisitor.__checkForM507"></a> |
|
126 <h4>BugBearVisitor.__checkForM507</h4> |
|
127 <b>__checkForM507</b>(<i>node</i>) |
|
128 <p> |
|
129 Private method to check for unused loop variables. |
|
130 </p><dl> |
|
131 <dt><i>node</i> (ast.For)</dt> |
|
132 <dd> |
|
133 reference to the node to be processed |
|
134 </dd> |
|
135 </dl><a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a> |
|
136 <h4>BugBearVisitor.visit</h4> |
|
137 <b>visit</b>(<i>node</i>) |
|
138 <p> |
|
139 Public method to traverse a given AST node. |
|
140 </p><dl> |
|
141 <dt><i>node</i> (ast.Node)</dt> |
|
142 <dd> |
|
143 AST node to be traversed |
|
144 </dd> |
|
145 </dl><a NAME="BugBearVisitor.visit_Assign" ID="BugBearVisitor.visit_Assign"></a> |
|
146 <h4>BugBearVisitor.visit_Assign</h4> |
|
147 <b>visit_Assign</b>(<i>node</i>) |
|
148 <p> |
|
149 Public method to handle assignments. |
|
150 </p><dl> |
|
151 <dt><i>node</i> (ast.Assign)</dt> |
|
152 <dd> |
|
153 reference to the node to be processed |
|
154 </dd> |
|
155 </dl><a NAME="BugBearVisitor.visit_Attribute" ID="BugBearVisitor.visit_Attribute"></a> |
|
156 <h4>BugBearVisitor.visit_Attribute</h4> |
|
157 <b>visit_Attribute</b>(<i>node</i>) |
|
158 <p> |
|
159 Public method to handle attributes. |
|
160 </p><dl> |
|
161 <dt><i>node</i> (ast.Attribute)</dt> |
|
162 <dd> |
|
163 reference to the node to be processed |
|
164 </dd> |
|
165 </dl><a NAME="BugBearVisitor.visit_Call" ID="BugBearVisitor.visit_Call"></a> |
|
166 <h4>BugBearVisitor.visit_Call</h4> |
|
167 <b>visit_Call</b>(<i>node</i>) |
|
168 <p> |
|
169 Public method to handle a function call. |
|
170 </p><dl> |
|
171 <dt><i>node</i> (ast.Call)</dt> |
|
172 <dd> |
|
173 reference to the node to be processed |
|
174 </dd> |
|
175 </dl><a NAME="BugBearVisitor.visit_For" ID="BugBearVisitor.visit_For"></a> |
|
176 <h4>BugBearVisitor.visit_For</h4> |
|
177 <b>visit_For</b>(<i>node</i>) |
|
178 <p> |
|
179 Public method to handle 'for' statements. |
|
180 </p><dl> |
|
181 <dt><i>node</i> (ast.For)</dt> |
|
182 <dd> |
|
183 reference to the node to be processed |
|
184 </dd> |
|
185 </dl><a NAME="BugBearVisitor.visit_UAdd" ID="BugBearVisitor.visit_UAdd"></a> |
|
186 <h4>BugBearVisitor.visit_UAdd</h4> |
|
187 <b>visit_UAdd</b>(<i>node</i>) |
|
188 <p> |
|
189 Public method to handle unary additions. |
|
190 </p><dl> |
|
191 <dt><i>node</i> (ast.UAdd)</dt> |
|
192 <dd> |
|
193 reference to the node to be processed |
|
194 </dd> |
|
195 </dl> |
|
196 <div align="right"><a href="#top">Up</a></div> |
|
197 <hr /><hr /> |
|
198 <a NAME="LoggingVisitor" ID="LoggingVisitor"></a> |
|
199 <h2>LoggingVisitor</h2> |
|
200 <p> |
|
201 Class implementing a node visitor to check logging statements. |
|
202 </p> |
|
203 <h3>Derived from</h3> |
|
204 ast.NodeVisitor |
|
205 <h3>Class Attributes</h3> |
|
206 <table> |
|
207 <tr><td>LoggingLevels</td></tr> |
|
208 </table> |
|
209 <h3>Class Methods</h3> |
|
210 <table> |
|
211 <tr><td>None</td></tr> |
|
212 </table> |
|
213 <h3>Methods</h3> |
|
214 <table> |
|
215 <tr> |
|
216 <td><a href="#LoggingVisitor.__init__">LoggingVisitor</a></td> |
|
217 <td>Constructor</td> |
|
218 </tr><tr> |
|
219 <td><a href="#LoggingVisitor.__detectLoggingLevel">__detectLoggingLevel</a></td> |
|
220 <td>Private method to decide whether an AST Call is a logging call.</td> |
|
221 </tr><tr> |
|
222 <td><a href="#LoggingVisitor.__isFormatCall">__isFormatCall</a></td> |
|
223 <td>Private method to check if a function call uses format.</td> |
|
224 </tr><tr> |
|
225 <td><a href="#LoggingVisitor.__withinExtraKeyword">__withinExtraKeyword</a></td> |
|
226 <td>Private method to check, if we are inside the extra keyword.</td> |
|
227 </tr><tr> |
|
228 <td><a href="#LoggingVisitor.__withinLoggingArgument">__withinLoggingArgument</a></td> |
|
229 <td>Private method to check, if we are inside a logging argument.</td> |
|
230 </tr><tr> |
|
231 <td><a href="#LoggingVisitor.__withinLoggingStatement">__withinLoggingStatement</a></td> |
|
232 <td>Private method to check, if we are inside a logging statement.</td> |
|
233 </tr><tr> |
|
234 <td><a href="#LoggingVisitor.visit_BinOp">visit_BinOp</a></td> |
|
235 <td>Public method to handle binary operations while processing the first logging argument.</td> |
|
236 </tr><tr> |
|
237 <td><a href="#LoggingVisitor.visit_Call">visit_Call</a></td> |
|
238 <td>Public method to handle a function call.</td> |
|
239 </tr><tr> |
|
240 <td><a href="#LoggingVisitor.visit_JoinedStr">visit_JoinedStr</a></td> |
|
241 <td>Public method to handle f-string arguments.</td> |
|
242 </tr> |
|
243 </table> |
|
244 <h3>Static Methods</h3> |
|
245 <table> |
|
246 <tr><td>None</td></tr> |
|
247 </table> |
|
248 <a NAME="LoggingVisitor.__init__" ID="LoggingVisitor.__init__"></a> |
|
249 <h4>LoggingVisitor (Constructor)</h4> |
|
250 <b>LoggingVisitor</b>(<i></i>) |
|
251 <p> |
|
252 Constructor |
|
253 </p><a NAME="LoggingVisitor.__detectLoggingLevel" ID="LoggingVisitor.__detectLoggingLevel"></a> |
|
254 <h4>LoggingVisitor.__detectLoggingLevel</h4> |
|
255 <b>__detectLoggingLevel</b>(<i>node</i>) |
|
256 <p> |
|
257 Private method to decide whether an AST Call is a logging call. |
|
258 </p><dl> |
|
259 <dt><i>node</i> (ast.Call)</dt> |
|
260 <dd> |
|
261 reference to the node to be processed |
|
262 </dd> |
|
263 </dl><dl> |
|
264 <dt>Returns:</dt> |
|
265 <dd> |
|
266 logging level |
|
267 </dd> |
|
268 </dl><dl> |
|
269 <dt>Return Type:</dt> |
|
270 <dd> |
|
271 str or None |
|
272 </dd> |
|
273 </dl><a NAME="LoggingVisitor.__isFormatCall" ID="LoggingVisitor.__isFormatCall"></a> |
|
274 <h4>LoggingVisitor.__isFormatCall</h4> |
|
275 <b>__isFormatCall</b>(<i>node</i>) |
|
276 <p> |
|
277 Private method to check if a function call uses format. |
|
278 </p><dl> |
|
279 <dt><i>node</i> (ast.Call)</dt> |
|
280 <dd> |
|
281 reference to the node to be processed |
|
282 </dd> |
|
283 </dl><dl> |
|
284 <dt>Returns:</dt> |
|
285 <dd> |
|
286 flag indicating the function call uses format |
|
287 </dd> |
|
288 </dl><dl> |
|
289 <dt>Return Type:</dt> |
|
290 <dd> |
|
291 bool |
|
292 </dd> |
|
293 </dl><a NAME="LoggingVisitor.__withinExtraKeyword" ID="LoggingVisitor.__withinExtraKeyword"></a> |
|
294 <h4>LoggingVisitor.__withinExtraKeyword</h4> |
|
295 <b>__withinExtraKeyword</b>(<i>node</i>) |
|
296 <p> |
|
297 Private method to check, if we are inside the extra keyword. |
|
298 </p><dl> |
|
299 <dt><i>node</i> (ast.keyword)</dt> |
|
300 <dd> |
|
301 reference to the node to be checked |
|
302 </dd> |
|
303 </dl><dl> |
|
304 <dt>Returns:</dt> |
|
305 <dd> |
|
306 flag indicating we are inside the extra keyword |
|
307 </dd> |
|
308 </dl><dl> |
|
309 <dt>Return Type:</dt> |
|
310 <dd> |
|
311 bool |
|
312 </dd> |
|
313 </dl><a NAME="LoggingVisitor.__withinLoggingArgument" ID="LoggingVisitor.__withinLoggingArgument"></a> |
|
314 <h4>LoggingVisitor.__withinLoggingArgument</h4> |
|
315 <b>__withinLoggingArgument</b>(<i></i>) |
|
316 <p> |
|
317 Private method to check, if we are inside a logging argument. |
|
318 </p><dl> |
|
319 <dt>Returns:</dt> |
|
320 <dd> |
|
321 flag indicating we are inside a logging argument |
|
322 </dd> |
|
323 </dl><dl> |
|
324 <dt>Return Type:</dt> |
|
325 <dd> |
|
326 bool |
|
327 </dd> |
|
328 </dl><a NAME="LoggingVisitor.__withinLoggingStatement" ID="LoggingVisitor.__withinLoggingStatement"></a> |
|
329 <h4>LoggingVisitor.__withinLoggingStatement</h4> |
|
330 <b>__withinLoggingStatement</b>(<i></i>) |
|
331 <p> |
|
332 Private method to check, if we are inside a logging statement. |
|
333 </p><dl> |
|
334 <dt>Returns:</dt> |
|
335 <dd> |
|
336 flag indicating we are inside a logging statement |
|
337 </dd> |
|
338 </dl><dl> |
|
339 <dt>Return Type:</dt> |
|
340 <dd> |
|
341 bool |
|
342 </dd> |
|
343 </dl><a NAME="LoggingVisitor.visit_BinOp" ID="LoggingVisitor.visit_BinOp"></a> |
|
344 <h4>LoggingVisitor.visit_BinOp</h4> |
|
345 <b>visit_BinOp</b>(<i>node</i>) |
|
346 <p> |
|
347 Public method to handle binary operations while processing the first |
|
348 logging argument. |
|
349 </p><dl> |
|
350 <dt><i>node</i> (ast.BinOp)</dt> |
|
351 <dd> |
|
352 reference to the node to be processed |
|
353 </dd> |
|
354 </dl><a NAME="LoggingVisitor.visit_Call" ID="LoggingVisitor.visit_Call"></a> |
|
355 <h4>LoggingVisitor.visit_Call</h4> |
|
356 <b>visit_Call</b>(<i>node</i>) |
|
357 <p> |
|
358 Public method to handle a function call. |
|
359 </p><p> |
|
360 Every logging statement and string format is expected to be a function |
|
361 call. |
|
362 </p><dl> |
|
363 <dt><i>node</i> (ast.Call)</dt> |
|
364 <dd> |
|
365 reference to the node to be processed |
|
366 </dd> |
|
367 </dl><a NAME="LoggingVisitor.visit_JoinedStr" ID="LoggingVisitor.visit_JoinedStr"></a> |
|
368 <h4>LoggingVisitor.visit_JoinedStr</h4> |
|
369 <b>visit_JoinedStr</b>(<i>node</i>) |
|
370 <p> |
|
371 Public method to handle f-string arguments. |
|
372 </p><dl> |
|
373 <dt><i>node</i> (ast.JoinedStr)</dt> |
|
374 <dd> |
|
375 reference to the node to be processed |
|
376 </dd> |
|
377 </dl> |
|
378 <div align="right"><a href="#top">Up</a></div> |
|
379 <hr /><hr /> |
|
380 <a NAME="MiscellaneousChecker" ID="MiscellaneousChecker"></a> |
|
381 <h2>MiscellaneousChecker</h2> |
|
382 <p> |
|
383 Class implementing a checker for miscellaneous checks. |
|
384 </p> |
|
385 <h3>Derived from</h3> |
|
386 object |
|
387 <h3>Class Attributes</h3> |
|
388 <table> |
|
389 <tr><td>BuiltinsWhiteList</td></tr><tr><td>Codes</td></tr><tr><td>FormatFieldRegex</td></tr><tr><td>Formatter</td></tr> |
|
390 </table> |
|
391 <h3>Class Methods</h3> |
|
392 <table> |
|
393 <tr><td>None</td></tr> |
|
394 </table> |
|
395 <h3>Methods</h3> |
|
396 <table> |
|
397 <tr> |
|
398 <td><a href="#MiscellaneousChecker.__init__">MiscellaneousChecker</a></td> |
|
399 <td>Constructor</td> |
|
400 </tr><tr> |
|
401 <td><a href="#MiscellaneousChecker.__checkBugBear">__checkBugBear</a></td> |
|
402 <td>Private method to bugbear checks.</td> |
|
403 </tr><tr> |
|
404 <td><a href="#MiscellaneousChecker.__checkBuiltins">__checkBuiltins</a></td> |
|
405 <td>Private method to check, if built-ins are shadowed.</td> |
|
406 </tr><tr> |
|
407 <td><a href="#MiscellaneousChecker.__checkCoding">__checkCoding</a></td> |
|
408 <td>Private method to check the presence of a coding line and valid encodings.</td> |
|
409 </tr><tr> |
|
410 <td><a href="#MiscellaneousChecker.__checkComprehensions">__checkComprehensions</a></td> |
|
411 <td>Private method to check some comprehension related things.</td> |
|
412 </tr><tr> |
|
413 <td><a href="#MiscellaneousChecker.__checkCopyright">__checkCopyright</a></td> |
|
414 <td>Private method to check the presence of a copyright statement.</td> |
|
415 </tr><tr> |
|
416 <td><a href="#MiscellaneousChecker.__checkDictWithSortedKeys">__checkDictWithSortedKeys</a></td> |
|
417 <td>Private method to check, if dictionary keys appear in sorted order.</td> |
|
418 </tr><tr> |
|
419 <td><a href="#MiscellaneousChecker.__checkFormatString">__checkFormatString</a></td> |
|
420 <td>Private method to check string format strings.</td> |
|
421 </tr><tr> |
|
422 <td><a href="#MiscellaneousChecker.__checkFuture">__checkFuture</a></td> |
|
423 <td>Private method to check the __future__ imports.</td> |
|
424 </tr><tr> |
|
425 <td><a href="#MiscellaneousChecker.__checkGettext">__checkGettext</a></td> |
|
426 <td>Private method to check the 'gettext' import statement.</td> |
|
427 </tr><tr> |
|
428 <td><a href="#MiscellaneousChecker.__checkLogging">__checkLogging</a></td> |
|
429 <td>Private method to check logging statements.</td> |
|
430 </tr><tr> |
|
431 <td><a href="#MiscellaneousChecker.__checkMutableDefault">__checkMutableDefault</a></td> |
|
432 <td>Private method to check for use of mutable types as default arguments.</td> |
|
433 </tr><tr> |
|
434 <td><a href="#MiscellaneousChecker.__checkPep3101">__checkPep3101</a></td> |
|
435 <td>Private method to check for old style string formatting.</td> |
|
436 </tr><tr> |
|
437 <td><a href="#MiscellaneousChecker.__checkPrintStatements">__checkPrintStatements</a></td> |
|
438 <td>Private method to check for print statements.</td> |
|
439 </tr><tr> |
|
440 <td><a href="#MiscellaneousChecker.__checkReturn">__checkReturn</a></td> |
|
441 <td>Private method to check return statements.</td> |
|
442 </tr><tr> |
|
443 <td><a href="#MiscellaneousChecker.__checkTuple">__checkTuple</a></td> |
|
444 <td>Private method to check for one element tuples.</td> |
|
445 </tr><tr> |
|
446 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td> |
|
447 <td>Private function to test, if the node should be checked.</td> |
|
448 </tr><tr> |
|
449 <td><a href="#MiscellaneousChecker.__error">__error</a></td> |
|
450 <td>Private method to record an issue.</td> |
|
451 </tr><tr> |
|
452 <td><a href="#MiscellaneousChecker.__getCoding">__getCoding</a></td> |
|
453 <td>Private method to get the defined coding of the source.</td> |
|
454 </tr><tr> |
|
455 <td><a href="#MiscellaneousChecker.__getFields">__getFields</a></td> |
|
456 <td>Private method to extract the format field information.</td> |
|
457 </tr><tr> |
|
458 <td><a href="#MiscellaneousChecker.__ignoreCode">__ignoreCode</a></td> |
|
459 <td>Private method to check if the message code should be ignored.</td> |
|
460 </tr><tr> |
|
461 <td><a href="#MiscellaneousChecker.__reportInvalidSyntax">__reportInvalidSyntax</a></td> |
|
462 <td>Private method to report a syntax error.</td> |
|
463 </tr><tr> |
|
464 <td><a href="#MiscellaneousChecker.run">run</a></td> |
|
465 <td>Public method to check the given source against miscellaneous conditions.</td> |
|
466 </tr> |
|
467 </table> |
|
468 <h3>Static Methods</h3> |
|
469 <table> |
|
470 <tr><td>None</td></tr> |
|
471 </table> |
|
472 <a NAME="MiscellaneousChecker.__init__" ID="MiscellaneousChecker.__init__"></a> |
|
473 <h4>MiscellaneousChecker (Constructor)</h4> |
|
474 <b>MiscellaneousChecker</b>(<i>source, filename, select, ignore, expected, repeat, args</i>) |
|
475 <p> |
|
476 Constructor |
|
477 </p><dl> |
|
478 <dt><i>source</i> (list of str)</dt> |
|
479 <dd> |
|
480 source code to be checked |
|
481 </dd><dt><i>filename</i> (str)</dt> |
|
482 <dd> |
|
483 name of the source file |
|
484 </dd><dt><i>select</i> (list of str)</dt> |
|
485 <dd> |
|
486 list of selected codes |
|
487 </dd><dt><i>ignore</i> (list of str)</dt> |
|
488 <dd> |
|
489 list of codes to be ignored |
|
490 </dd><dt><i>expected</i> (list of str)</dt> |
|
491 <dd> |
|
492 list of expected codes |
|
493 </dd><dt><i>repeat</i> (bool)</dt> |
|
494 <dd> |
|
495 flag indicating to report each occurrence of a code |
|
496 </dd><dt><i>args</i> (dict)</dt> |
|
497 <dd> |
|
498 dictionary of arguments for the miscellaneous checks |
|
499 </dd> |
|
500 </dl><a NAME="MiscellaneousChecker.__checkBugBear" ID="MiscellaneousChecker.__checkBugBear"></a> |
|
501 <h4>MiscellaneousChecker.__checkBugBear</h4> |
|
502 <b>__checkBugBear</b>(<i></i>) |
|
503 <p> |
|
504 Private method to bugbear checks. |
|
505 </p><a NAME="MiscellaneousChecker.__checkBuiltins" ID="MiscellaneousChecker.__checkBuiltins"></a> |
|
506 <h4>MiscellaneousChecker.__checkBuiltins</h4> |
|
507 <b>__checkBuiltins</b>(<i></i>) |
|
508 <p> |
|
509 Private method to check, if built-ins are shadowed. |
|
510 </p><a NAME="MiscellaneousChecker.__checkCoding" ID="MiscellaneousChecker.__checkCoding"></a> |
|
511 <h4>MiscellaneousChecker.__checkCoding</h4> |
|
512 <b>__checkCoding</b>(<i></i>) |
|
513 <p> |
|
514 Private method to check the presence of a coding line and valid |
|
515 encodings. |
|
516 </p><a NAME="MiscellaneousChecker.__checkComprehensions" ID="MiscellaneousChecker.__checkComprehensions"></a> |
|
517 <h4>MiscellaneousChecker.__checkComprehensions</h4> |
|
518 <b>__checkComprehensions</b>(<i></i>) |
|
519 <p> |
|
520 Private method to check some comprehension related things. |
|
521 </p><a NAME="MiscellaneousChecker.__checkCopyright" ID="MiscellaneousChecker.__checkCopyright"></a> |
|
522 <h4>MiscellaneousChecker.__checkCopyright</h4> |
|
523 <b>__checkCopyright</b>(<i></i>) |
|
524 <p> |
|
525 Private method to check the presence of a copyright statement. |
|
526 </p><a NAME="MiscellaneousChecker.__checkDictWithSortedKeys" ID="MiscellaneousChecker.__checkDictWithSortedKeys"></a> |
|
527 <h4>MiscellaneousChecker.__checkDictWithSortedKeys</h4> |
|
528 <b>__checkDictWithSortedKeys</b>(<i></i>) |
|
529 <p> |
|
530 Private method to check, if dictionary keys appear in sorted order. |
|
531 </p><a NAME="MiscellaneousChecker.__checkFormatString" ID="MiscellaneousChecker.__checkFormatString"></a> |
|
532 <h4>MiscellaneousChecker.__checkFormatString</h4> |
|
533 <b>__checkFormatString</b>(<i></i>) |
|
534 <p> |
|
535 Private method to check string format strings. |
|
536 </p><a NAME="MiscellaneousChecker.__checkFuture" ID="MiscellaneousChecker.__checkFuture"></a> |
|
537 <h4>MiscellaneousChecker.__checkFuture</h4> |
|
538 <b>__checkFuture</b>(<i></i>) |
|
539 <p> |
|
540 Private method to check the __future__ imports. |
|
541 </p><a NAME="MiscellaneousChecker.__checkGettext" ID="MiscellaneousChecker.__checkGettext"></a> |
|
542 <h4>MiscellaneousChecker.__checkGettext</h4> |
|
543 <b>__checkGettext</b>(<i></i>) |
|
544 <p> |
|
545 Private method to check the 'gettext' import statement. |
|
546 </p><a NAME="MiscellaneousChecker.__checkLogging" ID="MiscellaneousChecker.__checkLogging"></a> |
|
547 <h4>MiscellaneousChecker.__checkLogging</h4> |
|
548 <b>__checkLogging</b>(<i></i>) |
|
549 <p> |
|
550 Private method to check logging statements. |
|
551 </p><a NAME="MiscellaneousChecker.__checkMutableDefault" ID="MiscellaneousChecker.__checkMutableDefault"></a> |
|
552 <h4>MiscellaneousChecker.__checkMutableDefault</h4> |
|
553 <b>__checkMutableDefault</b>(<i></i>) |
|
554 <p> |
|
555 Private method to check for use of mutable types as default arguments. |
|
556 </p><a NAME="MiscellaneousChecker.__checkPep3101" ID="MiscellaneousChecker.__checkPep3101"></a> |
|
557 <h4>MiscellaneousChecker.__checkPep3101</h4> |
|
558 <b>__checkPep3101</b>(<i></i>) |
|
559 <p> |
|
560 Private method to check for old style string formatting. |
|
561 </p><a NAME="MiscellaneousChecker.__checkPrintStatements" ID="MiscellaneousChecker.__checkPrintStatements"></a> |
|
562 <h4>MiscellaneousChecker.__checkPrintStatements</h4> |
|
563 <b>__checkPrintStatements</b>(<i></i>) |
|
564 <p> |
|
565 Private method to check for print statements. |
|
566 </p><a NAME="MiscellaneousChecker.__checkReturn" ID="MiscellaneousChecker.__checkReturn"></a> |
|
567 <h4>MiscellaneousChecker.__checkReturn</h4> |
|
568 <b>__checkReturn</b>(<i></i>) |
|
569 <p> |
|
570 Private method to check return statements. |
|
571 </p><a NAME="MiscellaneousChecker.__checkTuple" ID="MiscellaneousChecker.__checkTuple"></a> |
|
572 <h4>MiscellaneousChecker.__checkTuple</h4> |
|
573 <b>__checkTuple</b>(<i></i>) |
|
574 <p> |
|
575 Private method to check for one element tuples. |
|
576 </p><a NAME="MiscellaneousChecker.__dictShouldBeChecked" ID="MiscellaneousChecker.__dictShouldBeChecked"></a> |
|
577 <h4>MiscellaneousChecker.__dictShouldBeChecked</h4> |
|
578 <b>__dictShouldBeChecked</b>(<i>node</i>) |
|
579 <p> |
|
580 Private function to test, if the node should be checked. |
|
581 </p><dl> |
|
582 <dt><i>node</i></dt> |
|
583 <dd> |
|
584 reference to the AST node |
|
585 </dd> |
|
586 </dl><dl> |
|
587 <dt>Returns:</dt> |
|
588 <dd> |
|
589 flag indicating to check the node |
|
590 </dd> |
|
591 </dl><dl> |
|
592 <dt>Return Type:</dt> |
|
593 <dd> |
|
594 bool |
|
595 </dd> |
|
596 </dl><a NAME="MiscellaneousChecker.__error" ID="MiscellaneousChecker.__error"></a> |
|
597 <h4>MiscellaneousChecker.__error</h4> |
|
598 <b>__error</b>(<i>lineNumber, offset, code, *args</i>) |
|
599 <p> |
|
600 Private method to record an issue. |
|
601 </p><dl> |
|
602 <dt><i>lineNumber</i> (int)</dt> |
|
603 <dd> |
|
604 line number of the issue |
|
605 </dd><dt><i>offset</i> (int)</dt> |
|
606 <dd> |
|
607 position within line of the issue |
|
608 </dd><dt><i>code</i> (str)</dt> |
|
609 <dd> |
|
610 message code |
|
611 </dd><dt><i>args</i> (list)</dt> |
|
612 <dd> |
|
613 arguments for the message |
|
614 </dd> |
|
615 </dl><a NAME="MiscellaneousChecker.__getCoding" ID="MiscellaneousChecker.__getCoding"></a> |
|
616 <h4>MiscellaneousChecker.__getCoding</h4> |
|
617 <b>__getCoding</b>(<i></i>) |
|
618 <p> |
|
619 Private method to get the defined coding of the source. |
|
620 </p><dl> |
|
621 <dt>Returns:</dt> |
|
622 <dd> |
|
623 tuple containing the line number and the coding |
|
624 </dd> |
|
625 </dl><dl> |
|
626 <dt>Return Type:</dt> |
|
627 <dd> |
|
628 tuple of int and str |
|
629 </dd> |
|
630 </dl><a NAME="MiscellaneousChecker.__getFields" ID="MiscellaneousChecker.__getFields"></a> |
|
631 <h4>MiscellaneousChecker.__getFields</h4> |
|
632 <b>__getFields</b>(<i>string</i>) |
|
633 <p> |
|
634 Private method to extract the format field information. |
|
635 </p><dl> |
|
636 <dt><i>string</i> (str)</dt> |
|
637 <dd> |
|
638 format string to be parsed |
|
639 </dd> |
|
640 </dl><dl> |
|
641 <dt>Returns:</dt> |
|
642 <dd> |
|
643 format field information as a tuple with fields, implicit |
|
644 field definitions present and explicit field definitions present |
|
645 </dd> |
|
646 </dl><dl> |
|
647 <dt>Return Type:</dt> |
|
648 <dd> |
|
649 tuple of set of str, bool, bool |
|
650 </dd> |
|
651 </dl><a NAME="MiscellaneousChecker.__ignoreCode" ID="MiscellaneousChecker.__ignoreCode"></a> |
|
652 <h4>MiscellaneousChecker.__ignoreCode</h4> |
|
653 <b>__ignoreCode</b>(<i>code</i>) |
|
654 <p> |
|
655 Private method to check if the message code should be ignored. |
|
656 </p><dl> |
|
657 <dt><i>code</i> (str)</dt> |
|
658 <dd> |
|
659 message code to check for |
|
660 </dd> |
|
661 </dl><dl> |
|
662 <dt>Returns:</dt> |
|
663 <dd> |
|
664 flag indicating to ignore the given code |
|
665 </dd> |
|
666 </dl><dl> |
|
667 <dt>Return Type:</dt> |
|
668 <dd> |
|
669 bool |
|
670 </dd> |
|
671 </dl><a NAME="MiscellaneousChecker.__reportInvalidSyntax" ID="MiscellaneousChecker.__reportInvalidSyntax"></a> |
|
672 <h4>MiscellaneousChecker.__reportInvalidSyntax</h4> |
|
673 <b>__reportInvalidSyntax</b>(<i></i>) |
|
674 <p> |
|
675 Private method to report a syntax error. |
|
676 </p><a NAME="MiscellaneousChecker.run" ID="MiscellaneousChecker.run"></a> |
|
677 <h4>MiscellaneousChecker.run</h4> |
|
678 <b>run</b>(<i></i>) |
|
679 <p> |
|
680 Public method to check the given source against miscellaneous |
|
681 conditions. |
|
682 </p> |
|
683 <div align="right"><a href="#top">Up</a></div> |
|
684 <hr /><hr /> |
|
685 <a NAME="NameFinder" ID="NameFinder"></a> |
|
686 <h2>NameFinder</h2> |
|
687 <p> |
|
688 Class to extract a name out of a tree of nodes. |
|
689 </p> |
|
690 <h3>Derived from</h3> |
|
691 ast.NodeVisitor |
|
692 <h3>Class Attributes</h3> |
|
693 <table> |
|
694 <tr><td>None</td></tr> |
|
695 </table> |
|
696 <h3>Class Methods</h3> |
|
697 <table> |
|
698 <tr><td>None</td></tr> |
|
699 </table> |
|
700 <h3>Methods</h3> |
|
701 <table> |
|
702 <tr> |
|
703 <td><a href="#NameFinder.__init__">NameFinder</a></td> |
|
704 <td>Constructor</td> |
|
705 </tr><tr> |
|
706 <td><a href="#NameFinder.getNames">getNames</a></td> |
|
707 <td>Public method to return the extracted names and Name nodes.</td> |
|
708 </tr><tr> |
|
709 <td><a href="#NameFinder.visit">visit</a></td> |
|
710 <td>Public method to traverse a given AST node.</td> |
|
711 </tr><tr> |
|
712 <td><a href="#NameFinder.visit_Name">visit_Name</a></td> |
|
713 <td>Public method to handle 'Name' nodes.</td> |
|
714 </tr> |
|
715 </table> |
|
716 <h3>Static Methods</h3> |
|
717 <table> |
|
718 <tr><td>None</td></tr> |
|
719 </table> |
|
720 <a NAME="NameFinder.__init__" ID="NameFinder.__init__"></a> |
|
721 <h4>NameFinder (Constructor)</h4> |
|
722 <b>NameFinder</b>(<i></i>) |
|
723 <p> |
|
724 Constructor |
|
725 </p><a NAME="NameFinder.getNames" ID="NameFinder.getNames"></a> |
|
726 <h4>NameFinder.getNames</h4> |
|
727 <b>getNames</b>(<i></i>) |
|
728 <p> |
|
729 Public method to return the extracted names and Name nodes. |
|
730 </p><dl> |
|
731 <dt>Returns:</dt> |
|
732 <dd> |
|
733 dictionary containing the names as keys and the list of nodes |
|
734 </dd> |
|
735 </dl><dl> |
|
736 <dt>Return Type:</dt> |
|
737 <dd> |
|
738 dict |
|
739 </dd> |
|
740 </dl><a NAME="NameFinder.visit" ID="NameFinder.visit"></a> |
|
741 <h4>NameFinder.visit</h4> |
|
742 <b>visit</b>(<i>node</i>) |
|
743 <p> |
|
744 Public method to traverse a given AST node. |
|
745 </p><dl> |
|
746 <dt><i>node</i> (ast.Node)</dt> |
|
747 <dd> |
|
748 AST node to be traversed |
|
749 </dd> |
|
750 </dl><a NAME="NameFinder.visit_Name" ID="NameFinder.visit_Name"></a> |
|
751 <h4>NameFinder.visit_Name</h4> |
|
752 <b>visit_Name</b>(<i>node</i>) |
|
753 <p> |
|
754 Public method to handle 'Name' nodes. |
|
755 </p><dl> |
|
756 <dt><i>node</i> (ast.Name)</dt> |
|
757 <dd> |
|
758 reference to the node to be processed |
|
759 </dd> |
|
760 </dl> |
|
761 <div align="right"><a href="#top">Up</a></div> |
|
762 <hr /><hr /> |
|
763 <a NAME="ReturnVisitor" ID="ReturnVisitor"></a> |
|
764 <h2>ReturnVisitor</h2> |
|
765 <p> |
|
766 Class implementing a node visitor to check return statements. |
|
767 </p> |
|
768 <h3>Derived from</h3> |
|
769 ast.NodeVisitor |
|
770 <h3>Class Attributes</h3> |
|
771 <table> |
|
772 <tr><td>Assigns</td></tr><tr><td>Refs</td></tr><tr><td>Returns</td></tr> |
|
773 </table> |
|
774 <h3>Class Methods</h3> |
|
775 <table> |
|
776 <tr><td>None</td></tr> |
|
777 </table> |
|
778 <h3>Methods</h3> |
|
779 <table> |
|
780 <tr> |
|
781 <td><a href="#ReturnVisitor.__init__">ReturnVisitor</a></td> |
|
782 <td>Constructor</td> |
|
783 </tr><tr> |
|
784 <td><a href="#ReturnVisitor.__checkFunction">__checkFunction</a></td> |
|
785 <td>Private method to check a function definition node.</td> |
|
786 </tr><tr> |
|
787 <td><a href="#ReturnVisitor.__checkImplicitReturn">__checkImplicitReturn</a></td> |
|
788 <td>Private method to check for an implicit return statement.</td> |
|
789 </tr><tr> |
|
790 <td><a href="#ReturnVisitor.__checkImplicitReturnValue">__checkImplicitReturnValue</a></td> |
|
791 <td>Private method to check for implicit return values.</td> |
|
792 </tr><tr> |
|
793 <td><a href="#ReturnVisitor.__checkUnnecessaryAssign">__checkUnnecessaryAssign</a></td> |
|
794 <td>Private method to check for an unnecessary assign statement.</td> |
|
795 </tr><tr> |
|
796 <td><a href="#ReturnVisitor.__checkUnnecessaryReturnNone">__checkUnnecessaryReturnNone</a></td> |
|
797 <td>Private method to check for an unnecessary 'return None' statement.</td> |
|
798 </tr><tr> |
|
799 <td><a href="#ReturnVisitor.__hasRefsBeforeNextAssign">__hasRefsBeforeNextAssign</a></td> |
|
800 <td>Private method to check for references before a following assign statement.</td> |
|
801 </tr><tr> |
|
802 <td><a href="#ReturnVisitor.__isNone">__isNone</a></td> |
|
803 <td>Private method to check, if a node value is None.</td> |
|
804 </tr><tr> |
|
805 <td><a href="#ReturnVisitor.__resultExists">__resultExists</a></td> |
|
806 <td>Private method to check the existance of a return result.</td> |
|
807 </tr><tr> |
|
808 <td><a href="#ReturnVisitor.__visitAssignTarget">__visitAssignTarget</a></td> |
|
809 <td>Private method to handle an assign target node.</td> |
|
810 </tr><tr> |
|
811 <td><a href="#ReturnVisitor.__visitWithStack">__visitWithStack</a></td> |
|
812 <td>Private method to traverse a given function node using a stack.</td> |
|
813 </tr><tr> |
|
814 <td><a href="#ReturnVisitor.assigns">assigns</a></td> |
|
815 <td>Public method to get the Assign nodes.</td> |
|
816 </tr><tr> |
|
817 <td><a href="#ReturnVisitor.refs">refs</a></td> |
|
818 <td>Public method to get the References nodes.</td> |
|
819 </tr><tr> |
|
820 <td><a href="#ReturnVisitor.returns">returns</a></td> |
|
821 <td>Public method to get the Return nodes.</td> |
|
822 </tr><tr> |
|
823 <td><a href="#ReturnVisitor.visit_Assign">visit_Assign</a></td> |
|
824 <td>Public method to handle an assign node.</td> |
|
825 </tr><tr> |
|
826 <td><a href="#ReturnVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td> |
|
827 <td>Public method to handle a function definition.</td> |
|
828 </tr><tr> |
|
829 <td><a href="#ReturnVisitor.visit_FunctionDef">visit_FunctionDef</a></td> |
|
830 <td>Public method to handle a function definition.</td> |
|
831 </tr><tr> |
|
832 <td><a href="#ReturnVisitor.visit_Name">visit_Name</a></td> |
|
833 <td>Public method to handle a name node.</td> |
|
834 </tr><tr> |
|
835 <td><a href="#ReturnVisitor.visit_Return">visit_Return</a></td> |
|
836 <td>Public method to handle a return node.</td> |
|
837 </tr> |
|
838 </table> |
|
839 <h3>Static Methods</h3> |
|
840 <table> |
|
841 <tr><td>None</td></tr> |
|
842 </table> |
|
843 <a NAME="ReturnVisitor.__init__" ID="ReturnVisitor.__init__"></a> |
|
844 <h4>ReturnVisitor (Constructor)</h4> |
|
845 <b>ReturnVisitor</b>(<i></i>) |
|
846 <p> |
|
847 Constructor |
|
848 </p><a NAME="ReturnVisitor.__checkFunction" ID="ReturnVisitor.__checkFunction"></a> |
|
849 <h4>ReturnVisitor.__checkFunction</h4> |
|
850 <b>__checkFunction</b>(<i>node</i>) |
|
851 <p> |
|
852 Private method to check a function definition node. |
|
853 </p><dl> |
|
854 <dt><i>node</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt> |
|
855 <dd> |
|
856 reference to the node to check |
|
857 </dd> |
|
858 </dl><a NAME="ReturnVisitor.__checkImplicitReturn" ID="ReturnVisitor.__checkImplicitReturn"></a> |
|
859 <h4>ReturnVisitor.__checkImplicitReturn</h4> |
|
860 <b>__checkImplicitReturn</b>(<i>node</i>) |
|
861 <p> |
|
862 Private method to check for an implicit return statement. |
|
863 </p><dl> |
|
864 <dt><i>node</i> (ast.AST)</dt> |
|
865 <dd> |
|
866 reference to the node to check |
|
867 </dd> |
|
868 </dl><a NAME="ReturnVisitor.__checkImplicitReturnValue" ID="ReturnVisitor.__checkImplicitReturnValue"></a> |
|
869 <h4>ReturnVisitor.__checkImplicitReturnValue</h4> |
|
870 <b>__checkImplicitReturnValue</b>(<i></i>) |
|
871 <p> |
|
872 Private method to check for implicit return values. |
|
873 </p><a NAME="ReturnVisitor.__checkUnnecessaryAssign" ID="ReturnVisitor.__checkUnnecessaryAssign"></a> |
|
874 <h4>ReturnVisitor.__checkUnnecessaryAssign</h4> |
|
875 <b>__checkUnnecessaryAssign</b>(<i>node</i>) |
|
876 <p> |
|
877 Private method to check for an unnecessary assign statement. |
|
878 </p><dl> |
|
879 <dt><i>node</i> (ast.AST)</dt> |
|
880 <dd> |
|
881 reference to the node to check |
|
882 </dd> |
|
883 </dl><a NAME="ReturnVisitor.__checkUnnecessaryReturnNone" ID="ReturnVisitor.__checkUnnecessaryReturnNone"></a> |
|
884 <h4>ReturnVisitor.__checkUnnecessaryReturnNone</h4> |
|
885 <b>__checkUnnecessaryReturnNone</b>(<i></i>) |
|
886 <p> |
|
887 Private method to check for an unnecessary 'return None' statement. |
|
888 </p><a NAME="ReturnVisitor.__hasRefsBeforeNextAssign" ID="ReturnVisitor.__hasRefsBeforeNextAssign"></a> |
|
889 <h4>ReturnVisitor.__hasRefsBeforeNextAssign</h4> |
|
890 <b>__hasRefsBeforeNextAssign</b>(<i>varname, returnLineno</i>) |
|
891 <p> |
|
892 Private method to check for references before a following assign |
|
893 statement. |
|
894 </p><dl> |
|
895 <dt><i>varname</i> (str)</dt> |
|
896 <dd> |
|
897 variable name to check for |
|
898 </dd><dt><i>returnLineno</i> (int)</dt> |
|
899 <dd> |
|
900 line number of the return statement |
|
901 </dd> |
|
902 </dl><dl> |
|
903 <dt>Returns:</dt> |
|
904 <dd> |
|
905 flag indicating the existence of references |
|
906 </dd> |
|
907 </dl><dl> |
|
908 <dt>Return Type:</dt> |
|
909 <dd> |
|
910 bool |
|
911 </dd> |
|
912 </dl><a NAME="ReturnVisitor.__isNone" ID="ReturnVisitor.__isNone"></a> |
|
913 <h4>ReturnVisitor.__isNone</h4> |
|
914 <b>__isNone</b>(<i>node</i>) |
|
915 <p> |
|
916 Private method to check, if a node value is None. |
|
917 </p><dl> |
|
918 <dt><i>node</i> (ast.AST)</dt> |
|
919 <dd> |
|
920 reference to the node to check |
|
921 </dd> |
|
922 </dl><dl> |
|
923 <dt>Returns:</dt> |
|
924 <dd> |
|
925 flag indicating the node contains a None value |
|
926 </dd> |
|
927 </dl><a NAME="ReturnVisitor.__resultExists" ID="ReturnVisitor.__resultExists"></a> |
|
928 <h4>ReturnVisitor.__resultExists</h4> |
|
929 <b>__resultExists</b>(<i></i>) |
|
930 <p> |
|
931 Private method to check the existance of a return result. |
|
932 </p><dl> |
|
933 <dt>Returns:</dt> |
|
934 <dd> |
|
935 flag indicating the existence of a return result |
|
936 </dd> |
|
937 </dl><dl> |
|
938 <dt>Return Type:</dt> |
|
939 <dd> |
|
940 bool |
|
941 </dd> |
|
942 </dl><a NAME="ReturnVisitor.__visitAssignTarget" ID="ReturnVisitor.__visitAssignTarget"></a> |
|
943 <h4>ReturnVisitor.__visitAssignTarget</h4> |
|
944 <b>__visitAssignTarget</b>(<i>node</i>) |
|
945 <p> |
|
946 Private method to handle an assign target node. |
|
947 </p><dl> |
|
948 <dt><i>node</i> (ast.AST)</dt> |
|
949 <dd> |
|
950 reference to the node to handle |
|
951 </dd> |
|
952 </dl><a NAME="ReturnVisitor.__visitWithStack" ID="ReturnVisitor.__visitWithStack"></a> |
|
953 <h4>ReturnVisitor.__visitWithStack</h4> |
|
954 <b>__visitWithStack</b>(<i>node</i>) |
|
955 <p> |
|
956 Private method to traverse a given function node using a stack. |
|
957 </p><dl> |
|
958 <dt><i>node</i> (ast.FunctionDef or ast.AsyncFunctionDef)</dt> |
|
959 <dd> |
|
960 AST node to be traversed |
|
961 </dd> |
|
962 </dl><a NAME="ReturnVisitor.assigns" ID="ReturnVisitor.assigns"></a> |
|
963 <h4>ReturnVisitor.assigns</h4> |
|
964 <b>assigns</b>(<i></i>) |
|
965 <p> |
|
966 Public method to get the Assign nodes. |
|
967 </p><dl> |
|
968 <dt>Returns:</dt> |
|
969 <dd> |
|
970 dictionary containing the node name as key and line number |
|
971 as value |
|
972 </dd> |
|
973 </dl><dl> |
|
974 <dt>Return Type:</dt> |
|
975 <dd> |
|
976 dict |
|
977 </dd> |
|
978 </dl><a NAME="ReturnVisitor.refs" ID="ReturnVisitor.refs"></a> |
|
979 <h4>ReturnVisitor.refs</h4> |
|
980 <b>refs</b>(<i></i>) |
|
981 <p> |
|
982 Public method to get the References nodes. |
|
983 </p><dl> |
|
984 <dt>Returns:</dt> |
|
985 <dd> |
|
986 dictionary containing the node name as key and line number |
|
987 as value |
|
988 </dd> |
|
989 </dl><dl> |
|
990 <dt>Return Type:</dt> |
|
991 <dd> |
|
992 dict |
|
993 </dd> |
|
994 </dl><a NAME="ReturnVisitor.returns" ID="ReturnVisitor.returns"></a> |
|
995 <h4>ReturnVisitor.returns</h4> |
|
996 <b>returns</b>(<i></i>) |
|
997 <p> |
|
998 Public method to get the Return nodes. |
|
999 </p><dl> |
|
1000 <dt>Returns:</dt> |
|
1001 <dd> |
|
1002 dictionary containing the node name as key and line number |
|
1003 as value |
|
1004 </dd> |
|
1005 </dl><dl> |
|
1006 <dt>Return Type:</dt> |
|
1007 <dd> |
|
1008 dict |
|
1009 </dd> |
|
1010 </dl><a NAME="ReturnVisitor.visit_Assign" ID="ReturnVisitor.visit_Assign"></a> |
|
1011 <h4>ReturnVisitor.visit_Assign</h4> |
|
1012 <b>visit_Assign</b>(<i>node</i>) |
|
1013 <p> |
|
1014 Public method to handle an assign node. |
|
1015 </p><dl> |
|
1016 <dt><i>node</i> (ast.Assign)</dt> |
|
1017 <dd> |
|
1018 reference to the node to handle |
|
1019 </dd> |
|
1020 </dl><a NAME="ReturnVisitor.visit_AsyncFunctionDef" ID="ReturnVisitor.visit_AsyncFunctionDef"></a> |
|
1021 <h4>ReturnVisitor.visit_AsyncFunctionDef</h4> |
|
1022 <b>visit_AsyncFunctionDef</b>(<i>node</i>) |
|
1023 <p> |
|
1024 Public method to handle a function definition. |
|
1025 </p><dl> |
|
1026 <dt><i>node</i> (ast.AsyncFunctionDef)</dt> |
|
1027 <dd> |
|
1028 reference to the node to handle |
|
1029 </dd> |
|
1030 </dl><a NAME="ReturnVisitor.visit_FunctionDef" ID="ReturnVisitor.visit_FunctionDef"></a> |
|
1031 <h4>ReturnVisitor.visit_FunctionDef</h4> |
|
1032 <b>visit_FunctionDef</b>(<i>node</i>) |
|
1033 <p> |
|
1034 Public method to handle a function definition. |
|
1035 </p><dl> |
|
1036 <dt><i>node</i> (ast.FunctionDef)</dt> |
|
1037 <dd> |
|
1038 reference to the node to handle |
|
1039 </dd> |
|
1040 </dl><a NAME="ReturnVisitor.visit_Name" ID="ReturnVisitor.visit_Name"></a> |
|
1041 <h4>ReturnVisitor.visit_Name</h4> |
|
1042 <b>visit_Name</b>(<i>node</i>) |
|
1043 <p> |
|
1044 Public method to handle a name node. |
|
1045 </p><dl> |
|
1046 <dt><i>node</i> (ast.Name)</dt> |
|
1047 <dd> |
|
1048 reference to the node to handle |
|
1049 </dd> |
|
1050 </dl><a NAME="ReturnVisitor.visit_Return" ID="ReturnVisitor.visit_Return"></a> |
|
1051 <h4>ReturnVisitor.visit_Return</h4> |
|
1052 <b>visit_Return</b>(<i>node</i>) |
|
1053 <p> |
|
1054 Public method to handle a return node. |
|
1055 </p><dl> |
|
1056 <dt><i>node</i> (ast.Return)</dt> |
|
1057 <dd> |
|
1058 reference to the node to handle |
|
1059 </dd> |
|
1060 </dl> |
|
1061 <div align="right"><a href="#top">Up</a></div> |
|
1062 <hr /><hr /> |
|
1063 <a NAME="TextVisitor" ID="TextVisitor"></a> |
|
1064 <h2>TextVisitor</h2> |
|
1065 <p> |
|
1066 Class implementing a node visitor for bytes and str instances. |
|
1067 </p><p> |
|
1068 It tries to detect docstrings as string of the first expression of each |
|
1069 module, class or function. |
|
1070 </p> |
|
1071 <h3>Derived from</h3> |
|
1072 ast.NodeVisitor |
|
1073 <h3>Class Attributes</h3> |
|
1074 <table> |
|
1075 <tr><td>None</td></tr> |
|
1076 </table> |
|
1077 <h3>Class Methods</h3> |
|
1078 <table> |
|
1079 <tr><td>None</td></tr> |
|
1080 </table> |
|
1081 <h3>Methods</h3> |
|
1082 <table> |
|
1083 <tr> |
|
1084 <td><a href="#TextVisitor.__init__">TextVisitor</a></td> |
|
1085 <td>Constructor</td> |
|
1086 </tr><tr> |
|
1087 <td><a href="#TextVisitor.__addNode">__addNode</a></td> |
|
1088 <td>Private method to add a node to our list of nodes.</td> |
|
1089 </tr><tr> |
|
1090 <td><a href="#TextVisitor.__isBaseString">__isBaseString</a></td> |
|
1091 <td>Private method to determine, if a node is a base string node.</td> |
|
1092 </tr><tr> |
|
1093 <td><a href="#TextVisitor.__visitBody">__visitBody</a></td> |
|
1094 <td>Private method to traverse the body of the node manually.</td> |
|
1095 </tr><tr> |
|
1096 <td><a href="#TextVisitor.__visitDefinition">__visitDefinition</a></td> |
|
1097 <td>Private method handling class and function definitions.</td> |
|
1098 </tr><tr> |
|
1099 <td><a href="#TextVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td> |
|
1100 <td>Public method to handle an asynchronous function definition.</td> |
|
1101 </tr><tr> |
|
1102 <td><a href="#TextVisitor.visit_Bytes">visit_Bytes</a></td> |
|
1103 <td>Public method to record a bytes node.</td> |
|
1104 </tr><tr> |
|
1105 <td><a href="#TextVisitor.visit_Call">visit_Call</a></td> |
|
1106 <td>Public method to handle a function call.</td> |
|
1107 </tr><tr> |
|
1108 <td><a href="#TextVisitor.visit_ClassDef">visit_ClassDef</a></td> |
|
1109 <td>Public method to handle a class definition.</td> |
|
1110 </tr><tr> |
|
1111 <td><a href="#TextVisitor.visit_FunctionDef">visit_FunctionDef</a></td> |
|
1112 <td>Public method to handle a function definition.</td> |
|
1113 </tr><tr> |
|
1114 <td><a href="#TextVisitor.visit_Module">visit_Module</a></td> |
|
1115 <td>Public method to handle a module.</td> |
|
1116 </tr><tr> |
|
1117 <td><a href="#TextVisitor.visit_Str">visit_Str</a></td> |
|
1118 <td>Public method to record a string node.</td> |
|
1119 </tr> |
|
1120 </table> |
|
1121 <h3>Static Methods</h3> |
|
1122 <table> |
|
1123 <tr><td>None</td></tr> |
|
1124 </table> |
|
1125 <a NAME="TextVisitor.__init__" ID="TextVisitor.__init__"></a> |
|
1126 <h4>TextVisitor (Constructor)</h4> |
|
1127 <b>TextVisitor</b>(<i></i>) |
|
1128 <p> |
|
1129 Constructor |
|
1130 </p><a NAME="TextVisitor.__addNode" ID="TextVisitor.__addNode"></a> |
|
1131 <h4>TextVisitor.__addNode</h4> |
|
1132 <b>__addNode</b>(<i>node</i>) |
|
1133 <p> |
|
1134 Private method to add a node to our list of nodes. |
|
1135 </p><dl> |
|
1136 <dt><i>node</i> (ast.AST)</dt> |
|
1137 <dd> |
|
1138 reference to the node to add |
|
1139 </dd> |
|
1140 </dl><a NAME="TextVisitor.__isBaseString" ID="TextVisitor.__isBaseString"></a> |
|
1141 <h4>TextVisitor.__isBaseString</h4> |
|
1142 <b>__isBaseString</b>(<i>node</i>) |
|
1143 <p> |
|
1144 Private method to determine, if a node is a base string node. |
|
1145 </p><dl> |
|
1146 <dt><i>node</i> (ast.AST)</dt> |
|
1147 <dd> |
|
1148 reference to the node to check |
|
1149 </dd> |
|
1150 </dl><dl> |
|
1151 <dt>Returns:</dt> |
|
1152 <dd> |
|
1153 flag indicating a base string |
|
1154 </dd> |
|
1155 </dl><dl> |
|
1156 <dt>Return Type:</dt> |
|
1157 <dd> |
|
1158 bool |
|
1159 </dd> |
|
1160 </dl><a NAME="TextVisitor.__visitBody" ID="TextVisitor.__visitBody"></a> |
|
1161 <h4>TextVisitor.__visitBody</h4> |
|
1162 <b>__visitBody</b>(<i>node</i>) |
|
1163 <p> |
|
1164 Private method to traverse the body of the node manually. |
|
1165 </p><p> |
|
1166 If the first node is an expression which contains a string or bytes it |
|
1167 marks that as a docstring. |
|
1168 </p><dl> |
|
1169 <dt><i>node</i> (ast.AST)</dt> |
|
1170 <dd> |
|
1171 reference to the node to traverse |
|
1172 </dd> |
|
1173 </dl><a NAME="TextVisitor.__visitDefinition" ID="TextVisitor.__visitDefinition"></a> |
|
1174 <h4>TextVisitor.__visitDefinition</h4> |
|
1175 <b>__visitDefinition</b>(<i>node</i>) |
|
1176 <p> |
|
1177 Private method handling class and function definitions. |
|
1178 </p><dl> |
|
1179 <dt><i>node</i> (ast.FunctionDef, ast.AsyncFunctionDef or ast.ClassDef)</dt> |
|
1180 <dd> |
|
1181 reference to the node to handle |
|
1182 </dd> |
|
1183 </dl><a NAME="TextVisitor.visit_AsyncFunctionDef" ID="TextVisitor.visit_AsyncFunctionDef"></a> |
|
1184 <h4>TextVisitor.visit_AsyncFunctionDef</h4> |
|
1185 <b>visit_AsyncFunctionDef</b>(<i>node</i>) |
|
1186 <p> |
|
1187 Public method to handle an asynchronous function definition. |
|
1188 </p><dl> |
|
1189 <dt><i>node</i> (ast.AsyncFunctionDef)</dt> |
|
1190 <dd> |
|
1191 reference to the node to handle |
|
1192 </dd> |
|
1193 </dl><a NAME="TextVisitor.visit_Bytes" ID="TextVisitor.visit_Bytes"></a> |
|
1194 <h4>TextVisitor.visit_Bytes</h4> |
|
1195 <b>visit_Bytes</b>(<i>node</i>) |
|
1196 <p> |
|
1197 Public method to record a bytes node. |
|
1198 </p><dl> |
|
1199 <dt><i>node</i> (ast.Bytes)</dt> |
|
1200 <dd> |
|
1201 reference to the bytes node |
|
1202 </dd> |
|
1203 </dl><a NAME="TextVisitor.visit_Call" ID="TextVisitor.visit_Call"></a> |
|
1204 <h4>TextVisitor.visit_Call</h4> |
|
1205 <b>visit_Call</b>(<i>node</i>) |
|
1206 <p> |
|
1207 Public method to handle a function call. |
|
1208 </p><dl> |
|
1209 <dt><i>node</i> (ast.Call)</dt> |
|
1210 <dd> |
|
1211 reference to the node to handle |
|
1212 </dd> |
|
1213 </dl><a NAME="TextVisitor.visit_ClassDef" ID="TextVisitor.visit_ClassDef"></a> |
|
1214 <h4>TextVisitor.visit_ClassDef</h4> |
|
1215 <b>visit_ClassDef</b>(<i>node</i>) |
|
1216 <p> |
|
1217 Public method to handle a class definition. |
|
1218 </p><dl> |
|
1219 <dt><i>node</i> (ast.ClassDef)</dt> |
|
1220 <dd> |
|
1221 reference to the node to handle |
|
1222 </dd> |
|
1223 </dl><a NAME="TextVisitor.visit_FunctionDef" ID="TextVisitor.visit_FunctionDef"></a> |
|
1224 <h4>TextVisitor.visit_FunctionDef</h4> |
|
1225 <b>visit_FunctionDef</b>(<i>node</i>) |
|
1226 <p> |
|
1227 Public method to handle a function definition. |
|
1228 </p><dl> |
|
1229 <dt><i>node</i> (ast.FunctionDef)</dt> |
|
1230 <dd> |
|
1231 reference to the node to handle |
|
1232 </dd> |
|
1233 </dl><a NAME="TextVisitor.visit_Module" ID="TextVisitor.visit_Module"></a> |
|
1234 <h4>TextVisitor.visit_Module</h4> |
|
1235 <b>visit_Module</b>(<i>node</i>) |
|
1236 <p> |
|
1237 Public method to handle a module. |
|
1238 </p><dl> |
|
1239 <dt><i>node</i> (ast.Module)</dt> |
|
1240 <dd> |
|
1241 reference to the node to handle |
|
1242 </dd> |
|
1243 </dl><a NAME="TextVisitor.visit_Str" ID="TextVisitor.visit_Str"></a> |
|
1244 <h4>TextVisitor.visit_Str</h4> |
|
1245 <b>visit_Str</b>(<i>node</i>) |
|
1246 <p> |
|
1247 Public method to record a string node. |
|
1248 </p><dl> |
|
1249 <dt><i>node</i> (ast.Str)</dt> |
|
1250 <dd> |
|
1251 reference to the string node |
|
1252 </dd> |
|
1253 </dl> |
|
1254 <div align="right"><a href="#top">Up</a></div> |
|
1255 <hr /><hr /> |
|
1256 <a NAME="composeCallPath" ID="composeCallPath"></a> |
|
1257 <h2>composeCallPath</h2> |
|
1258 <b>composeCallPath</b>(<i>node</i>) |
|
1259 <p> |
|
1260 Generator function to assemble the call path of a given node. |
|
1261 </p><dl> |
|
1262 <dt><i>node</i> (ast.Node)</dt> |
|
1263 <dd> |
|
1264 node to assemble call path for |
|
1265 </dd> |
|
1266 </dl><dl> |
|
1267 <dt>Returns:</dt> |
|
1268 <dd> |
|
1269 call path components |
|
1270 </dd> |
|
1271 </dl><dl> |
|
1272 <dt>Return Type:</dt> |
|
1273 <dd> |
|
1274 str |
|
1275 </dd> |
|
1276 </dl> |
|
1277 <div align="right"><a href="#top">Up</a></div> |
|
1278 <hr /> |
|
1279 </body></html> |