class documentation

class ModuleVistor(NodeVisitor): (source)

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method depart_AsyncFunctionDef Undocumented
Method depart_ClassDef Undocumented
Method depart_FunctionDef Undocumented
Method depart_Module Undocumented
Method visit_AnnAssign Undocumented
Method visit_Assign Undocumented
Method visit_AsyncFunctionDef Undocumented
Method visit_ClassDef Undocumented
Method visit_Expr Undocumented
Method visit_FunctionDef Undocumented
Method visit_If Undocumented
Method visit_Import Process an import statement.
Method visit_ImportFrom Undocumented
Method visit_Module Undocumented
Instance Variable builder Undocumented
Instance Variable module Undocumented
Instance Variable system Undocumented
Method _annotations_from_function Get annotations from a function definition.
Method _getCurrentModuleExports Undocumented
Method _handleAssignment Undocumented
Method _handleAssignmentInClass Undocumented
Method _handleAssignmentInModule Undocumented
Method _handleClassVar Undocumented
Method _handleConstant Must be called after obj.setLineNumber() to have the right line number in the warning.
Method _handleDocstringUpdate Undocumented
Method _handleFunctionDef Undocumented
Method _handleInstanceVar Undocumented
Method _handleModuleVar Undocumented
Method _handleOldSchoolMethodDecoration Undocumented
Method _handlePropertyDef Undocumented
Method _handleReExport Move re-exported objects into current module.
Method _importAll Handle a from <modname> import * statement.
Method _importNames Handle a from <modname> import <names> statement.
Method _warnsConstantAssigmentOverride Undocumented
Method _warnsConstantReAssigmentInInstance Undocumented

Inherited from NodeVisitor:

Class Method get_children Returns the nested nodes in the body of a node.
Method generic_visit Helper method to visit a node by calling visit() on each child of the node. This is useful because this vistitor only visits statements inside .body attribute.

Inherited from PartialVisitor (via NodeVisitor):

Method unknown_departure Called before exiting unknown object types.
Method unknown_visit Called when entering unknown object types.

Inherited from Visitor (via NodeVisitor, PartialVisitor):

Exception SkipChildren Do not visit any children of the current node. The current node's siblings and depart_... method are not affected.
Exception SkipDeparture Do not call the current node's depart_... method. The current node's children and siblings are not affected.
Exception SkipNode Do not visit the current node's children, and do not call the current node's depart_... method.
Exception SkipSiblings Do not visit any more siblings (to the right) of the current node. The current node's children and its depart_... method are not affected.
Method depart Extend the base depart with extensions.
Method visit Extend the base visit with extensions.
Method walk Traverse a tree of objects, calling the visit() method of visitor when entering each node. (The walkabout() method is similar, except it also calls the depart() method before exiting each objects.)
Method walkabout Perform a tree traversal similarly to walk() (which see), except also call the depart() method before exiting each node.
Instance Variable extensions Undocumented
Exception _TreePruningException Base class for Visitor-related tree pruning exceptions.
def __init__(self, builder, module): (source)

Undocumented

Parameters
builder:ASTBuilderUndocumented
module:model.ModuleUndocumented
def depart_AsyncFunctionDef(self, node): (source)

Undocumented

Parameters
node:ast.AsyncFunctionDefUndocumented
def depart_ClassDef(self, node): (source)

Undocumented

Parameters
node:ast.ClassDefUndocumented
def depart_FunctionDef(self, node): (source)

Undocumented

Parameters
node:ast.FunctionDefUndocumented
def depart_Module(self, node): (source)

Undocumented

Parameters
node:ast.ModuleUndocumented
def visit_AnnAssign(self, node): (source)

Undocumented

Parameters
node:ast.AnnAssignUndocumented
def visit_Assign(self, node): (source)

Undocumented

Parameters
node:ast.AssignUndocumented
def visit_AsyncFunctionDef(self, node): (source)

Undocumented

Parameters
node:ast.AsyncFunctionDefUndocumented
def visit_ClassDef(self, node): (source)

Undocumented

Parameters
node:ast.ClassDefUndocumented
def visit_Expr(self, node): (source)

Undocumented

Parameters
node:ast.ExprUndocumented
def visit_FunctionDef(self, node): (source)

Undocumented

Parameters
node:ast.FunctionDefUndocumented
def visit_If(self, node): (source)

Undocumented

Parameters
node:ast.IfUndocumented
def visit_Import(self, node): (source)

Process an import statement.

The grammar for the statement is roughly:

mod_as := DOTTEDNAME ['as' NAME] import_stmt := 'import' mod_as (',' mod_as)*

and this is translated into a node which is an instance of Import wih an attribute 'names', which is in turn a list of 2-tuples (dotted_name, as_name) where as_name is None if there was no 'as foo' part of the statement.

Parameters
node:ast.ImportUndocumented
def visit_ImportFrom(self, node): (source)

Undocumented

Parameters
node:ast.ImportFromUndocumented
def visit_Module(self, node): (source)

Undocumented

Parameters
node:ast.ModuleUndocumented

Undocumented

Undocumented

Undocumented

def _annotations_from_function(self, func): (source)

Get annotations from a function definition.

Parameters
func:Union[ast.AsyncFunctionDef, ast.FunctionDef]The function definition's AST.
Returns
Mapping[str, Optional[ast.expr]]Mapping from argument name to annotation. The name return is used for the return type. Unannotated arguments are omitted.
def _getCurrentModuleExports(self): (source)

Undocumented

Returns
Collection[str]Undocumented
def _handleAssignment(self, targetNode, annotation, expr, lineno): (source)

Undocumented

Parameters
targetNode:ast.exprUndocumented
annotation:Optional[ast.expr]Undocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleAssignmentInClass(self, target, annotation, expr, lineno): (source)

Undocumented

Parameters
target:strUndocumented
annotation:Optional[ast.expr]Undocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleAssignmentInModule(self, target, annotation, expr, lineno): (source)

Undocumented

Parameters
target:strUndocumented
annotation:Optional[ast.expr]Undocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleClassVar(self, name, annotation, expr, lineno): (source)

Undocumented

Parameters
name:strUndocumented
annotation:Optional[ast.expr]Undocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleConstant(self, obj, value, lineno): (source)

Must be called after obj.setLineNumber() to have the right line number in the warning.

Parameters
obj:model.AttributeUndocumented
value:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleDocstringUpdate(self, targetNode, expr, lineno): (source)

Undocumented

Parameters
targetNode:ast.exprUndocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleFunctionDef(self, node, is_async): (source)

Undocumented

Parameters
node:Union[ast.AsyncFunctionDef, ast.FunctionDef]Undocumented
is_async:boolUndocumented
def _handleInstanceVar(self, name, annotation, expr, lineno): (source)

Undocumented

Parameters
name:strUndocumented
annotation:Optional[ast.expr]Undocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleModuleVar(self, target, annotation, expr, lineno): (source)

Undocumented

Parameters
target:strUndocumented
annotation:Optional[ast.expr]Undocumented
expr:Optional[ast.expr]Undocumented
lineno:intUndocumented
def _handleOldSchoolMethodDecoration(self, target, expr): (source)

Undocumented

Parameters
target:strUndocumented
expr:Optional[ast.expr]Undocumented
Returns
boolUndocumented
def _handlePropertyDef(self, node, docstring, lineno): (source)

Undocumented

Parameters
node:Union[ast.AsyncFunctionDef, ast.FunctionDef]Undocumented
docstring:Optional[ast.Str]Undocumented
lineno:intUndocumented
Returns
model.AttributeUndocumented
def _handleReExport(self, curr_mod_exports, origin_name, as_name, origin_module): (source)

Move re-exported objects into current module.

Parameters
curr_mod_exports:Collection[str]Undocumented
origin_name:strUndocumented
as_name:strUndocumented
origin_module:model.ModuleUndocumented
Returns
boolTrue if the imported name has been sucessfully re-exported.
def _importAll(self, modname): (source)

Handle a from <modname> import * statement.

Parameters
modname:strUndocumented
def _importNames(self, modname, names): (source)

Handle a from <modname> import <names> statement.

Parameters
modname:strUndocumented
names:Iterable[ast.alias]Undocumented
def _warnsConstantAssigmentOverride(self, obj, lineno_offset): (source)

Undocumented

Parameters
obj:model.AttributeUndocumented
lineno_offset:intUndocumented
def _warnsConstantReAssigmentInInstance(self, obj, lineno_offset=0): (source)

Undocumented

Parameters
obj:model.AttributeUndocumented
lineno_offset:intUndocumented