File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff 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
421428class DefaultPayloadConverter (CompositePayloadConverter ):
You can’t perform that action at this time.
0 commit comments