Skip to content

Commit 7b32925

Browse files
committed
style: fix ruff formatting in openai.py and test_content_index.py
1 parent 480a3ef commit 7b32925

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

cubepi/providers/openai.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ async def _produce() -> None:
172172
)
173173
)
174174
tc_content_index = len(partial.content) - 1
175-
tool_calls_in_progress[idx]["content_index"] = str(tc_content_index)
175+
tool_calls_in_progress[idx]["content_index"] = str(
176+
tc_content_index
177+
)
176178
ms.push(
177179
StreamEvent(
178180
type="toolcall_start",
@@ -188,7 +190,9 @@ async def _produce() -> None:
188190
StreamEvent(
189191
type="toolcall_delta",
190192
delta=tc_delta.function.arguments,
191-
content_index=int(tool_calls_in_progress[idx]["content_index"]),
193+
content_index=int(
194+
tool_calls_in_progress[idx]["content_index"]
195+
),
192196
partial=partial.model_copy(deep=True),
193197
)
194198
)

tests/providers/test_content_index.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ class TestContentIndexThinkingAndText:
4242
async def test_thinking_then_text_content_index(self):
4343
provider = FauxProvider()
4444
provider.set_responses(
45-
[faux_assistant_message([faux_thinking("let me think"), faux_text("answer")])]
45+
[
46+
faux_assistant_message(
47+
[faux_thinking("let me think"), faux_text("answer")]
48+
)
49+
]
4650
)
4751

4852
stream = await provider.stream(_make_model(), [])
@@ -55,18 +59,14 @@ async def test_thinking_then_text_content_index(self):
5559
]
5660
assert len(thinking_events) >= 3
5761
for e in thinking_events:
58-
assert (
59-
e.content_index == 0
60-
), f"{e.type} had content_index={e.content_index}"
62+
assert e.content_index == 0, f"{e.type} had content_index={e.content_index}"
6163

6264
text_events = [
6365
e for e in events if e.type in ("text_start", "text_delta", "text_end")
6466
]
6567
assert len(text_events) >= 3
6668
for e in text_events:
67-
assert (
68-
e.content_index == 1
69-
), f"{e.type} had content_index={e.content_index}"
69+
assert e.content_index == 1, f"{e.type} had content_index={e.content_index}"
7070

7171

7272
class TestContentIndexTextAndToolCall:
@@ -77,7 +77,10 @@ async def test_text_then_tool_content_index(self):
7777
provider.set_responses(
7878
[
7979
faux_assistant_message(
80-
[faux_text("searching"), faux_tool_call("search", {"q": "test"}, id="tc-1")],
80+
[
81+
faux_text("searching"),
82+
faux_tool_call("search", {"q": "test"}, id="tc-1"),
83+
],
8184
stop_reason="tool_use",
8285
)
8386
]
@@ -91,9 +94,7 @@ async def test_text_then_tool_content_index(self):
9194
]
9295
assert len(text_events) >= 3
9396
for e in text_events:
94-
assert (
95-
e.content_index == 0
96-
), f"{e.type} had content_index={e.content_index}"
97+
assert e.content_index == 0, f"{e.type} had content_index={e.content_index}"
9798

9899
tool_events = [
99100
e
@@ -102,6 +103,4 @@ async def test_text_then_tool_content_index(self):
102103
]
103104
assert len(tool_events) >= 3
104105
for e in tool_events:
105-
assert (
106-
e.content_index == 1
107-
), f"{e.type} had content_index={e.content_index}"
106+
assert e.content_index == 1, f"{e.type} had content_index={e.content_index}"

0 commit comments

Comments
 (0)