basics

Module Contents

Classes

TypingCollector

The low-level base visitor class for traversing a CST. This should be used in

TypingTransformer

The low-level base visitor class for traversing a CST and creating an

Attributes

source_tree

info_tree

visitor

transformer

modified_tree

class basics.TypingCollector

Bases: libcst.CSTVisitor

The low-level base visitor class for traversing a CST. This should be used in conjunction with the visit() method on a CSTNode to visit each element in a tree starting with that node. Unlike CSTTransformer, instances of this class cannot modify the tree.

When visiting nodes using a CSTVisitor, the return value of visit() will equal the passed in tree.

visit_ClassDef(self, node: libcst.ClassDef) Optional[bool]
Parameters

node (libcst.ClassDef) –

Return type

Optional[bool]

leave_ClassDef(self, node: libcst.ClassDef) None
Parameters

node (libcst.ClassDef) –

Return type

None

visit_FunctionDef(self, node: libcst.FunctionDef) Optional[bool]
Parameters

node (libcst.FunctionDef) –

Return type

Optional[bool]

leave_FunctionDef(self, node: libcst.FunctionDef) None
Parameters

node (libcst.FunctionDef) –

Return type

None

class basics.TypingTransformer(annotations)

Bases: libcst.CSTTransformer

The low-level base visitor class for traversing a CST and creating an updated copy of the original CST. This should be used in conjunction with the visit() method on a CSTNode to visit each element in a tree starting with that node, and possibly returning a new node in its place.

When visiting nodes using a CSTTransformer, the return value of visit() will be a new tree with any changes made in on_leave() calls reflected in its children.

visit_ClassDef(self, node: libcst.ClassDef) Optional[bool]
Parameters

node (libcst.ClassDef) –

Return type

Optional[bool]

leave_ClassDef(self, original_node: libcst.ClassDef, updated_node: libcst.ClassDef) libcst.CSTNode
Parameters
  • original_node (libcst.ClassDef) –

  • updated_node (libcst.ClassDef) –

Return type

libcst.CSTNode

visit_FunctionDef(self, node: libcst.FunctionDef) Optional[bool]
Parameters

node (libcst.FunctionDef) –

Return type

Optional[bool]

leave_FunctionDef(self, original_node: libcst.FunctionDef, updated_node: libcst.FunctionDef) libcst.CSTNode
Parameters
  • original_node (libcst.FunctionDef) –

  • updated_node (libcst.FunctionDef) –

Return type

libcst.CSTNode

basics.source_tree
basics.info_tree
basics.visitor
basics.transformer
basics.modified_tree