class documentation

class TransformVisitor: (source)

View In Hierarchy

A visitor for handling transforms. The standard approach of using it is to call :meth:`~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. Based on its usage in AstroidManager.brain, it should not be reinstantiated.

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.
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.

transforms = (source)

Undocumented

def _transform(self, node: NodeNG) -> NodeNG: (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