class documentation

class TransformVisitor: (source)

View In Hierarchy

A visitor for handling transforms.

The standard approach of using it is to call ~visit with an astroid module and the class will take care of the rest, walking the tree and running the transforms for each encountered node.

Method __init__ Undocumented
Method register​_transform Register transform(node) function to be applied on the given astroid's node_class if predicate is None or returns true when called with the node as argument.
Method unregister​_transform Unregister the given transform.
Method visit Walk the given astroid tree and transform each encountered node
Constant TRANSFORM​_MAX​_CACHE​_SIZE Undocumented
Instance Variable transforms Undocumented
Method _transform Call matching transforms for the given node if any and return the transformed node.
Method _visit Undocumented
Method _visit​_generic Undocumented
def __init__(self): (source)

Undocumented

def register_transform(self, node_class, transform, predicate=None): (source)

Register transform(node) function to be applied on the given astroid's node_class if predicate is None or returns true when called with the node as argument.

The transform function may return a value which is then used to substitute the original node in the tree.

def unregister_transform(self, node_class, transform, predicate=None): (source)
Unregister the given transform.
def visit(self, module): (source)

Walk the given astroid tree and transform each encountered node

Only the nodes which have transforms registered will actually be replaced or changed.

TRANSFORM_MAX_CACHE_SIZE: int = (source)

Undocumented

Value
10000
transforms = (source)

Undocumented

@lru_cache(maxsize=TRANSFORM_MAX_CACHE_SIZE)
def _transform(self, node): (source)
Call matching transforms for the given node if any and return the transformed node.
def _visit(self, node): (source)

Undocumented

def _visit_generic(self, node): (source)

Undocumented