31 <table> |
31 <table> |
32 <tr> |
32 <tr> |
33 <td><a href="#BugBearVisitor">BugBearVisitor</a></td> |
33 <td><a href="#BugBearVisitor">BugBearVisitor</a></td> |
34 <td>Class implementing a node visitor to check for various topics.</td> |
34 <td>Class implementing a node visitor to check for various topics.</td> |
35 </tr><tr> |
35 </tr><tr> |
|
36 <td><a href="#DateTimeVisitor">DateTimeVisitor</a></td> |
|
37 <td>Class implementing a node visitor to check datetime function calls.</td> |
|
38 </tr><tr> |
36 <td><a href="#LoggingVisitor">LoggingVisitor</a></td> |
39 <td><a href="#LoggingVisitor">LoggingVisitor</a></td> |
37 <td>Class implementing a node visitor to check logging statements.</td> |
40 <td>Class implementing a node visitor to check logging statements.</td> |
38 </tr><tr> |
41 </tr><tr> |
39 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> |
42 <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> |
40 <td>Class implementing a checker for miscellaneous checks.</td> |
43 <td>Class implementing a checker for miscellaneous checks.</td> |
219 reference to the node to be processed |
222 reference to the node to be processed |
220 </dd> |
223 </dd> |
221 </dl> |
224 </dl> |
222 <div align="right"><a href="#top">Up</a></div> |
225 <div align="right"><a href="#top">Up</a></div> |
223 <hr /><hr /> |
226 <hr /><hr /> |
|
227 <a NAME="DateTimeVisitor" ID="DateTimeVisitor"></a> |
|
228 <h2>DateTimeVisitor</h2> |
|
229 <p> |
|
230 Class implementing a node visitor to check datetime function calls. |
|
231 </p><p> |
|
232 Note: This class is modelled after flake8_datetimez checker. |
|
233 </p> |
|
234 <h3>Derived from</h3> |
|
235 ast.NodeVisitor |
|
236 <h3>Class Attributes</h3> |
|
237 <table> |
|
238 <tr><td>None</td></tr> |
|
239 </table> |
|
240 <h3>Class Methods</h3> |
|
241 <table> |
|
242 <tr><td>None</td></tr> |
|
243 </table> |
|
244 <h3>Methods</h3> |
|
245 <table> |
|
246 <tr> |
|
247 <td><a href="#DateTimeVisitor.__init__">DateTimeVisitor</a></td> |
|
248 <td>Constructor</td> |
|
249 </tr><tr> |
|
250 <td><a href="#DateTimeVisitor.__getFromKeywords">__getFromKeywords</a></td> |
|
251 <td>Private method to get a keyword node given its name.</td> |
|
252 </tr><tr> |
|
253 <td><a href="#DateTimeVisitor.visit_Call">visit_Call</a></td> |
|
254 <td>Public method to handle a function call.</td> |
|
255 </tr> |
|
256 </table> |
|
257 <h3>Static Methods</h3> |
|
258 <table> |
|
259 <tr><td>None</td></tr> |
|
260 </table> |
|
261 <a NAME="DateTimeVisitor.__init__" ID="DateTimeVisitor.__init__"></a> |
|
262 <h4>DateTimeVisitor (Constructor)</h4> |
|
263 <b>DateTimeVisitor</b>(<i></i>) |
|
264 <p> |
|
265 Constructor |
|
266 </p><a NAME="DateTimeVisitor.__getFromKeywords" ID="DateTimeVisitor.__getFromKeywords"></a> |
|
267 <h4>DateTimeVisitor.__getFromKeywords</h4> |
|
268 <b>__getFromKeywords</b>(<i>keywords, name</i>) |
|
269 <p> |
|
270 Private method to get a keyword node given its name. |
|
271 </p><dl> |
|
272 <dt><i>keywords</i> (list of ast.AST)</dt> |
|
273 <dd> |
|
274 list of keyword argument nodes |
|
275 </dd><dt><i>name</i> (str)</dt> |
|
276 <dd> |
|
277 name of the keyword node |
|
278 </dd> |
|
279 </dl><dl> |
|
280 <dt>Returns:</dt> |
|
281 <dd> |
|
282 keyword node |
|
283 </dd> |
|
284 </dl><dl> |
|
285 <dt>Return Type:</dt> |
|
286 <dd> |
|
287 ast.AST |
|
288 </dd> |
|
289 </dl><a NAME="DateTimeVisitor.visit_Call" ID="DateTimeVisitor.visit_Call"></a> |
|
290 <h4>DateTimeVisitor.visit_Call</h4> |
|
291 <b>visit_Call</b>(<i>node</i>) |
|
292 <p> |
|
293 Public method to handle a function call. |
|
294 </p><p> |
|
295 Every datetime related function call is check for use of the naive |
|
296 variant (i.e. use without TZ info). |
|
297 </p><dl> |
|
298 <dt><i>node</i> (ast.Call)</dt> |
|
299 <dd> |
|
300 reference to the node to be processed |
|
301 </dd> |
|
302 </dl> |
|
303 <div align="right"><a href="#top">Up</a></div> |
|
304 <hr /><hr /> |
224 <a NAME="LoggingVisitor" ID="LoggingVisitor"></a> |
305 <a NAME="LoggingVisitor" ID="LoggingVisitor"></a> |
225 <h2>LoggingVisitor</h2> |
306 <h2>LoggingVisitor</h2> |
226 <p> |
307 <p> |
227 Class implementing a node visitor to check logging statements. |
308 Class implementing a node visitor to check logging statements. |
228 </p> |
309 </p> |
440 <td>Private method to check some comprehension related things.</td> |
521 <td>Private method to check some comprehension related things.</td> |
441 </tr><tr> |
522 </tr><tr> |
442 <td><a href="#MiscellaneousChecker.__checkCopyright">__checkCopyright</a></td> |
523 <td><a href="#MiscellaneousChecker.__checkCopyright">__checkCopyright</a></td> |
443 <td>Private method to check the presence of a copyright statement.</td> |
524 <td>Private method to check the presence of a copyright statement.</td> |
444 </tr><tr> |
525 </tr><tr> |
|
526 <td><a href="#MiscellaneousChecker.__checkDateTime">__checkDateTime</a></td> |
|
527 <td>Private method to check use of naive datetime functions.</td> |
|
528 </tr><tr> |
445 <td><a href="#MiscellaneousChecker.__checkDictWithSortedKeys">__checkDictWithSortedKeys</a></td> |
529 <td><a href="#MiscellaneousChecker.__checkDictWithSortedKeys">__checkDictWithSortedKeys</a></td> |
446 <td>Private method to check, if dictionary keys appear in sorted order.</td> |
530 <td>Private method to check, if dictionary keys appear in sorted order.</td> |
447 </tr><tr> |
531 </tr><tr> |
448 <td><a href="#MiscellaneousChecker.__checkFormatString">__checkFormatString</a></td> |
532 <td><a href="#MiscellaneousChecker.__checkFormatString">__checkFormatString</a></td> |
449 <td>Private method to check string format strings.</td> |
533 <td>Private method to check string format strings.</td> |
453 </tr><tr> |
537 </tr><tr> |
454 <td><a href="#MiscellaneousChecker.__checkGettext">__checkGettext</a></td> |
538 <td><a href="#MiscellaneousChecker.__checkGettext">__checkGettext</a></td> |
455 <td>Private method to check the 'gettext' import statement.</td> |
539 <td>Private method to check the 'gettext' import statement.</td> |
456 </tr><tr> |
540 </tr><tr> |
457 <td><a href="#MiscellaneousChecker.__checkLineContinuation">__checkLineContinuation</a></td> |
541 <td><a href="#MiscellaneousChecker.__checkLineContinuation">__checkLineContinuation</a></td> |
458 <td>Private method to check öine continuation using '\'.</td> |
542 <td>Private method to check line continuation using backslash.</td> |
459 </tr><tr> |
543 </tr><tr> |
460 <td><a href="#MiscellaneousChecker.__checkLogging">__checkLogging</a></td> |
544 <td><a href="#MiscellaneousChecker.__checkLogging">__checkLogging</a></td> |
461 <td>Private method to check logging statements.</td> |
545 <td>Private method to check logging statements.</td> |
462 </tr><tr> |
546 </tr><tr> |
463 <td><a href="#MiscellaneousChecker.__checkMutableDefault">__checkMutableDefault</a></td> |
547 <td><a href="#MiscellaneousChecker.__checkMutableDefault">__checkMutableDefault</a></td> |
478 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td> |
562 <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td> |
479 <td>Private function to test, if the node should be checked.</td> |
563 <td>Private function to test, if the node should be checked.</td> |
480 </tr><tr> |
564 </tr><tr> |
481 <td><a href="#MiscellaneousChecker.__error">__error</a></td> |
565 <td><a href="#MiscellaneousChecker.__error">__error</a></td> |
482 <td>Private method to record an issue.</td> |
566 <td>Private method to record an issue.</td> |
|
567 </tr><tr> |
|
568 <td><a href="#MiscellaneousChecker.__generateTree">__generateTree</a></td> |
|
569 <td>Private method to generate an AST for our source.</td> |
483 </tr><tr> |
570 </tr><tr> |
484 <td><a href="#MiscellaneousChecker.__getCoding">__getCoding</a></td> |
571 <td><a href="#MiscellaneousChecker.__getCoding">__getCoding</a></td> |
485 <td>Private method to get the defined coding of the source.</td> |
572 <td>Private method to get the defined coding of the source.</td> |
486 </tr><tr> |
573 </tr><tr> |
487 <td><a href="#MiscellaneousChecker.__getFields">__getFields</a></td> |
574 <td><a href="#MiscellaneousChecker.__getFields">__getFields</a></td> |
558 </p><a NAME="MiscellaneousChecker.__checkCopyright" ID="MiscellaneousChecker.__checkCopyright"></a> |
645 </p><a NAME="MiscellaneousChecker.__checkCopyright" ID="MiscellaneousChecker.__checkCopyright"></a> |
559 <h4>MiscellaneousChecker.__checkCopyright</h4> |
646 <h4>MiscellaneousChecker.__checkCopyright</h4> |
560 <b>__checkCopyright</b>(<i></i>) |
647 <b>__checkCopyright</b>(<i></i>) |
561 <p> |
648 <p> |
562 Private method to check the presence of a copyright statement. |
649 Private method to check the presence of a copyright statement. |
|
650 </p><a NAME="MiscellaneousChecker.__checkDateTime" ID="MiscellaneousChecker.__checkDateTime"></a> |
|
651 <h4>MiscellaneousChecker.__checkDateTime</h4> |
|
652 <b>__checkDateTime</b>(<i></i>) |
|
653 <p> |
|
654 Private method to check use of naive datetime functions. |
563 </p><a NAME="MiscellaneousChecker.__checkDictWithSortedKeys" ID="MiscellaneousChecker.__checkDictWithSortedKeys"></a> |
655 </p><a NAME="MiscellaneousChecker.__checkDictWithSortedKeys" ID="MiscellaneousChecker.__checkDictWithSortedKeys"></a> |
564 <h4>MiscellaneousChecker.__checkDictWithSortedKeys</h4> |
656 <h4>MiscellaneousChecker.__checkDictWithSortedKeys</h4> |
565 <b>__checkDictWithSortedKeys</b>(<i></i>) |
657 <b>__checkDictWithSortedKeys</b>(<i></i>) |
566 <p> |
658 <p> |
567 Private method to check, if dictionary keys appear in sorted order. |
659 Private method to check, if dictionary keys appear in sorted order. |
582 Private method to check the 'gettext' import statement. |
674 Private method to check the 'gettext' import statement. |
583 </p><a NAME="MiscellaneousChecker.__checkLineContinuation" ID="MiscellaneousChecker.__checkLineContinuation"></a> |
675 </p><a NAME="MiscellaneousChecker.__checkLineContinuation" ID="MiscellaneousChecker.__checkLineContinuation"></a> |
584 <h4>MiscellaneousChecker.__checkLineContinuation</h4> |
676 <h4>MiscellaneousChecker.__checkLineContinuation</h4> |
585 <b>__checkLineContinuation</b>(<i></i>) |
677 <b>__checkLineContinuation</b>(<i></i>) |
586 <p> |
678 <p> |
587 Private method to check öine continuation using '\'. |
679 Private method to check line continuation using backslash. |
588 </p><a NAME="MiscellaneousChecker.__checkLogging" ID="MiscellaneousChecker.__checkLogging"></a> |
680 </p><a NAME="MiscellaneousChecker.__checkLogging" ID="MiscellaneousChecker.__checkLogging"></a> |
589 <h4>MiscellaneousChecker.__checkLogging</h4> |
681 <h4>MiscellaneousChecker.__checkLogging</h4> |
590 <b>__checkLogging</b>(<i></i>) |
682 <b>__checkLogging</b>(<i></i>) |
591 <p> |
683 <p> |
592 Private method to check logging statements. |
684 Private method to check logging statements. |
651 <dd> |
743 <dd> |
652 message code |
744 message code |
653 </dd><dt><i>args</i> (list)</dt> |
745 </dd><dt><i>args</i> (list)</dt> |
654 <dd> |
746 <dd> |
655 arguments for the message |
747 arguments for the message |
|
748 </dd> |
|
749 </dl><a NAME="MiscellaneousChecker.__generateTree" ID="MiscellaneousChecker.__generateTree"></a> |
|
750 <h4>MiscellaneousChecker.__generateTree</h4> |
|
751 <b>__generateTree</b>(<i></i>) |
|
752 <p> |
|
753 Private method to generate an AST for our source. |
|
754 </p><dl> |
|
755 <dt>Returns:</dt> |
|
756 <dd> |
|
757 generated AST |
|
758 </dd> |
|
759 </dl><dl> |
|
760 <dt>Return Type:</dt> |
|
761 <dd> |
|
762 ast.AST |
656 </dd> |
763 </dd> |
657 </dl><a NAME="MiscellaneousChecker.__getCoding" ID="MiscellaneousChecker.__getCoding"></a> |
764 </dl><a NAME="MiscellaneousChecker.__getCoding" ID="MiscellaneousChecker.__getCoding"></a> |
658 <h4>MiscellaneousChecker.__getCoding</h4> |
765 <h4>MiscellaneousChecker.__getCoding</h4> |
659 <b>__getCoding</b>(<i></i>) |
766 <b>__getCoding</b>(<i></i>) |
660 <p> |
767 <p> |