Skip to content

Commit

Permalink
fix(test_client): use proper type hint in Producer.send (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
woile authored Oct 17, 2024
1 parent f6abee0 commit bfdb69a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions kstreams/test_utils/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from kstreams import RebalanceListener, TopicPartition
from kstreams.clients import Consumer, Producer
from kstreams.serializers import Serializer
from kstreams.types import ConsumerRecord, EncodedHeaders, Headers
from kstreams.types import ConsumerRecord, EncodedHeaders

from .structs import RecordMetadata
from .topics import TopicManager
Expand All @@ -24,7 +24,7 @@ async def send(
key: Any = None,
partition: int = 0,
timestamp_ms: Optional[int] = None,
headers: Optional[Headers] = None,
headers: Optional[EncodedHeaders] = None,
serializer: Optional[Serializer] = None,
serializer_kwargs: Optional[Dict] = None,
) -> Coroutine:
Expand All @@ -33,17 +33,13 @@ async def send(
total_partition_events = topic.offset(partition=partition)
partition = partition or 0

_headers: EncodedHeaders = []
if isinstance(headers, dict):
_headers = [(key, value.encode()) for key, value in headers.items()]

serialized_key_size = -1 if key is None else len(key)
serialized_value_size = -1 if value is None else len(value)
consumer_record: ConsumerRecord = ConsumerRecord(
topic=topic_name,
value=value,
key=key,
headers=_headers,
headers=headers or [],
partition=partition,
timestamp=timestamp_ms,
offset=total_partition_events + 1,
Expand Down

0 comments on commit bfdb69a

Please sign in to comment.