Skip to content

Commit 8c25c73

Browse files
authored
fix(ci): Various errors on master (#4009)
- `black==25.1.0` changed some default styles - `pytest-aiohttp==1.1.0` removed the `loop` fixture - `huggingface-hub==0.28.0` deprecated `InferenceClient.post` to `InferenceClient._inner_post` - `pymongo==4.11.0` required `maxWireVersion` to be `7`
1 parent 5a27502 commit 8c25c73

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

Diff for: sentry_sdk/_queue.py

+2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@
8686

8787
class EmptyError(Exception):
8888
"Exception raised by Queue.get(block=0)/get_nowait()."
89+
8990
pass
9091

9192

9293
class FullError(Exception):
9394
"Exception raised by Queue.put(block=0)/put_nowait()."
95+
9496
pass
9597

9698

Diff for: tests/integrations/aiohttp/test_aiohttp.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import json
3+
import sys
34
from contextlib import suppress
45
from unittest import mock
56

@@ -473,9 +474,17 @@ async def hello(request):
473474
assert error_event["contexts"]["trace"]["trace_id"] == trace_id
474475

475476

477+
if sys.version_info < (3, 12):
478+
# `loop` was deprecated in `pytest-aiohttp`
479+
# in favor of `event_loop` from `pytest-asyncio`
480+
@pytest.fixture
481+
def event_loop(loop):
482+
yield loop
483+
484+
476485
@pytest.mark.asyncio
477486
async def test_crumb_capture(
478-
sentry_init, aiohttp_raw_server, aiohttp_client, loop, capture_events
487+
sentry_init, aiohttp_raw_server, aiohttp_client, event_loop, capture_events
479488
):
480489
def before_breadcrumb(crumb, hint):
481490
crumb["data"]["extra"] = "foo"

Diff for: tests/integrations/huggingface_hub/test_huggingface_hub.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
from unittest import mock # python 3.3 and above
1313

1414

15+
def mock_client_post(client, post_mock):
16+
# huggingface-hub==0.28.0 deprecates the `post` method
17+
# so patch `_inner_post` instead
18+
client.post = post_mock
19+
client._inner_post = post_mock
20+
21+
1522
@pytest.mark.parametrize(
1623
"send_default_pii, include_prompts, details_arg",
1724
itertools.product([True, False], repeat=3),
@@ -28,7 +35,7 @@ def test_nonstreaming_chat_completion(
2835

2936
client = InferenceClient("some-model")
3037
if details_arg:
31-
client.post = mock.Mock(
38+
post_mock = mock.Mock(
3239
return_value=b"""[{
3340
"generated_text": "the model response",
3441
"details": {
@@ -40,9 +47,11 @@ def test_nonstreaming_chat_completion(
4047
}]"""
4148
)
4249
else:
43-
client.post = mock.Mock(
50+
post_mock = mock.Mock(
4451
return_value=b'[{"generated_text": "the model response"}]'
4552
)
53+
mock_client_post(client, post_mock)
54+
4655
with start_transaction(name="huggingface_hub tx"):
4756
response = client.text_generation(
4857
prompt="hello",
@@ -84,7 +93,8 @@ def test_streaming_chat_completion(
8493
events = capture_events()
8594

8695
client = InferenceClient("some-model")
87-
client.post = mock.Mock(
96+
97+
post_mock = mock.Mock(
8898
return_value=[
8999
b"""data:{
90100
"token":{"id":1, "special": false, "text": "the model "}
@@ -95,6 +105,8 @@ def test_streaming_chat_completion(
95105
}""",
96106
]
97107
)
108+
mock_client_post(client, post_mock)
109+
98110
with start_transaction(name="huggingface_hub tx"):
99111
response = list(
100112
client.text_generation(
@@ -131,7 +143,9 @@ def test_bad_chat_completion(sentry_init, capture_events):
131143
events = capture_events()
132144

133145
client = InferenceClient("some-model")
134-
client.post = mock.Mock(side_effect=OverloadedError("The server is overloaded"))
146+
post_mock = mock.Mock(side_effect=OverloadedError("The server is overloaded"))
147+
mock_client_post(client, post_mock)
148+
135149
with pytest.raises(OverloadedError):
136150
client.text_generation(prompt="hello")
137151

@@ -147,13 +161,15 @@ def test_span_origin(sentry_init, capture_events):
147161
events = capture_events()
148162

149163
client = InferenceClient("some-model")
150-
client.post = mock.Mock(
164+
post_mock = mock.Mock(
151165
return_value=[
152166
b"""data:{
153167
"token":{"id":1, "special": false, "text": "the model "}
154168
}""",
155169
]
156170
)
171+
mock_client_post(client, post_mock)
172+
157173
with start_transaction(name="huggingface_hub tx"):
158174
list(
159175
client.text_generation(

Diff for: tests/integrations/pymongo/test_pymongo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@pytest.fixture(scope="session")
1111
def mongo_server():
1212
server = MockupDB(verbose=True)
13-
server.autoresponds("ismaster", maxWireVersion=6)
13+
server.autoresponds("ismaster", maxWireVersion=7)
1414
server.run()
1515
server.autoresponds(
1616
{"find": "test_collection"}, cursor={"id": 123, "firstBatch": []}

0 commit comments

Comments
 (0)