Skip to content

Commit 7fe5269

Browse files
committed
Fix test: return Self
1 parent ffd4f3a commit 7fe5269

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

temporalio/converter.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ def __init__(self, *converters: EncodingPayloadConverter) -> None:
342342
Args:
343343
converters: Payload converters to delegate to, in order.
344344
"""
345+
self._set_converters(*converters)
346+
347+
def _set_converters(self, *converters: EncodingPayloadConverter) -> None:
345348
self.converters = {c.encoding.encode(): c for c in converters}
346349

347350
def to_payloads(
@@ -406,16 +409,20 @@ def from_payloads(
406409
) from err
407410
return values
408411

409-
def with_context(self, context: SerializationContext) -> CompositePayloadConverter:
412+
def with_context(self, context: SerializationContext) -> Self:
410413
"""Return a new instance with context set on the component converters"""
411-
return CompositePayloadConverter(
414+
new_instance = type(self)()
415+
new_instance._set_converters(
412416
*(
413-
c.with_context(context)
414-
if isinstance(c, WithSerializationContext)
415-
else c
417+
(
418+
c.with_context(context)
419+
if isinstance(c, WithSerializationContext)
420+
else c
421+
)
416422
for c in self.converters.values()
417423
)
418424
)
425+
return new_instance
419426

420427

421428
class DefaultPayloadConverter(CompositePayloadConverter):

0 commit comments

Comments
 (0)