Skip to content

Commit 57439a6

Browse files
authored
Add annotation for consumer (#870)
1 parent 139c546 commit 57439a6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

aiokafka/consumer/consumer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
import traceback
66
import warnings
7+
from typing import Dict, List
78

89
from kafka.coordinator.assignors.roundrobin import RoundRobinPartitionAssignor
910

@@ -14,7 +15,7 @@
1415
ConsumerStoppedError, IllegalOperation, UnsupportedVersionError,
1516
IllegalStateError, NoOffsetForPartitionError, RecordTooLargeError
1617
)
17-
from aiokafka.structs import TopicPartition
18+
from aiokafka.structs import TopicPartition, ConsumerRecord
1819
from aiokafka.util import (
1920
commit_structure_validate, get_running_loop
2021
)
@@ -1104,7 +1105,7 @@ def unsubscribe(self):
11041105
log.info(
11051106
"Unsubscribed all topics or patterns and assigned partitions")
11061107

1107-
async def getone(self, *partitions):
1108+
async def getone(self, *partitions) -> ConsumerRecord:
11081109
"""
11091110
Get one message from Kafka.
11101111
If no new messages prefetched, this method will wait for it.
@@ -1148,7 +1149,9 @@ async def getone(self, *partitions):
11481149
msg = await self._fetcher.next_record(partitions)
11491150
return msg
11501151

1151-
async def getmany(self, *partitions, timeout_ms=0, max_records=None):
1152+
async def getmany(
1153+
self, *partitions, timeout_ms=0, max_records=None
1154+
) -> Dict[TopicPartition, List[ConsumerRecord]]:
11521155
"""Get messages from assigned topics / partitions.
11531156
11541157
Prefetched messages are returned in batches by topic-partition.
@@ -1247,7 +1250,7 @@ def __aiter__(self):
12471250
raise ConsumerStoppedError()
12481251
return self
12491252

1250-
async def __anext__(self):
1253+
async def __anext__(self) -> ConsumerRecord:
12511254
"""Asyncio iterator interface for consumer
12521255
12531256
Note:

0 commit comments

Comments
 (0)