stubber.cst_transformer
¶
Module Contents¶
Classes¶
contains the functiondefs and classdefs info read from the stubs source |
|
The low-level base visitor class for traversing a CST. This should be used in |
Functions¶
|
Update the docstring of a function/method or class |
|
Update the docstring of a module |
Attributes¶
- class stubber.cst_transformer.TypeInfo¶
contains the functiondefs and classdefs info read from the stubs source
- name :str¶
- decorators :Sequence[libcst.Decorator]¶
- params :Optional[libcst.Parameters]¶
- returns :Optional[libcst.Annotation]¶
- docstr_node :Optional[libcst.SimpleStatementLine]¶
- def_node :Optional[Union[libcst.FunctionDef, libcst.ClassDef]]¶
- def_type :str = ?¶
- exception stubber.cst_transformer.TransformError¶
Bases:
Exception
Error raised upon encountering a known error while attempting to transform the tree.
- stubber.cst_transformer.MODULE_KEY¶
- stubber.cst_transformer._m¶
- class stubber.cst_transformer.StubTypingCollector¶
Bases:
libcst.CSTVisitor
The low-level base visitor class for traversing a CST. This should be used in conjunction with the
visit()
method on aCSTNode
to visit each element in a tree starting with that node. UnlikeCSTTransformer
, instances of this class cannot modify the tree.When visiting nodes using a
CSTVisitor
, the return value ofvisit()
will equal the passed in tree.- visit_Module(node: libcst.Module) bool ¶
Store the module docstring
- Parameters
node (libcst.Module) –
- Return type
- visit_ClassDef(node: libcst.ClassDef) Optional[bool] ¶
Store the class docstring
- Parameters
node (libcst.ClassDef) –
- Return type
Optional[bool]
- leave_ClassDef(original_node: libcst.ClassDef) None ¶
- Parameters
original_node (libcst.ClassDef) –
- Return type
None
- stubber.cst_transformer.update_def_docstr(dest_node: Union[libcst.FunctionDef, libcst.ClassDef], src_comment: Optional[libcst.SimpleStatementLine], src_node=None) Any ¶
Update the docstring of a function/method or class
for functiondefs ending in an ellipsis, the entire body needs to be replaced. in this case the src_body is mandatory.
- Parameters
dest_node (Union[libcst.FunctionDef, libcst.ClassDef]) –
src_comment (Optional[libcst.SimpleStatementLine]) –
- Return type
Any
- stubber.cst_transformer.update_module_docstr(node: libcst.Module, doc_tree: Optional[libcst.SimpleStatementLine]) Any ¶
Update the docstring of a module
- Parameters
node (libcst.Module) –
doc_tree (Optional[libcst.SimpleStatementLine]) –
- Return type
Any