--- a/src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.MiscellaneousChecker.html Thu Jan 18 09:25:11 2024 +0100 +++ b/src/eric7/Documentation/Source/eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.MiscellaneousChecker.html Thu Jan 18 13:10:08 2024 +0100 @@ -27,10 +27,18 @@ <td>Class implementing a node visitor to check datetime function calls.</td> </tr> <tr> +<td><a href="#ExceptBaseExceptionVisitor">ExceptBaseExceptionVisitor</a></td> +<td>Class to determine, if a 'BaseException' is re-raised.</td> +</tr> +<tr> <td><a href="#M520NameFinder">M520NameFinder</a></td> <td>Class to extract a name out of a tree of nodes ignoring names defined within the local scope of a comprehension.</td> </tr> <tr> +<td><a href="#M538Checker">M538Checker</a></td> +<td>Class traversing a 'for' loop body to check for modifications to a loop's mutable iterable.</td> +</tr> +<tr> <td><a href="#MiscellaneousChecker">MiscellaneousChecker</a></td> <td>Class implementing a checker for miscellaneous checks.</td> </tr> @@ -39,6 +47,10 @@ <td>Class to extract a name out of a tree of nodes.</td> </tr> <tr> +<td><a href="#NamedExprFinder">NamedExprFinder</a></td> +<td>Class to extract names defined through an ast.NamedExpr.</td> +</tr> +<tr> <td><a href="#ReturnVisitor">ReturnVisitor</a></td> <td>Class implementing a node visitor to check return statements.</td> </tr> @@ -177,6 +189,10 @@ <td>Private method to check that a static key isn't used in a dict comprehension.</td> </tr> <tr> +<td><a href="#BugBearVisitor.__checkForM538">__checkForM538</a></td> +<td>Private method to check for changes to a loop's mutable iterable.</td> +</tr> +<tr> <td><a href="#BugBearVisitor.__checkRedundantExcepthandlers">__checkRedundantExcepthandlers</a></td> <td>Private method to check for redundant exception types in an exception handler.</td> </tr> @@ -197,7 +213,7 @@ <td>Private method to get the names of a for loop.</td> </tr> <tr> -<td><a href="#BugBearVisitor.__getDictCompLoopVarNames">__getDictCompLoopVarNames</a></td> +<td><a href="#BugBearVisitor.__getDictCompLoopAndNamedExprVarNames">__getDictCompLoopAndNamedExprVarNames</a></td> <td>Private method to get the names of comprehension loop variables.</td> </tr> <tr> @@ -205,6 +221,10 @@ <td>Private method to get the names from an ast.Tuple node.</td> </tr> <tr> +<td><a href="#BugBearVisitor.__inClassInit">__inClassInit</a></td> +<td>Private method to check, if we are inside an '__init__' method.</td> +</tr> +<tr> <td><a href="#BugBearVisitor.__isIdentifier">__isIdentifier</a></td> <td>Private method to check if arg is a valid identifier.</td> </tr> @@ -213,10 +233,6 @@ <td>Private method to get names of an assignment.</td> </tr> <tr> -<td><a href="#BugBearVisitor.__toNameStr">__toNameStr</a></td> -<td>Private method to turn Name and Attribute nodes to strings, handling any depth of attribute accesses.</td> -</tr> -<tr> <td><a href="#BugBearVisitor.__typesafeIssubclass">__typesafeIssubclass</a></td> <td>Private method implementing a type safe issubclass() function.</td> </tr> @@ -257,6 +273,10 @@ <td>Public method to get a reference to the most recent node stack.</td> </tr> <tr> +<td><a href="#BugBearVisitor.toNameStr">toNameStr</a></td> +<td>Public method to turn Name and Attribute nodes to strings, handling any depth of attribute accesses.</td> +</tr> +<tr> <td><a href="#BugBearVisitor.visit">visit</a></td> <td>Public method to traverse a given AST node.</td> </tr> @@ -333,6 +353,10 @@ <td>Public method to handle 'raise' statements.</td> </tr> <tr> +<td><a href="#BugBearVisitor.visit_Return">visit_Return</a></td> +<td>Public method to handle 'Return' nodes.</td> +</tr> +<tr> <td><a href="#BugBearVisitor.visit_Set">visit_Set</a></td> <td>Public method to check a set.</td> </tr> @@ -356,6 +380,14 @@ <td><a href="#BugBearVisitor.visit_With">visit_With</a></td> <td>Public method to handle 'with' statements.</td> </tr> +<tr> +<td><a href="#BugBearVisitor.visit_Yield">visit_Yield</a></td> +<td>Public method to handle 'Yield' nodes.</td> +</tr> +<tr> +<td><a href="#BugBearVisitor.visit_YieldFrom">visit_YieldFrom</a></td> +<td>Public method to handle 'YieldFrom' nodes.</td> +</tr> </table> <h3>Static Methods</h3> @@ -663,7 +695,7 @@ </dl> <a NAME="BugBearVisitor.__checkForM535" ID="BugBearVisitor.__checkForM535"></a> <h4>BugBearVisitor.__checkForM535</h4> -<b>__checkForM535</b>(<i>node: ast.DictComp</i>) +<b>__checkForM535</b>(<i>node</i>) <p> Private method to check that a static key isn't used in a dict comprehension. </p> @@ -679,6 +711,20 @@ reference to the node to be processed </dd> </dl> +<a NAME="BugBearVisitor.__checkForM538" ID="BugBearVisitor.__checkForM538"></a> +<h4>BugBearVisitor.__checkForM538</h4> +<b>__checkForM538</b>(<i>node</i>) +<p> + Private method to check for changes to a loop's mutable iterable. +</p> + +<dl> + +<dt><i>node</i> (ast.For)</dt> +<dd> +loop node to be checked +</dd> +</dl> <a NAME="BugBearVisitor.__checkRedundantExcepthandlers" ID="BugBearVisitor.__checkRedundantExcepthandlers"></a> <h4>BugBearVisitor.__checkRedundantExcepthandlers</h4> <b>__checkRedundantExcepthandlers</b>(<i>names, node</i>) @@ -813,9 +859,9 @@ TYPE </dd> </dl> -<a NAME="BugBearVisitor.__getDictCompLoopVarNames" ID="BugBearVisitor.__getDictCompLoopVarNames"></a> -<h4>BugBearVisitor.__getDictCompLoopVarNames</h4> -<b>__getDictCompLoopVarNames</b>(<i>node</i>) +<a NAME="BugBearVisitor.__getDictCompLoopAndNamedExprVarNames" ID="BugBearVisitor.__getDictCompLoopAndNamedExprVarNames"></a> +<h4>BugBearVisitor.__getDictCompLoopAndNamedExprVarNames</h4> +<b>__getDictCompLoopAndNamedExprVarNames</b>(<i>node</i>) <p> Private method to get the names of comprehension loop variables. </p> @@ -865,6 +911,25 @@ str </dd> </dl> +<a NAME="BugBearVisitor.__inClassInit" ID="BugBearVisitor.__inClassInit"></a> +<h4>BugBearVisitor.__inClassInit</h4> +<b>__inClassInit</b>(<i></i>) +<p> + Private method to check, if we are inside an '__init__' method. +</p> + +<dl> +<dt>Return:</dt> +<dd> +flag indicating being within the '__init__' method +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +bool +</dd> +</dl> <a NAME="BugBearVisitor.__isIdentifier" ID="BugBearVisitor.__isIdentifier"></a> <h4>BugBearVisitor.__isIdentifier</h4> <b>__isIdentifier</b>(<i>arg</i>) @@ -920,36 +985,6 @@ str </dd> </dl> -<a NAME="BugBearVisitor.__toNameStr" ID="BugBearVisitor.__toNameStr"></a> -<h4>BugBearVisitor.__toNameStr</h4> -<b>__toNameStr</b>(<i>node</i>) -<p> - Private method to turn Name and Attribute nodes to strings, handling any - depth of attribute accesses. -</p> -<p> - -</p> - -<dl> - -<dt><i>node</i> (ast.Name or ast.Attribute)</dt> -<dd> -reference to the node -</dd> -</dl> -<dl> -<dt>Return:</dt> -<dd> -string representation -</dd> -</dl> -<dl> -<dt>Return Type:</dt> -<dd> -str -</dd> -</dl> <a NAME="BugBearVisitor.__typesafeIssubclass" ID="BugBearVisitor.__typesafeIssubclass"></a> <h4>BugBearVisitor.__typesafeIssubclass</h4> <b>__typesafeIssubclass</b>(<i>obj, classOrTuple</i>) @@ -1053,6 +1088,36 @@ list </dd> </dl> +<a NAME="BugBearVisitor.toNameStr" ID="BugBearVisitor.toNameStr"></a> +<h4>BugBearVisitor.toNameStr</h4> +<b>toNameStr</b>(<i>node</i>) +<p> + Public method to turn Name and Attribute nodes to strings, handling any + depth of attribute accesses. +</p> +<p> + +</p> + +<dl> + +<dt><i>node</i> (ast.Name or ast.Attribute)</dt> +<dd> +reference to the node +</dd> +</dl> +<dl> +<dt>Return:</dt> +<dd> +string representation +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +str +</dd> +</dl> <a NAME="BugBearVisitor.visit" ID="BugBearVisitor.visit"></a> <h4>BugBearVisitor.visit</h4> <b>visit</b>(<i>node</i>) @@ -1319,6 +1384,20 @@ reference to the node to be processed </dd> </dl> +<a NAME="BugBearVisitor.visit_Return" ID="BugBearVisitor.visit_Return"></a> +<h4>BugBearVisitor.visit_Return</h4> +<b>visit_Return</b>(<i>node</i>) +<p> + Public method to handle 'Return' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.Return)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> <a NAME="BugBearVisitor.visit_Set" ID="BugBearVisitor.visit_Set"></a> <h4>BugBearVisitor.visit_Set</h4> <b>visit_Set</b>(<i>node</i>) @@ -1403,6 +1482,34 @@ reference to the node to be processed </dd> </dl> +<a NAME="BugBearVisitor.visit_Yield" ID="BugBearVisitor.visit_Yield"></a> +<h4>BugBearVisitor.visit_Yield</h4> +<b>visit_Yield</b>(<i>node</i>) +<p> + Public method to handle 'Yield' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.Yield)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> +<a NAME="BugBearVisitor.visit_YieldFrom" ID="BugBearVisitor.visit_YieldFrom"></a> +<h4>BugBearVisitor.visit_YieldFrom</h4> +<b>visit_YieldFrom</b>(<i>node</i>) +<p> + Public method to handle 'YieldFrom' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.YieldFrom)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> @@ -1507,6 +1614,119 @@ <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> +<a NAME="ExceptBaseExceptionVisitor" ID="ExceptBaseExceptionVisitor"></a> +<h2>ExceptBaseExceptionVisitor</h2> +<p> + Class to determine, if a 'BaseException' is re-raised. +</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="#ExceptBaseExceptionVisitor.__init__">ExceptBaseExceptionVisitor</a></td> +<td>Constructor</td> +</tr> +<tr> +<td><a href="#ExceptBaseExceptionVisitor.reRaised">reRaised</a></td> +<td>Public method to check, if the exception is re-raised.</td> +</tr> +<tr> +<td><a href="#ExceptBaseExceptionVisitor.visit_ExceptHandler">visit_ExceptHandler</a></td> +<td>Public method to handle 'ExceptHandler' nodes.</td> +</tr> +<tr> +<td><a href="#ExceptBaseExceptionVisitor.visit_Raise">visit_Raise</a></td> +<td>Public method to handle 'Raise' nodes.</td> +</tr> +</table> + +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> + + +<a NAME="ExceptBaseExceptionVisitor.__init__" ID="ExceptBaseExceptionVisitor.__init__"></a> +<h4>ExceptBaseExceptionVisitor (Constructor)</h4> +<b>ExceptBaseExceptionVisitor</b>(<i>exceptNode</i>) +<p> + Constructor +</p> + +<dl> + +<dt><i>exceptNode</i> (ast.ExceptHandler)</dt> +<dd> +exception node to be inspected +</dd> +</dl> +<a NAME="ExceptBaseExceptionVisitor.reRaised" ID="ExceptBaseExceptionVisitor.reRaised"></a> +<h4>ExceptBaseExceptionVisitor.reRaised</h4> +<b>reRaised</b>(<i></i>) +<p> + Public method to check, if the exception is re-raised. +</p> + +<dl> +<dt>Return:</dt> +<dd> +flag indicating a re-raised exception +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +bool +</dd> +</dl> +<a NAME="ExceptBaseExceptionVisitor.visit_ExceptHandler" ID="ExceptBaseExceptionVisitor.visit_ExceptHandler"></a> +<h4>ExceptBaseExceptionVisitor.visit_ExceptHandler</h4> +<b>visit_ExceptHandler</b>(<i>node: ast.ExceptHandler</i>) +<p> + Public method to handle 'ExceptHandler' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.ExceptHandler)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> +<a NAME="ExceptBaseExceptionVisitor.visit_Raise" ID="ExceptBaseExceptionVisitor.visit_Raise"></a> +<h4>ExceptBaseExceptionVisitor.visit_Raise</h4> +<b>visit_Raise</b>(<i>node</i>) +<p> + Public method to handle 'Raise' nodes. +</p> +<p> + If we find a corresponding `raise` or `raise e` where e was from + `except BaseException as e:` then we mark re_raised as True and can + stop scanning. +</p> + +<dl> + +<dt><i>node</i> (ast.Raise)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +<hr /> <a NAME="M520NameFinder" ID="M520NameFinder"></a> <h2>M520NameFinder</h2> <p> @@ -1629,6 +1849,129 @@ <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> +<a NAME="M538Checker" ID="M538Checker"></a> +<h2>M538Checker</h2> +<p> + Class traversing a 'for' loop body to check for modifications to a loop's + mutable iterable. +</p> + +<h3>Derived from</h3> +ast.NodeVisitor +<h3>Class Attributes</h3> +<table> +<tr><td>MUTATING_FUNCTIONS</td></tr> +</table> + +<h3>Class Methods</h3> +<table> +<tr><td>None</td></tr> +</table> + +<h3>Methods</h3> +<table> +<tr> +<td><a href="#M538Checker.__init__">M538Checker</a></td> +<td>Constructor</td> +</tr> +<tr> +<td><a href="#M538Checker.visit">visit</a></td> +<td>Public method to inspect an ast node.</td> +</tr> +<tr> +<td><a href="#M538Checker.visit_Call">visit_Call</a></td> +<td>Public method handling 'Call' nodes.</td> +</tr> +<tr> +<td><a href="#M538Checker.visit_Delete">visit_Delete</a></td> +<td>Public method handling 'Delete' nodes.</td> +</tr> +</table> + +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> + + +<a NAME="M538Checker.__init__" ID="M538Checker.__init__"></a> +<h4>M538Checker (Constructor)</h4> +<b>M538Checker</b>(<i>name, bugbear</i>) +<p> + Constructor +</p> + +<dl> + +<dt><i>name</i> (str)</dt> +<dd> +name of the iterator +</dd> +<dt><i>bugbear</i> (BugBearVisitor)</dt> +<dd> +reference to the bugbear visitor +</dd> +</dl> +<a NAME="M538Checker.visit" ID="M538Checker.visit"></a> +<h4>M538Checker.visit</h4> +<b>visit</b>(<i>node</i>) +<p> + Public method to inspect an ast node. +</p> +<p> + Like super-visit but supports iteration over lists. +</p> + +<dl> + +<dt><i>node</i> (TYPE)</dt> +<dd> +AST node to be traversed +</dd> +</dl> +<dl> +<dt>Return:</dt> +<dd> +reference to the last processed node +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +ast.Node +</dd> +</dl> +<a NAME="M538Checker.visit_Call" ID="M538Checker.visit_Call"></a> +<h4>M538Checker.visit_Call</h4> +<b>visit_Call</b>(<i>node</i>) +<p> + Public method handling 'Call' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.Call)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> +<a NAME="M538Checker.visit_Delete" ID="M538Checker.visit_Delete"></a> +<h4>M538Checker.visit_Delete</h4> +<b>visit_Delete</b>(<i>node</i>) +<p> + Public method handling 'Delete' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.Delete)</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> @@ -2249,6 +2592,122 @@ <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> +<a NAME="NamedExprFinder" ID="NamedExprFinder"></a> +<h2>NamedExprFinder</h2> +<p> + Class to extract names defined through an ast.NamedExpr. +</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="#NamedExprFinder.__init__">NamedExprFinder</a></td> +<td>Constructor</td> +</tr> +<tr> +<td><a href="#NamedExprFinder.getNames">getNames</a></td> +<td>Public method to return the extracted names and Name nodes.</td> +</tr> +<tr> +<td><a href="#NamedExprFinder.visit">visit</a></td> +<td>Public method to traverse a given AST node.</td> +</tr> +<tr> +<td><a href="#NamedExprFinder.visit_NamedExpr">visit_NamedExpr</a></td> +<td>Public method handling 'NamedExpr' nodes.</td> +</tr> +</table> + +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> + + +<a NAME="NamedExprFinder.__init__" ID="NamedExprFinder.__init__"></a> +<h4>NamedExprFinder (Constructor)</h4> +<b>NamedExprFinder</b>(<i></i>) +<p> + Constructor +</p> + +<a NAME="NamedExprFinder.getNames" ID="NamedExprFinder.getNames"></a> +<h4>NamedExprFinder.getNames</h4> +<b>getNames</b>(<i></i>) +<p> + Public method to return the extracted names and Name nodes. +</p> + +<dl> +<dt>Return:</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="NamedExprFinder.visit" ID="NamedExprFinder.visit"></a> +<h4>NamedExprFinder.visit</h4> +<b>visit</b>(<i>node</i>) +<p> + Public method to traverse a given AST node. +</p> +<p> + Like super-visit but supports iteration over lists. +</p> + +<dl> + +<dt><i>node</i> (TYPE)</dt> +<dd> +AST node to be traversed +</dd> +</dl> +<dl> +<dt>Return:</dt> +<dd> +reference to the last processed node +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +ast.Node +</dd> +</dl> +<a NAME="NamedExprFinder.visit_NamedExpr" ID="NamedExprFinder.visit_NamedExpr"></a> +<h4>NamedExprFinder.visit_NamedExpr</h4> +<b>visit_NamedExpr</b>(<i>node: ast.NamedExpr</i>) +<p> + Public method handling 'NamedExpr' nodes. +</p> + +<dl> + +<dt><i>node</i> (ast.NamedExpr)</dt> +<dd> +reference to the node to be processed +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +<hr /> <a NAME="ReturnVisitor" ID="ReturnVisitor"></a> <h2>ReturnVisitor</h2> <p>