eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker.html

changeset 8248
b00c1c6cc312
parent 8215
fc5d68a6889e
diff -r e718d3a47f78 -r b00c1c6cc312 eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker.html
--- a/eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker.html	Sat Apr 17 12:36:40 2021 +0200
+++ b/eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker.html	Sat Apr 17 12:37:41 2021 +0200
@@ -38,23 +38,11 @@
 <td><a href="#AnnotationsChecker">AnnotationsChecker</a></td>
 <td>Class implementing a checker for function type annotations.</td>
 </tr>
-<tr>
-<td><a href="#FunctionVisitor">FunctionVisitor</a></td>
-<td>Class implementing a node visitor to check function annotations.</td>
-</tr>
 </table>
 <h3>Functions</h3>
 
 <table>
-
-<tr>
-<td><a href="#getAnnotationComplexity">getAnnotationComplexity</a></td>
-<td>Function to determine the annotation complexity.</td>
-</tr>
-<tr>
-<td><a href="#hasTypeAnnotations">hasTypeAnnotations</a></td>
-<td>Function to check for type annotations.</td>
-</tr>
+<tr><td>None</td></tr>
 </table>
 <hr />
 <hr />
@@ -85,6 +73,10 @@
 <td>Constructor</td>
 </tr>
 <tr>
+<td><a href="#AnnotationsChecker.__argumentErrorClassifier">__argumentErrorClassifier</a></td>
+<td>Private method to classify an argument type annotation issue.</td>
+</tr>
+<tr>
 <td><a href="#AnnotationsChecker.__checkAnnotationComplexity">__checkAnnotationComplexity</a></td>
 <td>Private method to check the type annotation complexity.</td>
 </tr>
@@ -97,14 +89,34 @@
 <td>Private method to check for function annotation issues.</td>
 </tr>
 <tr>
+<td><a href="#AnnotationsChecker.__classifyError">__classifyError</a></td>
+<td>Private method to classify the missing type annotation based on the Function & Argument metadata.</td>
+</tr>
+<tr>
 <td><a href="#AnnotationsChecker.__error">__error</a></td>
 <td>Private method to record an issue.</td>
 </tr>
 <tr>
+<td><a href="#AnnotationsChecker.__getAnnotationComplexity">__getAnnotationComplexity</a></td>
+<td>Private method to determine the annotation complexity.</td>
+</tr>
+<tr>
+<td><a href="#AnnotationsChecker.__getAnnotationLength">__getAnnotationLength</a></td>
+<td>Private method to determine the annotation length.</td>
+</tr>
+<tr>
+<td><a href="#AnnotationsChecker.__hasTypeAnnotations">__hasTypeAnnotations</a></td>
+<td>Private method to check for type annotations.</td>
+</tr>
+<tr>
 <td><a href="#AnnotationsChecker.__ignoreCode">__ignoreCode</a></td>
 <td>Private method to check if the message code should be ignored.</td>
 </tr>
 <tr>
+<td><a href="#AnnotationsChecker.__returnErrorClassifier">__returnErrorClassifier</a></td>
+<td>Private method to classify a return type annotation issue.</td>
+</tr>
+<tr>
 <td><a href="#AnnotationsChecker.run">run</a></td>
 <td>Public method to check the given source against annotation issues.</td>
 </tr>
@@ -157,6 +169,44 @@
 dictionary of arguments for the annotation checks
 </dd>
 </dl>
+<a NAME="AnnotationsChecker.__argumentErrorClassifier" ID="AnnotationsChecker.__argumentErrorClassifier"></a>
+<h4>AnnotationsChecker.__argumentErrorClassifier</h4>
+<b>__argumentErrorClassifier</b>(<i>isClassMethod, isFirstArg, classDecoratorType, annotationType</i>)
+
+<p>
+        Private method to classify an argument type annotation issue.
+</p>
+<dl>
+
+<dt><i>isClassMethod</i> (bool)</dt>
+<dd>
+flag indicating a classmethod type function
+</dd>
+<dt><i>isFirstArg</i> (bool)</dt>
+<dd>
+flag indicating the first argument
+</dd>
+<dt><i>classDecoratorType</i> (enums.ClassDecoratorType)</dt>
+<dd>
+type of class decorator
+</dd>
+<dt><i>annotationType</i> (AnnotationType)</dt>
+<dd>
+type of annotation
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+error code
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+str
+</dd>
+</dl>
 <a NAME="AnnotationsChecker.__checkAnnotationComplexity" ID="AnnotationsChecker.__checkAnnotationComplexity"></a>
 <h4>AnnotationsChecker.__checkAnnotationComplexity</h4>
 <b>__checkAnnotationComplexity</b>(<i></i>)
@@ -178,6 +228,34 @@
 <p>
         Private method to check for function annotation issues.
 </p>
+<a NAME="AnnotationsChecker.__classifyError" ID="AnnotationsChecker.__classifyError"></a>
+<h4>AnnotationsChecker.__classifyError</h4>
+<b>__classifyError</b>(<i>function, arg</i>)
+
+<p>
+        Private method to classify the missing type annotation based on the
+        Function & Argument metadata.
+</p>
+<p>
+        For the currently defined rules & program flow, the assumption can be
+        made that an argument passed to this method will match a linting error,
+        and will only match a single linting error
+</p>
+<p>
+        This function provides an initial classificaton, then passes relevant
+        attributes to cached helper function(s).
+</p>
+<dl>
+
+<dt><i>function</i> (Function)</dt>
+<dd>
+reference to the Function object
+</dd>
+<dt><i>arg</i> (Argument)</dt>
+<dd>
+reference to the Argument object
+</dd>
+</dl>
 <a NAME="AnnotationsChecker.__error" ID="AnnotationsChecker.__error"></a>
 <h4>AnnotationsChecker.__error</h4>
 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
@@ -204,6 +282,90 @@
 arguments for the message
 </dd>
 </dl>
+<a NAME="AnnotationsChecker.__getAnnotationComplexity" ID="AnnotationsChecker.__getAnnotationComplexity"></a>
+<h4>AnnotationsChecker.__getAnnotationComplexity</h4>
+<b>__getAnnotationComplexity</b>(<i>annotationNode, defaultComplexity=1</i>)
+
+<p>
+        Private method to determine the annotation complexity.
+</p>
+<dl>
+
+<dt><i>annotationNode</i> (ast.AST)</dt>
+<dd>
+reference to the node to determine the annotation
+            complexity for
+</dd>
+<dt><i>defaultComplexity</i> (int)</dt>
+<dd>
+default complexity value
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+annotation complexity
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+= int
+</dd>
+</dl>
+<a NAME="AnnotationsChecker.__getAnnotationLength" ID="AnnotationsChecker.__getAnnotationLength"></a>
+<h4>AnnotationsChecker.__getAnnotationLength</h4>
+<b>__getAnnotationLength</b>(<i>annotationNode</i>)
+
+<p>
+        Private method to determine the annotation length.
+</p>
+<dl>
+
+<dt><i>annotationNode</i> (ast.AST)</dt>
+<dd>
+reference to the node to determine the annotation
+            length for
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+annotation length
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+= int
+</dd>
+</dl>
+<a NAME="AnnotationsChecker.__hasTypeAnnotations" ID="AnnotationsChecker.__hasTypeAnnotations"></a>
+<h4>AnnotationsChecker.__hasTypeAnnotations</h4>
+<b>__hasTypeAnnotations</b>(<i>funcNode</i>)
+
+<p>
+        Private method to check for type annotations.
+</p>
+<dl>
+
+<dt><i>funcNode</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
+<dd>
+reference to the function definition node to be checked
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+flag indicating the presence of type annotations
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+bool
+</dd>
+</dl>
 <a NAME="AnnotationsChecker.__ignoreCode" ID="AnnotationsChecker.__ignoreCode"></a>
 <h4>AnnotationsChecker.__ignoreCode</h4>
 <b>__ignoreCode</b>(<i>code</i>)
@@ -230,6 +392,40 @@
 bool
 </dd>
 </dl>
+<a NAME="AnnotationsChecker.__returnErrorClassifier" ID="AnnotationsChecker.__returnErrorClassifier"></a>
+<h4>AnnotationsChecker.__returnErrorClassifier</h4>
+<b>__returnErrorClassifier</b>(<i>isClassMethod, classDecoratorType, functionType</i>)
+
+<p>
+        Private method to classify a return type annotation issue.
+</p>
+<dl>
+
+<dt><i>isClassMethod</i> (bool)</dt>
+<dd>
+flag indicating a classmethod type function
+</dd>
+<dt><i>classDecoratorType</i> (ClassDecoratorType)</dt>
+<dd>
+type of class decorator
+</dd>
+<dt><i>functionType</i> (FunctionType)</dt>
+<dd>
+type of function
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+error code
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+str
+</dd>
+</dl>
 <a NAME="AnnotationsChecker.run" ID="AnnotationsChecker.run"></a>
 <h4>AnnotationsChecker.run</h4>
 <b>run</b>(<i></i>)
@@ -239,248 +435,4 @@
 </p>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
-<hr />
-<a NAME="FunctionVisitor" ID="FunctionVisitor"></a>
-<h2>FunctionVisitor</h2>
-
-<p>
-    Class implementing a node visitor to check function annotations.
-</p>
-<p>
-    Note: this class is modelled after flake8-annotations checker.
-</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="#FunctionVisitor.__init__">FunctionVisitor</a></td>
-<td>Constructor</td>
-</tr>
-<tr>
-<td><a href="#FunctionVisitor.__checkFunctionNode">__checkFunctionNode</a></td>
-<td>Private method to check an individual function definition node.</td>
-</tr>
-<tr>
-<td><a href="#FunctionVisitor.__classifyArgumentError">__classifyArgumentError</a></td>
-<td>Private method to classify and record an argument annotation issue.</td>
-</tr>
-<tr>
-<td><a href="#FunctionVisitor.__classifyReturnError">__classifyReturnError</a></td>
-<td>Private method to classify and record a return annotation issue.</td>
-</tr>
-<tr>
-<td><a href="#FunctionVisitor.visit_AsyncFunctionDef">visit_AsyncFunctionDef</a></td>
-<td>Public method to handle an async function or method definition.</td>
-</tr>
-<tr>
-<td><a href="#FunctionVisitor.visit_ClassDef">visit_ClassDef</a></td>
-<td>Public method to handle class definitions.</td>
-</tr>
-<tr>
-<td><a href="#FunctionVisitor.visit_FunctionDef">visit_FunctionDef</a></td>
-<td>Public method to handle a function or method definition.</td>
-</tr>
-</table>
-<h3>Static Methods</h3>
-
-<table>
-<tr><td>None</td></tr>
-</table>
-
-<a NAME="FunctionVisitor.__init__" ID="FunctionVisitor.__init__"></a>
-<h4>FunctionVisitor (Constructor)</h4>
-<b>FunctionVisitor</b>(<i>sourceLines</i>)
-
-<p>
-        Constructor
-</p>
-<dl>
-
-<dt><i>sourceLines</i> (list of str)</dt>
-<dd>
-lines of source code
-</dd>
-</dl>
-<a NAME="FunctionVisitor.__checkFunctionNode" ID="FunctionVisitor.__checkFunctionNode"></a>
-<h4>FunctionVisitor.__checkFunctionNode</h4>
-<b>__checkFunctionNode</b>(<i>node, classMethod=False</i>)
-
-<p>
-        Private method to check an individual function definition node.
-</p>
-<dl>
-
-<dt><i>node</i> (ast.FunctionDef or ast.AsyncFunctionDef)</dt>
-<dd>
-reference to the node to be processed
-</dd>
-<dt><i>classMethod</i> (bool)</dt>
-<dd>
-flag indicating a class method
-</dd>
-</dl>
-<a NAME="FunctionVisitor.__classifyArgumentError" ID="FunctionVisitor.__classifyArgumentError"></a>
-<h4>FunctionVisitor.__classifyArgumentError</h4>
-<b>__classifyArgumentError</b>(<i>argNode, argType, methodType</i>)
-
-<p>
-        Private method to classify and record an argument annotation issue.
-</p>
-<dl>
-
-<dt><i>argNode</i> (ast.arguments)</dt>
-<dd>
-reference to the argument node
-</dd>
-<dt><i>argType</i> (str)</dt>
-<dd>
-type of the argument node
-</dd>
-<dt><i>methodType</i> (str)</dt>
-<dd>
-type of method/function the argument belongs to
-</dd>
-</dl>
-<a NAME="FunctionVisitor.__classifyReturnError" ID="FunctionVisitor.__classifyReturnError"></a>
-<h4>FunctionVisitor.__classifyReturnError</h4>
-<b>__classifyReturnError</b>(<i>methodType, visibilityType, lineno, colOffset</i>)
-
-<p>
-        Private method to classify and record a return annotation issue.
-</p>
-<dl>
-
-<dt><i>methodType</i> (str)</dt>
-<dd>
-type of method/function the argument belongs to
-</dd>
-<dt><i>visibilityType</i> (str)</dt>
-<dd>
-visibility of the function
-</dd>
-<dt><i>lineno</i> (int)</dt>
-<dd>
-line number
-</dd>
-<dt><i>colOffset</i> (int)</dt>
-<dd>
-column number
-</dd>
-</dl>
-<a NAME="FunctionVisitor.visit_AsyncFunctionDef" ID="FunctionVisitor.visit_AsyncFunctionDef"></a>
-<h4>FunctionVisitor.visit_AsyncFunctionDef</h4>
-<b>visit_AsyncFunctionDef</b>(<i>node</i>)
-
-<p>
-        Public method to handle an async function or method definition.
-</p>
-<dl>
-
-<dt><i>node</i> (ast.AsyncFunctionDef)</dt>
-<dd>
-reference to the node to be processed
-</dd>
-</dl>
-<a NAME="FunctionVisitor.visit_ClassDef" ID="FunctionVisitor.visit_ClassDef"></a>
-<h4>FunctionVisitor.visit_ClassDef</h4>
-<b>visit_ClassDef</b>(<i>node</i>)
-
-<p>
-        Public method to handle class definitions.
-</p>
-<dl>
-
-<dt><i>node</i> (ast.ClassDef)</dt>
-<dd>
-reference to the node to be processed
-</dd>
-</dl>
-<a NAME="FunctionVisitor.visit_FunctionDef" ID="FunctionVisitor.visit_FunctionDef"></a>
-<h4>FunctionVisitor.visit_FunctionDef</h4>
-<b>visit_FunctionDef</b>(<i>node</i>)
-
-<p>
-        Public method to handle a function or method definition.
-</p>
-<dl>
-
-<dt><i>node</i> (ast.FunctionDef)</dt>
-<dd>
-reference to the node to be processed
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
-<hr />
-<a NAME="getAnnotationComplexity" ID="getAnnotationComplexity"></a>
-<h2>getAnnotationComplexity</h2>
-<b>getAnnotationComplexity</b>(<i>annotationNode</i>)
-
-<p>
-    Function to determine the annotation complexity.
-</p>
-<dl>
-
-<dt><i>annotationNode</i> (ast.AST)</dt>
-<dd>
-reference to the node to determine the annotation
-        complexity for
-</dd>
-</dl>
-<dl>
-<dt>Return:</dt>
-<dd>
-annotation complexity
-</dd>
-</dl>
-<dl>
-<dt>Return Type:</dt>
-<dd>
-= int
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
-<hr />
-<a NAME="hasTypeAnnotations" ID="hasTypeAnnotations"></a>
-<h2>hasTypeAnnotations</h2>
-<b>hasTypeAnnotations</b>(<i>funcNode</i>)
-
-<p>
-    Function to check for type annotations.
-</p>
-<dl>
-
-<dt><i>funcNode</i> (ast.AsyncFunctionDef or ast.FunctionDef)</dt>
-<dd>
-reference to the function definition node to be checked
-</dd>
-</dl>
-<dl>
-<dt>Return:</dt>
-<dd>
-flag indicating the presence of type annotations
-</dd>
-</dl>
-<dl>
-<dt>Return Type:</dt>
-<dd>
-bool
-</dd>
-</dl>
-<div align="right"><a href="#top">Up</a></div>
-<hr />
 </body></html>
\ No newline at end of file

eric ide

mercurial