eric7.Plugins.CheckerPlugins.CodeStyleChecker.Annotations.AnnotationsFutureVisitor

Module implementing a node visitor for function type annotations.

Global Attributes

None

Classes

AnnotationsFutureVisitor Class implementing a node visitor to check __future__ imports.

Functions

None


AnnotationsFutureVisitor

Class implementing a node visitor to check __future__ imports.

Derived from

ast.NodeVisitor

Class Attributes

SimplifiedTypes
SimplifyableTypes

Class Methods

None

Methods

AnnotationsFutureVisitor Constructor
__processAnnotation Private method to process the given annotations.
getSimplifiedTypes Public method Public method to get the list of detected simplified types.
getTypingImports Public method to get the list of typing imports.
hasSimplifiedTypes Public method to check, if the analyzed code includes annotations with simplified types.
hasTypingImports Public method to check, if the analyzed code includes typing imports.
importsFutureAnnotations Public method to check, if the analyzed code uses future annotation.
visit_AnnAssign Public method to check type annotations.
visit_Attribute Public method to record simplifiable names.
visit_Import Public method to check imports for typing related stuff.
visit_ImportFrom Public method to detect the 'from __future__ import annotations' import if present.
visit_arg Public method to check argument annotations.

Static Methods

None

AnnotationsFutureVisitor (Constructor)

AnnotationsFutureVisitor()

Constructor

AnnotationsFutureVisitor.__processAnnotation

__processAnnotation(node)

Private method to process the given annotations.

node (ast.expr)
reference to the AST node containing the annotations

AnnotationsFutureVisitor.getSimplifiedTypes

getSimplifiedTypes()

Public method Public method to get the list of detected simplified types.

Return:
list of simplified types
Return Type:
list of str

AnnotationsFutureVisitor.getTypingImports

getTypingImports()

Public method to get the list of typing imports.

Return:
list of typing imports
Return Type:
list of str

AnnotationsFutureVisitor.hasSimplifiedTypes

hasSimplifiedTypes()

Public method to check, if the analyzed code includes annotations with simplified types.

Return:
flag indicating the presence of simplified types
Return Type:
bool

AnnotationsFutureVisitor.hasTypingImports

hasTypingImports()

Public method to check, if the analyzed code includes typing imports.

Return:
flag indicating the use of typing imports
Return Type:
bool

AnnotationsFutureVisitor.importsFutureAnnotations

importsFutureAnnotations()

Public method to check, if the analyzed code uses future annotation.

Return:
flag indicatung the use of future annotation
Return Type:
bool

AnnotationsFutureVisitor.visit_AnnAssign

visit_AnnAssign(node)

Public method to check type annotations.

node (ast.AnnAssign)
reference to the AST Assign node

AnnotationsFutureVisitor.visit_Attribute

visit_Attribute(node)

Public method to record simplifiable names.

If 'import typing' or 'import typing as t' is used, add simplifiable names that were used later on in the code.

node (ast.Attribute)
reference to the AST Attribute node

AnnotationsFutureVisitor.visit_Import

visit_Import(node)

Public method to check imports for typing related stuff.

This looks like: import typing or import typing as t

typing or t will be added to the list of typing aliases.

node (ast.Import)
reference to the AST Import node

AnnotationsFutureVisitor.visit_ImportFrom

visit_ImportFrom(node)

Public method to detect the 'from __future__ import annotations' import if present.

If 'from typing import ...' is used, add simplifiable names that were imported.

node (ast.ImportFrom)
reference to the AST ImportFrom node

AnnotationsFutureVisitor.visit_arg

visit_arg(node: ast.arg)

Public method to check argument annotations.

node (ast.arg)
reference to the AST argument node
Up