Skip to content

Commit 9d5566d

Browse files
committed
pyright fixes
1 parent be13607 commit 9d5566d

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/saluki/play.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ def play(
4545
TopicPartition(src_topic, src_partition, timestamps[1]),
4646
]
4747
)
48-
else:
48+
elif offsets is not None:
4949
start_offset = TopicPartition(src_topic, src_partition, offsets[0])
5050
stop_offset = TopicPartition(src_topic, src_partition, offsets[1])
51+
else:
52+
raise ValueError("offsets and timestamps cannot both be None")
53+
5154
consumer.assign([start_offset])
5255

5356
num_messages = stop_offset.offset - start_offset.offset + 1
54-
msgs = []
5557

5658
try:
5759
msgs = consumer.consume(num_messages)

tests/test_play.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from unittest.mock import Mock, patch
22

3+
import pytest
34
from confluent_kafka import Message, TopicPartition
45

56
from saluki.play import play
@@ -95,3 +96,8 @@ def test_play_with_exception_when_consuming_consumer_still_closed():
9596
mock_logger.exception.assert_called_once()
9697

9798
mock_consumer().close.assert_called_once()
99+
100+
101+
def test_play_raises_when_offsets_and_timestamps_are_none():
102+
with pytest.raises(ValueError):
103+
play("", "", "", "", None, None)

tests/test_sniff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_sniff_with_two_partitions_in_a_topic():
1313
):
1414
fake_cluster_md = ClusterMetadata()
1515
broker1 = BrokerMetadata()
16-
broker1.id = "id1"
17-
broker1.host = "mybroker"
16+
broker1.id = "id1" # type: ignore
17+
broker1.host = "mybroker" # type: ignore
1818
broker1.port = 9093
1919
fake_cluster_md.brokers = {0: broker1}
2020

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_deserialising_message_which_raises_does_not_stop_loop(mock_message):
7979
def test_deserialising_with_schema_list_ignores_messages_with_schema_not_in_list(mock_message):
8080
with patch("saluki.utils.logger") as logger:
8181
ok_message = Mock(spec=Message)
82-
ok_message.value.return_value = serialise_fc00(config_change=1, streams=[])
82+
ok_message.value.return_value = serialise_fc00(config_change=1, streams=[]) # type: ignore
8383
ok_message.error.return_value = False
8484
ok_message.timestamp.return_value = 2, 1
8585

0 commit comments

Comments
 (0)