py2dag 0.1.8__py3-none-any.whl → 0.1.10__py3-none-any.whl
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/parser.py +15 -3
- {py2dag-0.1.8.dist-info → py2dag-0.1.10.dist-info}/METADATA +1 -1
- py2dag-0.1.10.dist-info/RECORD +11 -0
- py2dag-0.1.8.dist-info/RECORD +0 -11
- {py2dag-0.1.8.dist-info → py2dag-0.1.10.dist-info}/LICENSE +0 -0
- {py2dag-0.1.8.dist-info → py2dag-0.1.10.dist-info}/WHEEL +0 -0
- {py2dag-0.1.8.dist-info → py2dag-0.1.10.dist-info}/entry_points.txt +0 -0
py2dag/parser.py
CHANGED
@@ -101,6 +101,15 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
101
101
|
"deps": deps,
|
102
102
|
"args": {"template": template},
|
103
103
|
})
|
104
|
+
elif isinstance(value, (ast.Constant, ast.List, ast.Tuple, ast.Dict)):
|
105
|
+
# Allow assigning JSON-serialisable literals directly
|
106
|
+
lit = _literal(value)
|
107
|
+
ops.append({
|
108
|
+
"id": var_name,
|
109
|
+
"op": "CONST.value",
|
110
|
+
"deps": [],
|
111
|
+
"args": {"value": lit},
|
112
|
+
})
|
104
113
|
else:
|
105
114
|
raise DSLParseError("Right hand side must be a call or f-string")
|
106
115
|
defined.add(var_name)
|
@@ -144,9 +153,9 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
144
153
|
if var not in defined:
|
145
154
|
raise DSLParseError(f"Undefined return variable: {var}")
|
146
155
|
returned_var = var
|
147
|
-
elif isinstance(stmt.value, ast.Constant):
|
148
|
-
# Support returning a literal (
|
149
|
-
lit = stmt.value
|
156
|
+
elif isinstance(stmt.value, (ast.Constant, ast.List, ast.Tuple, ast.Dict)):
|
157
|
+
# Support returning a JSON-serialisable literal (str/num/bool/None, list/tuple, dict)
|
158
|
+
lit = _literal(stmt.value)
|
150
159
|
const_id_base = "return_value"
|
151
160
|
const_id = const_id_base
|
152
161
|
n = 1
|
@@ -162,6 +171,9 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
162
171
|
returned_var = const_id
|
163
172
|
else:
|
164
173
|
raise DSLParseError("return must return a variable name or literal")
|
174
|
+
elif isinstance(stmt, (ast.For, ast.AsyncFor, ast.While)):
|
175
|
+
# Ignore control flow blocks; only top-level linear statements are modeled
|
176
|
+
continue
|
165
177
|
else:
|
166
178
|
raise DSLParseError("Only assignments, expression calls, and a final return are allowed in function body")
|
167
179
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
py2dag/__init__.py,sha256=i8VB44JCVcRJAcvnQtbH8YVRUz5j7dE355iRbikXPGQ,250
|
2
|
+
py2dag/cli.py,sha256=BCBi5mNxOqeEN8uEMt_hiDx0iSt7ZE3y74cGXREzZ2I,1296
|
3
|
+
py2dag/export_dagre.py,sha256=S244wUxBMuM9qXD8bklaslkMp3rcbBGWvMhwWVBzBF0,3487
|
4
|
+
py2dag/export_svg.py,sha256=YyjqOuj8GhUTDWP70SKnnSWAKI1PvJwyOhHLwB29uNM,1812
|
5
|
+
py2dag/parser.py,sha256=nj3QE_6iPBktdBQFt5DF0YYitPKVQRmtcuLxG9WyQjE,10444
|
6
|
+
py2dag/pseudo.py,sha256=NJK61slyFLtSjhj8gJDJneUInEpBN57_41g8IfHNPWI,922
|
7
|
+
py2dag-0.1.10.dist-info/LICENSE,sha256=3Qee1EPwej_nusovTbyIQ8LvD2rXHdM0c6LNwk_D8Kc,1067
|
8
|
+
py2dag-0.1.10.dist-info/METADATA,sha256=0VGU_tJB5PeSIuZVr2ZTUkxqvXCgcMnl5QUHdOzSN2w,3550
|
9
|
+
py2dag-0.1.10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
10
|
+
py2dag-0.1.10.dist-info/entry_points.txt,sha256=Q0SHexJJ0z1te4AYL1xTZogx5FrxCCE1ZJ5qntkFMZs,42
|
11
|
+
py2dag-0.1.10.dist-info/RECORD,,
|
py2dag-0.1.8.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
py2dag/__init__.py,sha256=i8VB44JCVcRJAcvnQtbH8YVRUz5j7dE355iRbikXPGQ,250
|
2
|
-
py2dag/cli.py,sha256=BCBi5mNxOqeEN8uEMt_hiDx0iSt7ZE3y74cGXREzZ2I,1296
|
3
|
-
py2dag/export_dagre.py,sha256=S244wUxBMuM9qXD8bklaslkMp3rcbBGWvMhwWVBzBF0,3487
|
4
|
-
py2dag/export_svg.py,sha256=YyjqOuj8GhUTDWP70SKnnSWAKI1PvJwyOhHLwB29uNM,1812
|
5
|
-
py2dag/parser.py,sha256=1U16-GOQMa8oriJLePJ2TQlRZsrC9A4apy5V-V10M1A,9774
|
6
|
-
py2dag/pseudo.py,sha256=NJK61slyFLtSjhj8gJDJneUInEpBN57_41g8IfHNPWI,922
|
7
|
-
py2dag-0.1.8.dist-info/LICENSE,sha256=3Qee1EPwej_nusovTbyIQ8LvD2rXHdM0c6LNwk_D8Kc,1067
|
8
|
-
py2dag-0.1.8.dist-info/METADATA,sha256=PvQOVUwFviTr7G_m_sUsQeBGQtbedpZfxjbEiVsZvko,3549
|
9
|
-
py2dag-0.1.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
10
|
-
py2dag-0.1.8.dist-info/entry_points.txt,sha256=Q0SHexJJ0z1te4AYL1xTZogx5FrxCCE1ZJ5qntkFMZs,42
|
11
|
-
py2dag-0.1.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|