Skip to content

Commit 36c2fea

Browse files
authored
refactor: use TypedDict for exec program output (#1322)
Signed-off-by: Louis Mandel <[email protected]>
1 parent 8f21b4d commit 36c2fea

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/pdl/pdl.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from . import pdl_interpreter
1313
from ._version import version
1414
from .pdl_ast import (
15+
BlockType,
1516
PdlBlock,
1617
PdlLocationType,
1718
Program,
@@ -58,6 +59,13 @@ class InterpreterConfig(TypedDict, total=False):
5859
"""Event loop to schedule LLM calls."""
5960

6061

62+
class Result(TypedDict):
63+
result: Any
64+
scope: dict[str, Any]
65+
trace: BlockType
66+
replay: dict[str, Any]
67+
68+
6169
def exec_program(
6270
prog: Program,
6371
config: Optional[InterpreterConfig] = None,
@@ -92,13 +100,13 @@ def exec_program(
92100
case "result":
93101
return result
94102
case "all":
95-
scope = future_scope.result()
96-
return {
103+
result_all: Result = {
97104
"result": result,
98-
"scope": scope,
105+
"scope": future_scope.result(),
99106
"trace": trace,
100107
"replay": state.replay,
101108
}
109+
return result_all
102110
case _:
103111
assert False, 'The `output` variable should be "result" or "all"'
104112

0 commit comments

Comments
 (0)