3838 PayloadCodec ,
3939 PayloadConverter ,
4040 SerializationContext ,
41+ WithSerializationContext ,
4142 WorkflowSerializationContext ,
4243)
4344from temporalio .exceptions import ApplicationError
@@ -65,7 +66,9 @@ class TraceData:
6566 items : list [TraceItem ] = field (default_factory = list )
6667
6768
68- class SerializationContextPayloadConverter (EncodingPayloadConverter ):
69+ class SerializationContextPayloadConverter (
70+ EncodingPayloadConverter , WithSerializationContext
71+ ):
6972 def __init__ (self ):
7073 self .context : Optional [SerializationContext ] = None
7174
@@ -130,7 +133,9 @@ def from_payload(
130133 return value
131134
132135
133- class SerializationContextCompositePayloadConverter (CompositePayloadConverter ):
136+ class SerializationContextCompositePayloadConverter (
137+ CompositePayloadConverter , WithSerializationContext
138+ ):
134139 def __init__ (self ):
135140 super ().__init__ (
136141 SerializationContextPayloadConverter (),
@@ -995,7 +1000,7 @@ async def run(self) -> Never:
9951000test_traces : dict [str , list [TraceItem ]] = defaultdict (list )
9961001
9971002
998- class FailureConverterWithContext (DefaultFailureConverter ):
1003+ class FailureConverterWithContext (DefaultFailureConverter , WithSerializationContext ):
9991004 def __init__ (self ):
10001005 super ().__init__ (encode_common_attributes = False )
10011006 self .context : Optional [SerializationContext ] = None
@@ -1126,7 +1131,7 @@ async def test_failure_converter_with_context(client: Client):
11261131# Test payload codec
11271132
11281133
1129- class PayloadCodecWithContext (PayloadCodec ):
1134+ class PayloadCodecWithContext (PayloadCodec , WithSerializationContext ):
11301135 def __init__ (self ):
11311136 self .context : Optional [SerializationContext ] = None
11321137 self .encode_called_with_context = False
@@ -1427,7 +1432,7 @@ async def test_child_workflow_codec_with_context(client: Client):
14271432# Payload codec: test decode context matches encode context
14281433
14291434
1430- class PayloadEncryptionCodec (PayloadCodec ):
1435+ class PayloadEncryptionCodec (PayloadCodec , WithSerializationContext ):
14311436 """
14321437 The outbound data for encoding must always be the string "outbound". "Encrypt" it by replacing
14331438 it with a key that is derived from the context available during encoding. On decryption, assert
@@ -1592,7 +1597,7 @@ async def test_decode_context_matches_encode_context(
15921597# Test nexus payload codec
15931598
15941599
1595- class AssertNexusLacksContextPayloadCodec (PayloadCodec ):
1600+ class AssertNexusLacksContextPayloadCodec (PayloadCodec , WithSerializationContext ):
15961601 def __init__ (self ):
15971602 self .context = None
15981603
@@ -1674,7 +1679,9 @@ class PydanticData(BaseModel):
16741679 trace : List [str ] = []
16751680
16761681
1677- class PydanticJSONConverterWithContext (PydanticJSONPlainPayloadConverter ):
1682+ class PydanticJSONConverterWithContext (
1683+ PydanticJSONPlainPayloadConverter , WithSerializationContext
1684+ ):
16781685 def __init__ (self ):
16791686 super ().__init__ ()
16801687 self .context : Optional [SerializationContext ] = None
@@ -1693,7 +1700,7 @@ def to_payload(self, value: Any) -> Optional[temporalio.api.common.v1.Payload]:
16931700 return super ().to_payload (value )
16941701
16951702
1696- class PydanticConverterWithContext (CompositePayloadConverter ):
1703+ class PydanticConverterWithContext (CompositePayloadConverter , WithSerializationContext ):
16971704 def __init__ (self ):
16981705 super ().__init__ (
16991706 * (
@@ -1751,7 +1758,9 @@ class UserMethodCalledError(Exception):
17511758 pass
17521759
17531760
1754- class CustomEncodingPayloadConverter (JSONPlainPayloadConverter ):
1761+ class CustomEncodingPayloadConverter (
1762+ JSONPlainPayloadConverter , WithSerializationContext
1763+ ):
17551764 @property
17561765 def encoding (self ) -> str :
17571766 return "custom-encoding-that-does-not-clash-with-default-converters"
0 commit comments