py2dag 0.3.6__tar.gz → 0.3.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: py2dag
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: Convert Python function plans to DAG (JSON, pseudo, optional SVG).
5
5
  License: MIT
6
6
  Author: rvergis
@@ -722,11 +722,28 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
722
722
  for stmt in body:
723
723
  _parse_stmt(stmt)
724
724
 
725
+ # If no explicit return was encountered, emit a terminal break node so
726
+ # that the plan represents function completion.
727
+ break_id: Optional[str] = None
728
+ if returned_var is None:
729
+ break_id = _ssa_new("break")
730
+ ops.append({"id": break_id, "op": "CTRL.break", "deps": [], "args": {}})
731
+
732
+ # If no outputs were produced, synthesise a default return of `None` so
733
+ # that parsing succeeds for empty functions.
734
+ if returned_var is None and not outputs:
735
+ const_id = _ssa_new("return_value")
736
+ ops.append({
737
+ "id": const_id,
738
+ "op": "CONST.value",
739
+ "deps": [],
740
+ "args": {"value": None},
741
+ })
742
+ returned_var = const_id
743
+
725
744
  if not outputs:
726
- if returned_var is not None:
727
- outputs.append({"from": returned_var, "as": "return"})
728
- else:
729
- raise DSLParseError("At least one output() call required")
745
+ outputs.append({"from": returned_var if returned_var is not None else break_id, "as": "return"})
746
+
730
747
  if len(ops) > 2000:
731
748
  raise DSLParseError("Too many operations")
732
749
 
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "py2dag"
7
- version = "0.3.6"
7
+ version = "0.3.7"
8
8
  description = "Convert Python function plans to DAG (JSON, pseudo, optional SVG)."
9
9
  authors = ["rvergis"]
10
10
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes