lineapy.transformer package
Submodules
lineapy.transformer.node_transformer module
- class lineapy.transformer.node_transformer.NodeTransformer(code: str, location: Union[Path, JupyterCell], tracer: Tracer)[source]
Need to be careful about the order by which these calls are invoked so that the transformation do not get called more than once.
- generic_visit(node: AST)[source]
This will capture any generic blackboxes. Now that we have a clean scope handling, we can separate them out into two types: expressions that return something and statements that return nothing
- visit_Assign(node: Assign) None [source]
Todo
None variable assignment, should be turned into a setattr call not an assignment, so we might need to change the return signature from ast.Expr.
- visit_Call(node: Call) Optional[CallNode] [source]
- Returns None if visiting special publish linea publish,
which cannot be chained
- visit_Ellipsis(node: Ellipsis) LiteralNode [source]
Note
Deprecated in Python 3.8
- visit_ExtSlice(node: ExtSlice) Union[ImportNode, CallNode, LiteralNode, LookupNode, MutateNode, GlobalNode] [source]
Note
Deprecated in Python 3.9
- visit_Import(node: Import) None [source]
Similar to visit_ImportFrom, slightly different class syntax
- visit_Index(node: Index) Union[ImportNode, CallNode, LiteralNode, LookupNode, MutateNode, GlobalNode] [source]
Note
Deprecated in Python 3.9
- visit_NameConstant(node: NameConstant) LiteralNode [source]
Note
Deprecated in Python 3.8
- visit_Num(node: Num) LiteralNode [source]
Note
Deprecated in Python 3.8
- visit_Str(node: Str) LiteralNode [source]
Note
Deprecated in Python 3.8
- visit_assign_value(target: AST, value_node: Union[ImportNode, CallNode, LiteralNode, LookupNode, MutateNode, GlobalNode], source_location: Optional[SourceLocation] = None) None [source]
Visits assigning a target node to a value. This is extracted out of visit_assign, so we can call it multiple times and pass in the value as a node, instead of as AST, when we are assigning to a tuple. Assign currently special cases for: - Subscript, e.g., ls[0] = 1 - Constant, e.g., a = 1 - Call, e.g., a = foo()
- lineapy.transformer.node_transformer.transform(code: str, location: Union[Path, JupyterCell], tracer: Tracer) Optional[Union[ImportNode, CallNode, LiteralNode, LookupNode, MutateNode, GlobalNode]] [source]
Traces the given code, executing it and writing the results to the DB.
It returns the node corresponding to the last statement in the code, if it exists.