From 44fde64ae5f57255da8b3e62f9aea4f11f869d03 Mon Sep 17 00:00:00 2001 From: "pardhubharadhwaz.vangipuram" Date: Sun, 2 Aug 2026 19:42:44 +0530 Subject: [PATCH] Use with_child_unrestricted in pydantic_converter_v1 sample The upstream SDK fix this workaround waited on (temporalio/sdk-python#254) has shipped, so replace the manual removal of the datetime restriction with with_child_unrestricted. Closes #126 --- pydantic_converter_v1/worker.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pydantic_converter_v1/worker.py b/pydantic_converter_v1/worker.py index 5ff65e1e2..3753aa0b5 100644 --- a/pydantic_converter_v1/worker.py +++ b/pydantic_converter_v1/worker.py @@ -49,18 +49,11 @@ async def run(self, models: List[MyPydanticModel]) -> List[MyPydanticModel]: # workflows, we're going to remove datetime module restrictions. See sdk-python # README's discussion of known sandbox issues for more details. def new_sandbox_runner() -> SandboxedWorkflowRunner: - # TODO(cretz): Use with_child_unrestricted when https://github.com/temporalio/sdk-python/issues/254 - # is fixed and released - invalid_module_member_children = dict( - SandboxRestrictions.invalid_module_members_default.children - ) - del invalid_module_member_children["datetime"] return SandboxedWorkflowRunner( restrictions=dataclasses.replace( SandboxRestrictions.default, - invalid_module_members=dataclasses.replace( - SandboxRestrictions.invalid_module_members_default, - children=invalid_module_member_children, + invalid_module_members=SandboxRestrictions.invalid_module_members_default.with_child_unrestricted( + "datetime" ), ) )