Mon, 12 Mar 2018 19:37:23 +0100
Code Style Checker: added some checks of the bugbear checker
<!DOCTYPE html> <html><head> <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker</title> <meta charset="UTF-8"> <style> body { background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } h1 { color: white; background: #85774A; } h2 { color: white; background: #85774A; } h3 { color: white; background: #9D936E; } h4 { color: white; background: #9D936E; } a { color: #BA6D36; } </style> </head> <body><a NAME="top" ID="top"></a> <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker</h1> <p> Module implementing a checker for miscellaneous checks. </p> <h3>Global Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#BugBearVisitor">BugBearVisitor</a></td> <td>Class implementing a node visitor to check for various topics.</td> </tr><tr> <td><a href="#LoggingVisitor">LoggingVisitor</a></td> <td>Class implementing a node visitor to check logging statements.</td> </tr><tr> <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> <td>Class implementing a checker for miscellaneous checks.</td> </tr><tr> <td><a href="#NameFinder">NameFinder</a></td> <td>Class to extract a name out of a tree of nodes.</td> </tr><tr> <td><a href="#TextVisitor">TextVisitor</a></td> <td>Class implementing a node visitor for bytes and str instances.</td> </tr> </table> <h3>Functions</h3> <table> <tr> <td><a href="#composeCallPath">composeCallPath</a></td> <td>Generator function to assemble the call path of a given node.</td> </tr> </table> <hr /><hr /> <a NAME="BugBearVisitor" ID="BugBearVisitor"></a> <h2>BugBearVisitor</h2> <p> Class implementing a node visitor to check for various topics. </p> <h3>Derived from</h3> ast.NodeVisitor <h3>Class Attributes</h3> <table> <tr><td>NodeWindowSize</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#BugBearVisitor.__init__">BugBearVisitor</a></td> <td>Constructor</td> </tr><tr> <td><a href="#BugBearVisitor.__checkForM502">__checkForM502</a></td> <td>Private method to check the use of *strip().</td> </tr><tr> <td><a href="#BugBearVisitor.__checkForM507">__checkForM507</a></td> <td>Private method to check for unused loop variables.</td> </tr><tr> <td><a href="#BugBearVisitor.visit">visit</a></td> <td>Public method to traverse a given AST node.</td> </tr><tr> <td><a href="#BugBearVisitor.visit_Assign">visit_Assign</a></td> <td>Public method to handle assignments.</td> </tr><tr> <td><a href="#BugBearVisitor.visit_Attribute">visit_Attribute</a></td> <td>Public method to handle attributes.</td> </tr><tr> <td><a href="#BugBearVisitor.visit_Call">visit_Call</a></td> <td>Public method to handle a function call.</td> </tr><tr> <td><a href="#BugBearVisitor.visit_For">visit_For</a></td> <td>Public method to handle 'for' statements.</td> </tr><tr> <td><a href="#BugBearVisitor.visit_UAdd">visit_UAdd</a></td> <td>Public method to handle unary additions.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="BugBearVisitor.__init__" ID="BugBearVisitor.__init__"></a> <h4>BugBearVisitor (Constructor)</h4> <b>BugBearVisitor</b>(<i></i>) <p> Constructor </p><a NAME="BugBearVisitor.__checkForM502" ID="BugBearVisitor.__checkForM502"></a> <h4>BugBearVisitor.__checkForM502</h4> <b>__checkForM502</b>(<i>node</i>) <p> Private method to check the use of *strip(). </p><dl> <dt><i>node</i> (ast.Call)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="BugBearVisitor.__checkForM507" ID="BugBearVisitor.__checkForM507"></a> <h4>BugBearVisitor.__checkForM507</h4> <b>__checkForM507</b>(<i>node</i>) <p> Private method to check for unused loop variables. </p><dl> <dt><i>node</i> (ast.For)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a> <h4>BugBearVisitor.visit</h4> <b>visit</b>(<i>node</i>) <p> Public method to traverse a given AST node. </p><dl> <dt><i>node</i> (ast.Node)</dt> <dd> AST node to be traversed </dd> </dl><a NAME="BugBearVisitor.visit_Assign" ID="BugBearVisitor.visit_Assign"></a> <h4>BugBearVisitor.visit_Assign</h4> <b>visit_Assign</b>(<i>node</i>) <p> Public method to handle assignments. </p><dl> <dt><i>node</i> (ast.Assign)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="BugBearVisitor.visit_Attribute" ID="BugBearVisitor.visit_Attribute"></a> <h4>BugBearVisitor.visit_Attribute</h4> <b>visit_Attribute</b>(<i>node</i>) <p> Public method to handle attributes. </p><dl> <dt><i>node</i> (ast.Attribute)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="BugBearVisitor.visit_Call" ID="BugBearVisitor.visit_Call"></a> <h4>BugBearVisitor.visit_Call</h4> <b>visit_Call</b>(<i>node</i>) <p> Public method to handle a function call. </p><dl> <dt><i>node</i> (ast.Call)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="BugBearVisitor.visit_For" ID="BugBearVisitor.visit_For"></a> <h4>BugBearVisitor.visit_For</h4> <b>visit_For</b>(<i>node</i>) <p> Public method to handle 'for' statements. </p><dl> <dt><i>node</i> (ast.For)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="BugBearVisitor.visit_UAdd" ID="BugBearVisitor.visit_UAdd"></a> <h4>BugBearVisitor.visit_UAdd</h4> <b>visit_UAdd</b>(<i>node</i>) <p> Public method to handle unary additions. </p><dl> <dt><i>node</i> (ast.UAdd)</dt> <dd> reference to the node to be processed </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="LoggingVisitor" ID="LoggingVisitor"></a> <h2>LoggingVisitor</h2> <p> Class implementing a node visitor to check logging statements. </p> <h3>Derived from</h3> ast.NodeVisitor <h3>Class Attributes</h3> <table> <tr><td>LoggingLevels</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#LoggingVisitor.__init__">LoggingVisitor</a></td> <td>Constructor</td> </tr><tr> <td><a href="#LoggingVisitor.__detectLoggingLevel">__detectLoggingLevel</a></td> <td>Private method to decide whether an AST Call is a logging call.</td> </tr><tr> <td><a href="#LoggingVisitor.__isFormatCall">__isFormatCall</a></td> <td>Private method to check if a function call uses format.</td> </tr><tr> <td><a href="#LoggingVisitor.__withinExtraKeyword">__withinExtraKeyword</a></td> <td>Private method to check, if we are inside the extra keyword.</td> </tr><tr> <td><a href="#LoggingVisitor.__withinLoggingArgument">__withinLoggingArgument</a></td> <td>Private method to check, if we are inside a logging argument.</td> </tr><tr> <td><a href="#LoggingVisitor.__withinLoggingStatement">__withinLoggingStatement</a></td> <td>Private method to check, if we are inside a logging statement.</td> </tr><tr> <td><a href="#LoggingVisitor.visit_BinOp">visit_BinOp</a></td> <td>Public method to handle binary operations while processing the first logging argument.</td> </tr><tr> <td><a href="#LoggingVisitor.visit_Call">visit_Call</a></td> <td>Public method to handle a function call.</td> </tr><tr> <td><a href="#LoggingVisitor.visit_JoinedStr">visit_JoinedStr</a></td> <td>Public method to handle f-string arguments.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="LoggingVisitor.__init__" ID="LoggingVisitor.__init__"></a> <h4>LoggingVisitor (Constructor)</h4> <b>LoggingVisitor</b>(<i></i>) <p> Constructor </p><a NAME="LoggingVisitor.__detectLoggingLevel" ID="LoggingVisitor.__detectLoggingLevel"></a> <h4>LoggingVisitor.__detectLoggingLevel</h4> <b>__detectLoggingLevel</b>(<i>node</i>) <p> Private method to decide whether an AST Call is a logging call. </p><dl> <dt><i>node</i> (ast.Call)</dt> <dd> reference to the node to be processed </dd> </dl><dl> <dt>Returns:</dt> <dd> logging level </dd> </dl><dl> <dt>Return Type:</dt> <dd> str or None </dd> </dl><a NAME="LoggingVisitor.__isFormatCall" ID="LoggingVisitor.__isFormatCall"></a> <h4>LoggingVisitor.__isFormatCall</h4> <b>__isFormatCall</b>(<i>node</i>) <p> Private method to check if a function call uses format. </p><dl> <dt><i>node</i> (ast.Call)</dt> <dd> reference to the node to be processed </dd> </dl><dl> <dt>Returns:</dt> <dd> flag indicating the function call uses format </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="LoggingVisitor.__withinExtraKeyword" ID="LoggingVisitor.__withinExtraKeyword"></a> <h4>LoggingVisitor.__withinExtraKeyword</h4> <b>__withinExtraKeyword</b>(<i>node</i>) <p> Private method to check, if we are inside the extra keyword. </p><dl> <dt><i>node</i> (ast.keyword)</dt> <dd> reference to the node to be checked </dd> </dl><dl> <dt>Returns:</dt> <dd> flag indicating we are inside the extra keyword </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="LoggingVisitor.__withinLoggingArgument" ID="LoggingVisitor.__withinLoggingArgument"></a> <h4>LoggingVisitor.__withinLoggingArgument</h4> <b>__withinLoggingArgument</b>(<i></i>) <p> Private method to check, if we are inside a logging argument. </p><dl> <dt>Returns:</dt> <dd> flag indicating we are inside a logging argument </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="LoggingVisitor.__withinLoggingStatement" ID="LoggingVisitor.__withinLoggingStatement"></a> <h4>LoggingVisitor.__withinLoggingStatement</h4> <b>__withinLoggingStatement</b>(<i></i>) <p> Private method to check, if we are inside a logging statement. </p><dl> <dt>Returns:</dt> <dd> flag indicating we are inside a logging statement </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="LoggingVisitor.visit_BinOp" ID="LoggingVisitor.visit_BinOp"></a> <h4>LoggingVisitor.visit_BinOp</h4> <b>visit_BinOp</b>(<i>node</i>) <p> Public method to handle binary operations while processing the first logging argument. </p><dl> <dt><i>node</i> (ast.BinOp)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="LoggingVisitor.visit_Call" ID="LoggingVisitor.visit_Call"></a> <h4>LoggingVisitor.visit_Call</h4> <b>visit_Call</b>(<i>node</i>) <p> Public method to handle a function call. </p><p> Every logging statement and string format is expected to be a function call. </p><dl> <dt><i>node</i> (ast.Call)</dt> <dd> reference to the node to be processed </dd> </dl><a NAME="LoggingVisitor.visit_JoinedStr" ID="LoggingVisitor.visit_JoinedStr"></a> <h4>LoggingVisitor.visit_JoinedStr</h4> <b>visit_JoinedStr</b>(<i>node</i>) <p> Public method to handle f-string arguments. </p><dl> <dt><i>node</i> (ast.JoinedStr)</dt> <dd> reference to the node to be processed </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="MiscellaneousChecker" ID="MiscellaneousChecker"></a> <h2>MiscellaneousChecker</h2> <p> Class implementing a checker for miscellaneous checks. </p> <h3>Derived from</h3> object <h3>Class Attributes</h3> <table> <tr><td>BuiltinsWhiteList</td></tr><tr><td>Codes</td></tr><tr><td>FormatFieldRegex</td></tr><tr><td>Formatter</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#MiscellaneousChecker.__init__">MiscellaneousChecker</a></td> <td>Constructor</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkBugBear">__checkBugBear</a></td> <td>Private method to bugbear checks.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkBuiltins">__checkBuiltins</a></td> <td>Private method to check, if built-ins are shadowed.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkCoding">__checkCoding</a></td> <td>Private method to check the presence of a coding line and valid encodings.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkComprehensions">__checkComprehensions</a></td> <td>Private method to check some comprehension related things.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkCopyright">__checkCopyright</a></td> <td>Private method to check the presence of a copyright statement.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkDictWithSortedKeys">__checkDictWithSortedKeys</a></td> <td>Private method to check, if dictionary keys appear in sorted order.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkFormatString">__checkFormatString</a></td> <td>Private method to check string format strings.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkFuture">__checkFuture</a></td> <td>Private method to check the __future__ imports.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkGettext">__checkGettext</a></td> <td>Private method to check the 'gettext' import statement.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkLogging">__checkLogging</a></td> <td>Private method to check logging statements.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkMutableDefault">__checkMutableDefault</a></td> <td>Private method to check for use of mutable types as default arguments.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkPep3101">__checkPep3101</a></td> <td>Private method to check for old style string formatting.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkPrintStatements">__checkPrintStatements</a></td> <td>Private method to check for print statements.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__checkTuple">__checkTuple</a></td> <td>Private method to check for one element tuples.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__dictShouldBeChecked">__dictShouldBeChecked</a></td> <td>Private function to test, if the node should be checked.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__error">__error</a></td> <td>Private method to record an issue.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__getCoding">__getCoding</a></td> <td>Private method to get the defined coding of the source.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__getFields">__getFields</a></td> <td>Private method to extract the format field information.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__ignoreCode">__ignoreCode</a></td> <td>Private method to check if the message code should be ignored.</td> </tr><tr> <td><a href="#MiscellaneousChecker.__reportInvalidSyntax">__reportInvalidSyntax</a></td> <td>Private method to report a syntax error.</td> </tr><tr> <td><a href="#MiscellaneousChecker.run">run</a></td> <td>Public method to check the given source against miscellaneous conditions.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="MiscellaneousChecker.__init__" ID="MiscellaneousChecker.__init__"></a> <h4>MiscellaneousChecker (Constructor)</h4> <b>MiscellaneousChecker</b>(<i>source, filename, select, ignore, expected, repeat, args</i>) <p> Constructor </p><dl> <dt><i>source</i> (list of str)</dt> <dd> source code to be checked </dd><dt><i>filename</i> (str)</dt> <dd> name of the source file </dd><dt><i>select</i> (list of str)</dt> <dd> list of selected codes </dd><dt><i>ignore</i> (list of str)</dt> <dd> list of codes to be ignored </dd><dt><i>expected</i> (list of str)</dt> <dd> list of expected codes </dd><dt><i>repeat</i> (bool)</dt> <dd> flag indicating to report each occurrence of a code </dd><dt><i>args</i> (dict)</dt> <dd> dictionary of arguments for the miscellaneous checks </dd> </dl><a NAME="MiscellaneousChecker.__checkBugBear" ID="MiscellaneousChecker.__checkBugBear"></a> <h4>MiscellaneousChecker.__checkBugBear</h4> <b>__checkBugBear</b>(<i></i>) <p> Private method to bugbear checks. </p><a NAME="MiscellaneousChecker.__checkBuiltins" ID="MiscellaneousChecker.__checkBuiltins"></a> <h4>MiscellaneousChecker.__checkBuiltins</h4> <b>__checkBuiltins</b>(<i></i>) <p> Private method to check, if built-ins are shadowed. </p><a NAME="MiscellaneousChecker.__checkCoding" ID="MiscellaneousChecker.__checkCoding"></a> <h4>MiscellaneousChecker.__checkCoding</h4> <b>__checkCoding</b>(<i></i>) <p> Private method to check the presence of a coding line and valid encodings. </p><a NAME="MiscellaneousChecker.__checkComprehensions" ID="MiscellaneousChecker.__checkComprehensions"></a> <h4>MiscellaneousChecker.__checkComprehensions</h4> <b>__checkComprehensions</b>(<i></i>) <p> Private method to check some comprehension related things. </p><a NAME="MiscellaneousChecker.__checkCopyright" ID="MiscellaneousChecker.__checkCopyright"></a> <h4>MiscellaneousChecker.__checkCopyright</h4> <b>__checkCopyright</b>(<i></i>) <p> Private method to check the presence of a copyright statement. </p><a NAME="MiscellaneousChecker.__checkDictWithSortedKeys" ID="MiscellaneousChecker.__checkDictWithSortedKeys"></a> <h4>MiscellaneousChecker.__checkDictWithSortedKeys</h4> <b>__checkDictWithSortedKeys</b>(<i></i>) <p> Private method to check, if dictionary keys appear in sorted order. </p><a NAME="MiscellaneousChecker.__checkFormatString" ID="MiscellaneousChecker.__checkFormatString"></a> <h4>MiscellaneousChecker.__checkFormatString</h4> <b>__checkFormatString</b>(<i></i>) <p> Private method to check string format strings. </p><a NAME="MiscellaneousChecker.__checkFuture" ID="MiscellaneousChecker.__checkFuture"></a> <h4>MiscellaneousChecker.__checkFuture</h4> <b>__checkFuture</b>(<i></i>) <p> Private method to check the __future__ imports. </p><a NAME="MiscellaneousChecker.__checkGettext" ID="MiscellaneousChecker.__checkGettext"></a> <h4>MiscellaneousChecker.__checkGettext</h4> <b>__checkGettext</b>(<i></i>) <p> Private method to check the 'gettext' import statement. </p><a NAME="MiscellaneousChecker.__checkLogging" ID="MiscellaneousChecker.__checkLogging"></a> <h4>MiscellaneousChecker.__checkLogging</h4> <b>__checkLogging</b>(<i></i>) <p> Private method to check logging statements. </p><a NAME="MiscellaneousChecker.__checkMutableDefault" ID="MiscellaneousChecker.__checkMutableDefault"></a> <h4>MiscellaneousChecker.__checkMutableDefault</h4> <b>__checkMutableDefault</b>(<i></i>) <p> Private method to check for use of mutable types as default arguments. </p><a NAME="MiscellaneousChecker.__checkPep3101" ID="MiscellaneousChecker.__checkPep3101"></a> <h4>MiscellaneousChecker.__checkPep3101</h4> <b>__checkPep3101</b>(<i></i>) <p> Private method to check for old style string formatting. </p><a NAME="MiscellaneousChecker.__checkPrintStatements" ID="MiscellaneousChecker.__checkPrintStatements"></a> <h4>MiscellaneousChecker.__checkPrintStatements</h4> <b>__checkPrintStatements</b>(<i></i>) <p> Private method to check for print statements. </p><a NAME="MiscellaneousChecker.__checkTuple" ID="MiscellaneousChecker.__checkTuple"></a> <h4>MiscellaneousChecker.__checkTuple</h4> <b>__checkTuple</b>(<i></i>) <p> Private method to check for one element tuples. </p><a NAME="MiscellaneousChecker.__dictShouldBeChecked" ID="MiscellaneousChecker.__dictShouldBeChecked"></a> <h4>MiscellaneousChecker.__dictShouldBeChecked</h4> <b>__dictShouldBeChecked</b>(<i>node</i>) <p> Private function to test, if the node should be checked. </p><dl> <dt><i>node</i></dt> <dd> reference to the AST node </dd> </dl><dl> <dt>Returns:</dt> <dd> flag indicating to check the node </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="MiscellaneousChecker.__error" ID="MiscellaneousChecker.__error"></a> <h4>MiscellaneousChecker.__error</h4> <b>__error</b>(<i>lineNumber, offset, code, *args</i>) <p> Private method to record an issue. </p><dl> <dt><i>lineNumber</i> (int)</dt> <dd> line number of the issue </dd><dt><i>offset</i> (int)</dt> <dd> position within line of the issue </dd><dt><i>code</i> (str)</dt> <dd> message code </dd><dt><i>args</i> (list)</dt> <dd> arguments for the message </dd> </dl><a NAME="MiscellaneousChecker.__getCoding" ID="MiscellaneousChecker.__getCoding"></a> <h4>MiscellaneousChecker.__getCoding</h4> <b>__getCoding</b>(<i></i>) <p> Private method to get the defined coding of the source. </p><dl> <dt>Returns:</dt> <dd> tuple containing the line number and the coding </dd> </dl><dl> <dt>Return Type:</dt> <dd> tuple of int and str </dd> </dl><a NAME="MiscellaneousChecker.__getFields" ID="MiscellaneousChecker.__getFields"></a> <h4>MiscellaneousChecker.__getFields</h4> <b>__getFields</b>(<i>string</i>) <p> Private method to extract the format field information. </p><dl> <dt><i>string</i> (str)</dt> <dd> format string to be parsed </dd> </dl><dl> <dt>Returns:</dt> <dd> format field information as a tuple with fields, implicit field definitions present and explicit field definitions present </dd> </dl><dl> <dt>Return Type:</dt> <dd> tuple of set of str, bool, bool </dd> </dl><a NAME="MiscellaneousChecker.__ignoreCode" ID="MiscellaneousChecker.__ignoreCode"></a> <h4>MiscellaneousChecker.__ignoreCode</h4> <b>__ignoreCode</b>(<i>code</i>) <p> Private method to check if the message code should be ignored. </p><dl> <dt><i>code</i> (str)</dt> <dd> message code to check for </dd> </dl><dl> <dt>Returns:</dt> <dd> flag indicating to ignore the given code </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="MiscellaneousChecker.__reportInvalidSyntax" ID="MiscellaneousChecker.__reportInvalidSyntax"></a> <h4>MiscellaneousChecker.__reportInvalidSyntax</h4> <b>__reportInvalidSyntax</b>(<i></i>) <p> Private method to report a syntax error. </p><a NAME="MiscellaneousChecker.run" ID="MiscellaneousChecker.run"></a> <h4>MiscellaneousChecker.run</h4> <b>run</b>(<i></i>) <p> Public method to check the given source against miscellaneous conditions. </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="NameFinder" ID="NameFinder"></a> <h2>NameFinder</h2> <p> Class to extract a name out of a tree of nodes. </p> <h3>Derived from</h3> ast.NodeVisitor <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#NameFinder.__init__">NameFinder</a></td> <td>Constructor</td> </tr><tr> <td><a href="#NameFinder.getNames">getNames</a></td> <td>Public method to return the extracted names and Name nodes.</td> </tr><tr> <td><a href="#NameFinder.visit">visit</a></td> <td>Public method to traverse a given AST node.</td> </tr><tr> <td><a href="#NameFinder.visit_Name">visit_Name</a></td> <td>Public method to handle 'Name' nodes.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="NameFinder.__init__" ID="NameFinder.__init__"></a> <h4>NameFinder (Constructor)</h4> <b>NameFinder</b>(<i></i>) <p> Constructor </p><a NAME="NameFinder.getNames" ID="NameFinder.getNames"></a> <h4>NameFinder.getNames</h4> <b>getNames</b>(<i></i>) <p> Public method to return the extracted names and Name nodes. </p><dl> <dt>Returns:</dt> <dd> dictionary containing the names as keys and the list of nodes </dd> </dl><dl> <dt>Return Type:</dt> <dd> dict </dd> </dl><a NAME="NameFinder.visit" ID="NameFinder.visit"></a> <h4>NameFinder.visit</h4> <b>visit</b>(<i>node</i>) <p> Public method to traverse a given AST node. </p><dl> <dt><i>node</i> (ast.Node)</dt> <dd> AST node to be traversed </dd> </dl><a NAME="NameFinder.visit_Name" ID="NameFinder.visit_Name"></a> <h4>NameFinder.visit_Name</h4> <b>visit_Name</b>(<i>node</i>) <p> Public method to handle 'Name' nodes. </p><dl> <dt><i>node</i> (ast.Name)</dt> <dd> reference to the node to be processed </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="TextVisitor" ID="TextVisitor"></a> <h2>TextVisitor</h2> <p> Class implementing a node visitor for bytes and str instances. </p><p> It tries to detect docstrings as string of the first expression of each module, class or function. </p> <h3>Derived from</h3> ast.NodeVisitor <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#TextVisitor.__init__">TextVisitor</a></td> <td>Constructor</td> </tr><tr> <td><a href="#TextVisitor.__addNode">__addNode</a></td> <td>Private method to add a node to our list of nodes.</td> </tr><tr> <td><a href="#TextVisitor.__isBaseString">__isBaseString</a></td> <td>Private method to determine, if a node is a base string node.</td> </tr><tr> <td><a href="#TextVisitor.__visitBody">__visitBody</a></td> <td>Private method to traverse the body of the node manually.</td> </tr><tr> <td><a href="#TextVisitor.__visitDefinition">__visitDefinition</a></td> <td>Private method handling class and function definitions.</td> </tr><tr> <td><a href="#TextVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td> <td>Public method to handle an asynchronous function definition.</td> </tr><tr> <td><a href="#TextVisitor.visit_Bytes">visit_Bytes</a></td> <td>Public method to record a bytes node.</td> </tr><tr> <td><a href="#TextVisitor.visit_Call">visit_Call</a></td> <td>Public method to handle a function call.</td> </tr><tr> <td><a href="#TextVisitor.visit_ClassDef">visit_ClassDef</a></td> <td>Public method to handle a class definition.</td> </tr><tr> <td><a href="#TextVisitor.visit_FunctionDef">visit_FunctionDef</a></td> <td>Public method to handle a function definition.</td> </tr><tr> <td><a href="#TextVisitor.visit_Module">visit_Module</a></td> <td>Public method to handle a module.</td> </tr><tr> <td><a href="#TextVisitor.visit_Str">visit_Str</a></td> <td>Public method to record a string node.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="TextVisitor.__init__" ID="TextVisitor.__init__"></a> <h4>TextVisitor (Constructor)</h4> <b>TextVisitor</b>(<i></i>) <p> Constructor </p><a NAME="TextVisitor.__addNode" ID="TextVisitor.__addNode"></a> <h4>TextVisitor.__addNode</h4> <b>__addNode</b>(<i>node</i>) <p> Private method to add a node to our list of nodes. </p><dl> <dt><i>node</i> (ast.AST)</dt> <dd> reference to the node to add </dd> </dl><a NAME="TextVisitor.__isBaseString" ID="TextVisitor.__isBaseString"></a> <h4>TextVisitor.__isBaseString</h4> <b>__isBaseString</b>(<i>node</i>) <p> Private method to determine, if a node is a base string node. </p><dl> <dt><i>node</i> (ast.AST)</dt> <dd> reference to the node to check </dd> </dl><dl> <dt>Returns:</dt> <dd> flag indicating a base string </dd> </dl><dl> <dt>Return Type:</dt> <dd> bool </dd> </dl><a NAME="TextVisitor.__visitBody" ID="TextVisitor.__visitBody"></a> <h4>TextVisitor.__visitBody</h4> <b>__visitBody</b>(<i>node</i>) <p> Private method to traverse the body of the node manually. </p><p> If the first node is an expression which contains a string or bytes it marks that as a docstring. </p><dl> <dt><i>node</i> (ast.AST)</dt> <dd> reference to the node to traverse </dd> </dl><a NAME="TextVisitor.__visitDefinition" ID="TextVisitor.__visitDefinition"></a> <h4>TextVisitor.__visitDefinition</h4> <b>__visitDefinition</b>(<i>node</i>) <p> Private method handling class and function definitions. </p><dl> <dt><i>node</i> (ast.FunctionDef, ast.AsyncFunctionDef or ast.ClassDef)</dt> <dd> reference to the node to handle </dd> </dl><a NAME="TextVisitor.visit_AsyncFunctionDef" ID="TextVisitor.visit_AsyncFunctionDef"></a> <h4>TextVisitor.visit_AsyncFunctionDef</h4> <b>visit_AsyncFunctionDef</b>(<i>node</i>) <p> Public method to handle an asynchronous function definition. </p><dl> <dt><i>node</i> (ast.AsyncFunctionDef)</dt> <dd> reference to the node to handle </dd> </dl><a NAME="TextVisitor.visit_Bytes" ID="TextVisitor.visit_Bytes"></a> <h4>TextVisitor.visit_Bytes</h4> <b>visit_Bytes</b>(<i>node</i>) <p> Public method to record a bytes node. </p><dl> <dt><i>node</i> (ast.Bytes)</dt> <dd> reference to the bytes node </dd> </dl><a NAME="TextVisitor.visit_Call" ID="TextVisitor.visit_Call"></a> <h4>TextVisitor.visit_Call</h4> <b>visit_Call</b>(<i>node</i>) <p> Public method to handle a function call. </p><dl> <dt><i>node</i> (ast.Call)</dt> <dd> reference to the node to handle </dd> </dl><a NAME="TextVisitor.visit_ClassDef" ID="TextVisitor.visit_ClassDef"></a> <h4>TextVisitor.visit_ClassDef</h4> <b>visit_ClassDef</b>(<i>node</i>) <p> Public method to handle a class definition. </p><dl> <dt><i>node</i> (ast.ClassDef)</dt> <dd> reference to the node to handle </dd> </dl><a NAME="TextVisitor.visit_FunctionDef" ID="TextVisitor.visit_FunctionDef"></a> <h4>TextVisitor.visit_FunctionDef</h4> <b>visit_FunctionDef</b>(<i>node</i>) <p> Public method to handle a function definition. </p><dl> <dt><i>node</i> (ast.FunctionDef)</dt> <dd> reference to the node to handle </dd> </dl><a NAME="TextVisitor.visit_Module" ID="TextVisitor.visit_Module"></a> <h4>TextVisitor.visit_Module</h4> <b>visit_Module</b>(<i>node</i>) <p> Public method to handle a module. </p><dl> <dt><i>node</i> (ast.Module)</dt> <dd> reference to the node to handle </dd> </dl><a NAME="TextVisitor.visit_Str" ID="TextVisitor.visit_Str"></a> <h4>TextVisitor.visit_Str</h4> <b>visit_Str</b>(<i>node</i>) <p> Public method to record a string node. </p><dl> <dt><i>node</i> (ast.Str)</dt> <dd> reference to the string node </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> <a NAME="composeCallPath" ID="composeCallPath"></a> <h2>composeCallPath</h2> <b>composeCallPath</b>(<i>node</i>) <p> Generator function to assemble the call path of a given node. </p><dl> <dt><i>node</i> (ast.Node)</dt> <dd> node to assemble call path for </dd> </dl><dl> <dt>Returns:</dt> <dd> call path components </dd> </dl><dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>