# eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsChecker

Module implementing a checker for function type annotations.

### Global Attributes

None

### Classes

AnnotationsChecker | Class implementing a checker for function type annotations.

### Functions

None

## AnnotationsChecker

Class implementing a checker for function type annotations.

### Derived from

None

### Class Attributes

Codes

### Class Methods

None

### Methods

AnnotationsChecker | Constructor
__argumentErrorClassifier | Private method to classify an argument type annotation issue.
__checkAnnotationComplexity | Private method to check the type annotation complexity.
__checkAnnotationPep604 | Private method to check the use of typing.Union.
__checkAnnotationsCoverage | Private method to check for function annotation coverage.
__checkAnnotationsFuture | Private method to check the use of __future__ and typing imports.
__checkDeprecatedTypingSymbols | Private method to check the use of deprecated 'typing' symbols.
__checkFunctionAnnotations | Private method to check for function annotation issues.
__classifyError | Private method to classify the missing type annotation based on the Function & Argument metadata.
__error | Private method to record an issue.
__getAnnotationComplexity | Private method to determine the annotation complexity.
__getAnnotationLength | Private method to determine the annotation length.
__hasTypeAnnotations | Private method to check for type annotations.
__ignoreCode | Private method to check if the message code should be ignored.
__returnErrorClassifier | Private method to classify a return type annotation issue.
run | Public method to check the given source against annotation issues.

### Static Methods

None

#### AnnotationsChecker (Constructor)

AnnotationsChecker(source, filename, tree, select, ignore, expected, repeat, args)

Constructor

source (list of str)
  source code to be checked
filename (str)
  name of the source file
tree (ast.Module)
  AST tree of the source code
select (list of str)
  list of selected codes
ignore (list of str)
  list of codes to be ignored
expected (list of str)
  list of expected codes
repeat (bool)
  flag indicating to report each occurrence of a code
args (dict)
  dictionary of arguments for the annotation checks

#### AnnotationsChecker.__argumentErrorClassifier

__argumentErrorClassifier(isClassMethod, isFirstArg, classDecoratorType, annotationType)

Private method to classify an argument type annotation issue.

isClassMethod (bool)
  flag indicating a classmethod type function
isFirstArg (bool)
  flag indicating the first argument
classDecoratorType (enums.ClassDecoratorType)
  type of class decorator
annotationType (AnnotationType)
  type of annotation

Return:
  error code

Return Type:
  str

#### AnnotationsChecker.__checkAnnotationComplexity

__checkAnnotationComplexity()

Private method to check the type annotation complexity.

#### AnnotationsChecker.__checkAnnotationPep604

__checkAnnotationPep604()

Private method to check the use of typing.Union.

#### AnnotationsChecker.__checkAnnotationsCoverage

__checkAnnotationsCoverage()

Private method to check for function annotation coverage.

#### AnnotationsChecker.__checkAnnotationsFuture

__checkAnnotationsFuture()

Private method to check the use of __future__ and typing imports.

#### AnnotationsChecker.__checkDeprecatedTypingSymbols

__checkDeprecatedTypingSymbols()

Private method to check the use of deprecated 'typing' symbols.

#### AnnotationsChecker.__checkFunctionAnnotations

__checkFunctionAnnotations()

Private method to check for function annotation issues.

#### AnnotationsChecker.__classifyError

__classifyError(function, arg)

Private method to classify the missing type annotation based on the Function & Argument metadata.

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

This function provides an initial classificaton, then passes relevant attributes to cached helper function(s).

function (Function)
  reference to the Function object
arg (Argument)
  reference to the Argument object

#### AnnotationsChecker.__error

__error(lineNumber, offset, code, *args)

Private method to record an issue.

lineNumber (int)
  line number of the issue
offset (int)
  position within line of the issue
code (str)
  message code
args (list)
  arguments for the message

#### AnnotationsChecker.__getAnnotationComplexity

__getAnnotationComplexity(annotationNode, defaultComplexity=1)

Private method to determine the annotation complexity.

annotationNode (ast.AST)
  reference to the node to determine the annotation complexity for
defaultComplexity (int)
  default complexity value

Return:
  annotation complexity

Return Type:
  = int

#### AnnotationsChecker.__getAnnotationLength

__getAnnotationLength(annotationNode)

Private method to determine the annotation length.

annotationNode (ast.AST)
  reference to the node to determine the annotation length for

Return:
  annotation length

Return Type:
  = int

#### AnnotationsChecker.__hasTypeAnnotations

__hasTypeAnnotations(funcNode)

Private method to check for type annotations.

funcNode (ast.AsyncFunctionDef or ast.FunctionDef)
  reference to the function definition node to be checked

Return:
  flag indicating the presence of type annotations

Return Type:
  bool

#### AnnotationsChecker.__ignoreCode

__ignoreCode(code)

Private method to check if the message code should be ignored.

code (str)
  message code to check for

Return:
  flag indicating to ignore the given code

Return Type:
  bool

#### AnnotationsChecker.__returnErrorClassifier

__returnErrorClassifier(isClassMethod, classDecoratorType, functionType)

Private method to classify a return type annotation issue.

isClassMethod (bool)
  flag indicating a classmethod type function
classDecoratorType (ClassDecoratorType)
  type of class decorator
functionType (FunctionType)
  type of function

Return:
  error code

Return Type:
  str

#### AnnotationsChecker.run

run()

Public method to check the given source against annotation issues.

Up