Skip to content

Commit 70ab208

Browse files
committed
enhance: optimization from comment on PR #1852
1 parent 6fba4c7 commit 70ab208

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

packages/testing/src/execution_testing/client_clis/file_utils.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from pydantic import BaseModel, RootModel
99

10-
from execution_testing.client_clis.cli_types import LazyAlloc
10+
from execution_testing.client_clis.cli_types import LazyAllocJson, LazyAllocStr
1111

1212

1313
def dump_files_to_directory(output_path: str, files: Dict[str, Any]) -> None:
@@ -24,15 +24,12 @@ def dump_files_to_directory(output_path: str, files: Dict[str, Any]) -> None:
2424
os.makedirs(os.path.join(output_path, rel_path), exist_ok=True)
2525
file_path = os.path.join(output_path, file_rel_path)
2626
with open(file_path, "w") as f:
27-
if isinstance(file_contents, LazyAlloc):
28-
# Validate and serialize the lazy alloc
29-
f.write(
30-
file_contents.get().model_dump_json(
31-
indent=4,
32-
exclude_none=True,
33-
by_alias=True,
34-
)
35-
)
27+
if isinstance(file_contents, (LazyAllocStr, LazyAllocJson)):
28+
if isinstance(file_contents, LazyAllocJson):
29+
dump(file_contents.raw, f, ensure_ascii=True, indent=4)
30+
else:
31+
f.write(file_contents.raw)
32+
3633
elif isinstance(file_contents, BaseModel) or isinstance(
3734
file_contents, RootModel
3835
):

0 commit comments

Comments
 (0)