py2dag 0.3.5__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.
- {py2dag-0.3.5 → py2dag-0.3.7}/PKG-INFO +1 -1
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/parser.py +36 -6
- {py2dag-0.3.5 → py2dag-0.3.7}/pyproject.toml +1 -1
- {py2dag-0.3.5 → py2dag-0.3.7}/LICENSE +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/README.md +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/__init__.py +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/cli.py +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/colors.py +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/export_dagre.py +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/export_svg.py +0 -0
- {py2dag-0.3.5 → py2dag-0.3.7}/py2dag/pseudo.py +0 -0
@@ -131,7 +131,7 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
131
131
|
return list(prev.get("deps", []))
|
132
132
|
return [ssa_var]
|
133
133
|
|
134
|
-
for arg in call.args:
|
134
|
+
for idx, arg in enumerate(call.args):
|
135
135
|
if isinstance(arg, ast.Starred):
|
136
136
|
star_val = arg.value
|
137
137
|
if isinstance(star_val, ast.Name):
|
@@ -156,7 +156,20 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
156
156
|
deps.append(_ssa_get(elt.id))
|
157
157
|
dep_labels.append("")
|
158
158
|
else:
|
159
|
-
|
159
|
+
# Allow literal positional arguments by emitting a CONST node
|
160
|
+
try:
|
161
|
+
lit = _literal(arg)
|
162
|
+
except DSLParseError:
|
163
|
+
raise DSLParseError("Positional args must be variable names or lists/tuples of names or literals")
|
164
|
+
const_id = _ssa_new(f"{var_name}_arg{idx}")
|
165
|
+
ops.append({
|
166
|
+
"id": const_id,
|
167
|
+
"op": "CONST.value",
|
168
|
+
"deps": [],
|
169
|
+
"args": {"value": lit},
|
170
|
+
})
|
171
|
+
deps.append(const_id)
|
172
|
+
dep_labels.append("")
|
160
173
|
|
161
174
|
kwargs: Dict[str, Any] = {}
|
162
175
|
for kw in call.keywords:
|
@@ -709,11 +722,28 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
709
722
|
for stmt in body:
|
710
723
|
_parse_stmt(stmt)
|
711
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
|
+
|
712
744
|
if not outputs:
|
713
|
-
if returned_var is not None:
|
714
|
-
|
715
|
-
else:
|
716
|
-
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
|
+
|
717
747
|
if len(ops) > 2000:
|
718
748
|
raise DSLParseError("Too many operations")
|
719
749
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|