lineapy.transformer package

Submodules

lineapy.transformer.node_transformer module

class lineapy.transformer.node_transformer.NodeTransformer(code: str, location: Union[pathlib.Path, lineapy.data.types.JupyterCell], tracer: lineapy.instrumentation.tracer.Tracer)[source]

Note

  • 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.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: _ast.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: _ast.Call) Optional[lineapy.data.types.CallNode][source]
Returns None if visiting special publish linea publish,

which cannot be chained

visit_Ellipsis(node: _ast.Ellipsis) lineapy.data.types.LiteralNode[source]

Note

Deprecated in Python 3.8

visit_ExtSlice(node: _ast.ExtSlice) Union[lineapy.data.types.ImportNode, lineapy.data.types.CallNode, lineapy.data.types.LiteralNode, lineapy.data.types.LookupNode, lineapy.data.types.MutateNode, lineapy.data.types.GlobalNode, lineapy.data.types.IfNode, lineapy.data.types.ElseNode][source]

Note

Deprecated in Python 3.9

visit_Import(node: _ast.Import) None[source]

Similar to visit_ImportFrom, slightly different class syntax

visit_Index(node: _ast.Index) Union[lineapy.data.types.ImportNode, lineapy.data.types.CallNode, lineapy.data.types.LiteralNode, lineapy.data.types.LookupNode, lineapy.data.types.MutateNode, lineapy.data.types.GlobalNode, lineapy.data.types.IfNode, lineapy.data.types.ElseNode][source]

Note

Deprecated in Python 3.9

visit_NameConstant(node: _ast.NameConstant) lineapy.data.types.LiteralNode[source]

Note

Deprecated in Python 3.8

visit_Num(node: _ast.Num) lineapy.data.types.LiteralNode[source]

Note

Deprecated in Python 3.8

visit_Str(node: _ast.Str) lineapy.data.types.LiteralNode[source]

Note

Deprecated in Python 3.8

visit_assign_value(target: _ast.AST, value_node: Union[lineapy.data.types.ImportNode, lineapy.data.types.CallNode, lineapy.data.types.LiteralNode, lineapy.data.types.LookupNode, lineapy.data.types.MutateNode, lineapy.data.types.GlobalNode, lineapy.data.types.IfNode, lineapy.data.types.ElseNode], source_location: Optional[lineapy.data.types.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.source_giver module

lineapy.transformer.transform_code module

lineapy.transformer.transform_code.transform(code: str, location: Union[pathlib.Path, lineapy.data.types.JupyterCell], tracer: lineapy.instrumentation.tracer.Tracer) Optional[Union[lineapy.data.types.ImportNode, lineapy.data.types.CallNode, lineapy.data.types.LiteralNode, lineapy.data.types.LookupNode, lineapy.data.types.MutateNode, lineapy.data.types.GlobalNode, lineapy.data.types.IfNode, lineapy.data.types.ElseNode]][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.

lineapy.transformer.transformer_util module

Module contents