Skip to content

Commit 7473305

Browse files
committed
fixup consumer.position()
1 parent 245c4fe commit 7473305

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kafka/consumer/group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,16 +732,16 @@ def position(self, partition):
732732
partition (TopicPartition): Partition to check
733733
734734
Returns:
735-
int: Offset
735+
int: Offset or None
736736
"""
737737
if not isinstance(partition, TopicPartition):
738738
raise TypeError('partition must be a TopicPartition namedtuple')
739739
assert self._subscription.is_assigned(partition), 'Partition is not assigned'
740740
position = self._subscription.assignment[partition].position
741-
if offset is None:
741+
if position is None:
742742
self._update_fetch_positions([partition])
743743
position = self._subscription.assignment[partition].position
744-
return position.offset
744+
return position.offset if position else None
745745

746746
def highwater(self, partition):
747747
"""Last known highwater offset for a partition.

0 commit comments

Comments
 (0)