Skip to content

Commit d94ec2c

Browse files
committed
fix: combine nested with statements to fix ruff SIM117
Combine nested `with` and `async with` statements in test_client.py to satisfy ruff SIM117 lint rule.
1 parent 6cb62af commit d94ec2c

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

tests/test_client.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ def test_chat_stream(self, respx_mock: respx.MockRouter) -> None:
200200
)
201201
)
202202

203-
with HawkClient() as client:
204-
with client.chat_stream("hello") as stream:
205-
text = stream.collect_text()
203+
with HawkClient() as client, client.chat_stream("hello") as stream:
204+
text = stream.collect_text()
206205

207206
assert text == "HelloWorld"
208207

@@ -236,13 +235,12 @@ def test_chat_stream_close(self, respx_mock: respx.MockRouter) -> None:
236235
)
237236
)
238237

239-
with HawkClient() as client:
240-
with client.chat_stream("hello") as stream:
241-
events = []
242-
for event in stream.events():
243-
events.append(event)
244-
if len(events) == 1:
245-
break
238+
with HawkClient() as client, client.chat_stream("hello") as stream:
239+
events = []
240+
for event in stream.events():
241+
events.append(event)
242+
if len(events) == 1:
243+
break
246244

247245
assert len(events) == 1
248246
assert events[0].data == "First"
@@ -338,9 +336,8 @@ async def test_chat_stream(self, respx_mock: respx.MockRouter) -> None:
338336
)
339337
)
340338

341-
async with AsyncHawkClient() as client:
342-
async with await client.chat_stream("hello") as stream:
343-
text = await stream.collect_text()
339+
async with AsyncHawkClient() as client, await client.chat_stream("hello") as stream:
340+
text = await stream.collect_text()
344341

345342
assert text == "HelloWorld"
346343

@@ -375,13 +372,12 @@ async def test_chat_stream_close(self, respx_mock: respx.MockRouter) -> None:
375372
)
376373
)
377374

378-
async with AsyncHawkClient() as client:
379-
async with await client.chat_stream("hello") as stream:
380-
events = []
381-
async for event in stream.events():
382-
events.append(event)
383-
if len(events) == 1:
384-
break
375+
async with AsyncHawkClient() as client, await client.chat_stream("hello") as stream:
376+
events = []
377+
async for event in stream.events():
378+
events.append(event)
379+
if len(events) == 1:
380+
break
385381

386382
assert len(events) == 1
387383
assert events[0].data == "First"

0 commit comments

Comments
 (0)