Skip to content

Commit 155fc58

Browse files
committed
Don't assume user overrides with same constructor signature
1 parent 0b3e68e commit 155fc58

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

temporalio/converter.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,16 @@ def from_payloads(
401401
) from err
402402
return values
403403

404-
def with_context(self, context: SerializationContext) -> Self:
404+
def with_context(self, context: SerializationContext) -> CompositePayloadConverter:
405405
"""Return a new instance with the given context."""
406-
converters = [
407-
c.with_context(context) if isinstance(c, WithSerializationContext) else c
408-
for c in self.converters.values()
409-
]
410-
instance = type(self).__new__(type(self))
411-
CompositePayloadConverter.__init__(instance, *converters)
412-
return instance
406+
return CompositePayloadConverter(
407+
*(
408+
c.with_context(context)
409+
if isinstance(c, WithSerializationContext)
410+
else c
411+
for c in self.converters.values()
412+
)
413+
)
413414

414415

415416
class DefaultPayloadConverter(CompositePayloadConverter):

0 commit comments

Comments
 (0)