Skip to content

Commit 5b1ca9d

Browse files
committed
fix: Use string keys instead of bytes for Payload metadata
Payload.metadata expects string keys, not byte strings. This fixes pyright type errors in the ContextCodec test.
1 parent 487c6a1 commit 5b1ca9d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/test_serialization_context.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ async def encode(self, payloads: Sequence[Payload]) -> List[Payload]:
10841084
if self.context:
10851085
self.encode_called_with_context = True
10861086
# Just add a marker that we encoded with context
1087-
new_p.metadata[b"has_context"] = b"true"
1087+
new_p.metadata["has_context"] = b"true"
10881088
result.append(new_p)
10891089
return result
10901090

@@ -1093,10 +1093,10 @@ async def decode(self, payloads: Sequence[Payload]) -> List[Payload]:
10931093
for p in payloads:
10941094
new_p = Payload()
10951095
new_p.CopyFrom(p)
1096-
if self.context and new_p.metadata.get(b"has_context") == b"true":
1096+
if self.context and new_p.metadata.get("has_context") == b"true":
10971097
self.decode_called_with_context = True
10981098
# Remove the marker
1099-
del new_p.metadata[b"has_context"]
1099+
del new_p.metadata["has_context"]
11001100
result.append(new_p)
11011101
return result
11021102

@@ -1175,7 +1175,7 @@ def with_context(
11751175
converter = ContextPydanticConverter()
11761176
converter.context = context
11771177
# Also set context on all sub-converters
1178-
converters = []
1178+
converters: list[EncodingPayloadConverter] = []
11791179
for c in self.converters.values():
11801180
if isinstance(c, WithSerializationContext):
11811181
converters.append(c.with_context(context))

0 commit comments

Comments
 (0)