Skip to content

Commit 8d56e68

Browse files
committed
fix: stringify as json when contributing to a string
Signed-off-by: Louis Mandel <[email protected]>
1 parent b0e9a14 commit 8d56e68

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,12 @@ def contribute(
25092509
loc: Optional[PdlLocationType] = None,
25102510
block: Optional[BlockType] = None,
25112511
) -> "FileAggregator":
2512-
print(f"{self.prefix}{result}", file=self.fp, end=self.suffix, flush=self.flush)
2512+
print(
2513+
f"{self.prefix}{stringify(result)}",
2514+
file=self.fp,
2515+
end=self.suffix,
2516+
flush=self.flush,
2517+
)
25132518
return self
25142519

25152520

src/pdl/pdl_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
get_sampling_defaults,
1616
)
1717
from .pdl_dumper import as_json, block_to_dict
18+
from .pdl_lazy import PdlLazy
1819

1920
RefT = TypeVar("RefT")
2021

@@ -64,6 +65,8 @@ async def to_async(value: ToAsyncT) -> ToAsyncT:
6465

6566

6667
def stringify(result):
68+
if isinstance(result, PdlLazy):
69+
result = result.result()
6770
if isinstance(result, str):
6871
s = result
6972
elif isinstance(result, FunctionBlock):

0 commit comments

Comments
 (0)