Skip to content

Commit 8fadecb

Browse files
committed
fix: correct test assertions and add missing pyright ignore
1 parent fee09ac commit 8fadecb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/replicate/_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def stream(
350350
"""
351351
from .lib._stream import stream as _stream
352352

353-
return _stream(type(self), ref, input=input) # type: ignore[return-value, arg-type] # pyright: ignore[reportDeprecated]
353+
return _stream(type(self), ref, input=input) # type: ignore[return-value, arg-type] # pyright: ignore[reportDeprecated, reportGeneralTypeIssues]
354354

355355
def copy(
356356
self,
@@ -757,7 +757,7 @@ async def stream(
757757
"""
758758
from .lib._stream import stream as _stream
759759

760-
return _stream(type(self), ref, input=input) # type: ignore[return-value, arg-type] # pyright: ignore[reportDeprecated]
760+
return _stream(type(self), ref, input=input) # type: ignore[return-value, arg-type] # pyright: ignore[reportDeprecated, reportGeneralTypeIssues]
761761

762762
def copy(
763763
self,

tests/lib/test_stream.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_stream_calls_use_with_streaming_true():
6767
mock_use.assert_called_once()
6868
call_args = mock_use.call_args
6969
assert call_args.kwargs["streaming"] is True
70-
assert call_args.args[0] == "anthropic/claude-4.5-sonnet"
70+
assert call_args.args[1] == "anthropic/claude-4.5-sonnet"
7171

7272
# Verify the mock function was called with the input
7373
mock_function.assert_called_once_with(prompt="Hello")
@@ -101,12 +101,14 @@ def test_stream_returns_iterator():
101101

102102
def test_stream_works_same_as_use_with_streaming():
103103
"""Test that stream() produces the same output as use() with streaming=True."""
104-
with patch("replicate.lib._stream.use") as mock_use:
104+
with patch("replicate.lib._stream.use") as mock_stream_use, \
105+
patch("replicate.lib._predictions_use.use") as mock_predictions_use:
105106
# Create a mock function that returns an iterator
106107
mock_function = Mock()
107108
expected_output = ["Test", " ", "output"]
108109
mock_function.return_value = iter(expected_output.copy())
109-
mock_use.return_value = mock_function
110+
mock_stream_use.return_value = mock_function
111+
mock_predictions_use.return_value = mock_function
110112

111113
client = Replicate(bearer_token="test-token")
112114

0 commit comments

Comments
 (0)