Skip to content

Commit 7fa75d0

Browse files
Copy RunOptions when mutating them (#135)
* Copy RunOptions when mutating them * Fix linting issue
1 parent 8a2e9e4 commit 7fa75d0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

python/restate/serde.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def from_dict(a,b): # pylint: disable=too-few-public-methods,unused-argument
6060
return to_dict, from_dict
6161

6262
PydanticBaseModel = try_import_pydantic_base_model()
63+
# pylint: disable=C0103
6364
DaciteToDict, DaciteFromDict = try_import_from_dacite()
6465

6566
T = typing.TypeVar('T')

python/restate/server_context.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import asyncio
2020
import contextvars
21+
import copy
2122
from random import Random
2223
from datetime import timedelta
2324
import inspect
@@ -612,10 +613,12 @@ def run_typed(
612613
**kwargs: P.kwargs,
613614
) -> RestateDurableFuture[T]:
614615
if isinstance(options.serde, DefaultSerde):
616+
# Copy options, as we're going to mutate type_hint and serde
617+
options = copy.copy(options)
615618
if options.type_hint is None:
616619
signature = inspect.signature(action, eval_str=True)
617620
options.type_hint = signature.return_annotation
618-
options.serde = options.serde.with_maybe_type(options.type_hint)
621+
options.serde = typing.cast(DefaultSerde, options.serde).with_maybe_type(options.type_hint)
619622
handle = self.vm.sys_run(name)
620623
update_restate_context_is_replaying(self.vm)
621624

0 commit comments

Comments
 (0)