py2dag 0.2.3__tar.gz → 0.2.4__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.2.3 → py2dag-0.2.4}/PKG-INFO +1 -1
- {py2dag-0.2.3 → py2dag-0.2.4}/py2dag/parser.py +22 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/pyproject.toml +1 -1
- {py2dag-0.2.3 → py2dag-0.2.4}/LICENSE +0 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/README.md +0 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/py2dag/__init__.py +0 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/py2dag/cli.py +0 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/py2dag/export_dagre.py +0 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/py2dag/export_svg.py +0 -0
- {py2dag-0.2.3 → py2dag-0.2.4}/py2dag/pseudo.py +0 -0
@@ -288,6 +288,26 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
288
288
|
})
|
289
289
|
return ssa
|
290
290
|
|
291
|
+
def _emit_assign_from_subscript(var_name: str, node: ast.Subscript) -> str:
|
292
|
+
# Support name[key] where key is a JSON-serialisable literal
|
293
|
+
base = node.value
|
294
|
+
if not isinstance(base, ast.Name):
|
295
|
+
raise DSLParseError("Subscript base must be a variable name")
|
296
|
+
# Extract slice expression across Python versions
|
297
|
+
sl = getattr(node, 'slice', None)
|
298
|
+
# In Python >=3.9, slice is the actual node; before it may be ast.Index
|
299
|
+
if hasattr(ast, 'Index') and isinstance(sl, getattr(ast, 'Index')): # type: ignore[attr-defined]
|
300
|
+
sl = sl.value # type: ignore[assignment]
|
301
|
+
key = _literal(sl) # may raise if not literal
|
302
|
+
ssa = _ssa_new(var_name)
|
303
|
+
ops.append({
|
304
|
+
"id": ssa,
|
305
|
+
"op": "GET.item",
|
306
|
+
"deps": [_ssa_get(base.id)],
|
307
|
+
"args": {"key": key},
|
308
|
+
})
|
309
|
+
return ssa
|
310
|
+
|
291
311
|
def _emit_cond(node: ast.AST, kind: str = "if") -> str:
|
292
312
|
expr = _stringify(node)
|
293
313
|
deps = [_ssa_get(n) for n in _collect_value_deps(node)]
|
@@ -322,6 +342,8 @@ def parse(source: str, function_name: Optional[str] = None) -> Dict[str, Any]:
|
|
322
342
|
return _emit_assign_from_literal_or_pack(var_name, value)
|
323
343
|
elif isinstance(value, (ast.ListComp, ast.SetComp, ast.DictComp, ast.GeneratorExp)):
|
324
344
|
return _emit_assign_from_comp(var_name, value)
|
345
|
+
elif isinstance(value, ast.Subscript):
|
346
|
+
return _emit_assign_from_subscript(var_name, value)
|
325
347
|
else:
|
326
348
|
raise DSLParseError("Right hand side must be a call or f-string")
|
327
349
|
elif isinstance(stmt, ast.Expr):
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|