Skip to content

Commit 0342b0e

Browse files
committed
chore(test): fix ruff/pyright and format snapshot refresh files
1 parent 1d74ca1 commit 0342b0e

5 files changed

Lines changed: 64 additions & 40 deletions

File tree

tests/core/test_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def test_default_config_dump():
5151
"max_steps_per_turn": 1000,
5252
"max_consecutive_failures": 8,
5353
"max_truncation_recoveries": 3,
54-
"max_session_cost_usd": None, "budget_nudge_ratio": 0.75, "max_retries_per_step": 3,
54+
"max_session_cost_usd": None,
55+
"budget_nudge_ratio": 0.75,
56+
"max_retries_per_step": 3,
5557
"max_ralph_iterations": 0,
5658
"reserved_context_size": 50000,
5759
"compaction_trigger_ratio": 0.85,

tests/core/test_overflow_recovery.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from __future__ import annotations
1111

12+
from contextvars import Token
1213
from unittest.mock import AsyncMock
1314

1415
import pytest
@@ -20,15 +21,14 @@
2021
from pythinker_code.wire import Wire
2122

2223

23-
def _wire_context() -> tuple[Wire, object]:
24+
def _wire_context() -> Token[Wire | None]:
2425
import pythinker_code.soul as soul_module
2526

2627
wire = Wire()
27-
token = soul_module._current_wire.set(wire)
28-
return wire, token
28+
return soul_module._current_wire.set(wire)
2929

3030

31-
def _reset_wire_context(token: object) -> None:
31+
def _reset_wire_context(token: Token[Wire | None]) -> None:
3232
import pythinker_code.soul as soul_module
3333

3434
soul_module._current_wire.reset(token)
@@ -54,7 +54,7 @@ async def test_prunes_compacts_and_reports_recovered(self, runtime, tmp_path) ->
5454
soul = _make_soul(runtime, tmp_path)
5555
soul.prune_context = AsyncMock(return_value=True) # type: ignore[method-assign]
5656
soul.compact_context = AsyncMock() # type: ignore[method-assign]
57-
_, wire_token = _wire_context()
57+
wire_token = _wire_context()
5858

5959
try:
6060
recovered = await soul._recover_from_context_overflow(step_no=3)
@@ -70,7 +70,7 @@ async def test_prune_failure_does_not_block_compaction(self, runtime, tmp_path)
7070
soul = _make_soul(runtime, tmp_path)
7171
soul.prune_context = AsyncMock(side_effect=RuntimeError("prune broke")) # type: ignore[method-assign]
7272
soul.compact_context = AsyncMock() # type: ignore[method-assign]
73-
_, wire_token = _wire_context()
73+
wire_token = _wire_context()
7474

7575
try:
7676
recovered = await soul._recover_from_context_overflow(step_no=3)
@@ -85,7 +85,7 @@ async def test_compaction_failure_reports_not_recovered(self, runtime, tmp_path)
8585
soul = _make_soul(runtime, tmp_path)
8686
soul.prune_context = AsyncMock(return_value=False) # type: ignore[method-assign]
8787
soul.compact_context = AsyncMock(side_effect=RuntimeError("compact broke")) # type: ignore[method-assign]
88-
_, wire_token = _wire_context()
88+
wire_token = _wire_context()
8989

9090
try:
9191
recovered = await soul._recover_from_context_overflow(step_no=3)

tests/core/test_pythinkersoul_ralph_loop.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
from pythinker_code.wire import Wire
2626
from pythinker_code.wire.types import TurnBegin
2727

28-
from pythinker_core import Message
29-
3028

3129
@pytest.fixture
3230
def approval() -> Approval:
@@ -260,15 +258,21 @@ async def test_ralph_loop_replays_original_prompt(runtime: Runtime, tmp_path: Pa
260258
""" # noqa: E501
261259
),
262260
],
263-
), Message(
264-
role="user",
265-
content=[TextPart(text="""\
261+
),
262+
Message(
263+
role="user",
264+
content=[
265+
TextPart(
266+
text="""\
266267
<system-reminder>
267268
Available agent types (this list is regenerated when subagent specs change):
268269
- `mocker`: The mock agent for testing purposes. (Tools: All tools)
269270
</system-reminder>\
270-
""")],
271-
), Message(
271+
"""
272+
)
273+
],
274+
),
275+
Message(
272276
role="assistant", content=[TextPart(text="second <choice>CONTINUE</choice>")]
273277
),
274278
Message(
@@ -286,15 +290,21 @@ async def test_ralph_loop_replays_original_prompt(runtime: Runtime, tmp_path: Pa
286290
""" # noqa: E501
287291
),
288292
],
289-
), Message(
290-
role="user",
291-
content=[TextPart(text="""\
293+
),
294+
Message(
295+
role="user",
296+
content=[
297+
TextPart(
298+
text="""\
292299
<system-reminder>
293300
Available agent types (this list is regenerated when subagent specs change):
294301
- `mocker`: The mock agent for testing purposes. (Tools: All tools)
295302
</system-reminder>\
296-
""")],
297-
), Message(role="assistant", content=[TextPart(text="third <choice>STOP</choice>")]),
303+
"""
304+
)
305+
],
306+
),
307+
Message(role="assistant", content=[TextPart(text="third <choice>STOP</choice>")]),
298308
]
299309
),
300310
)
@@ -346,15 +356,21 @@ async def test_ralph_loop_stops_on_choice(runtime: Runtime, tmp_path: Path) -> N
346356
""" # noqa: E501
347357
),
348358
],
349-
), Message(
350-
role="user",
351-
content=[TextPart(text="""\
359+
),
360+
Message(
361+
role="user",
362+
content=[
363+
TextPart(
364+
text="""\
352365
<system-reminder>
353366
Available agent types (this list is regenerated when subagent specs change):
354367
- `mocker`: The mock agent for testing purposes. (Tools: All tools)
355368
</system-reminder>\
356-
""")],
357-
), Message(role="assistant", content=[TextPart(text="done <choice>STOP</choice>")]),
369+
"""
370+
)
371+
],
372+
),
373+
Message(role="assistant", content=[TextPart(text="done <choice>STOP</choice>")]),
358374
]
359375
),
360376
)

tests_e2e/test_wire_approvals_tools.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,13 @@ def test_display_block_todo(tmp_path) -> None:
996996
"extras": None,
997997
},
998998
},
999-
}, {
1000-
"method": "event",
1001-
"type": "TodoListUpdated",
1002-
"payload": {"items": [["one", "pending"]], "complete": False, "source": "tool"},
1003-
}, {"method": "event", "type": "StepBegin", "payload": {"n": 2}},
999+
},
1000+
{
1001+
"method": "event",
1002+
"type": "TodoListUpdated",
1003+
"payload": {"items": [["one", "pending"]], "complete": False, "source": "tool"},
1004+
},
1005+
{"method": "event", "type": "StepBegin", "payload": {"n": 2}},
10041006
{
10051007
"method": "event",
10061008
"type": "ContentPart",
@@ -1126,11 +1128,13 @@ def test_tool_call_part_streaming(tmp_path) -> None:
11261128
"extras": None,
11271129
},
11281130
},
1129-
}, {
1130-
"method": "event",
1131-
"type": "TodoListUpdated",
1132-
"payload": {"items": [["a", "pending"]], "complete": False, "source": "tool"},
1133-
}, {"method": "event", "type": "StepBegin", "payload": {"n": 2}},
1131+
},
1132+
{
1133+
"method": "event",
1134+
"type": "TodoListUpdated",
1135+
"payload": {"items": [["a", "pending"]], "complete": False, "source": "tool"},
1136+
},
1137+
{"method": "event", "type": "StepBegin", "payload": {"n": 2}},
11341138
{
11351139
"method": "event",
11361140
"type": "ContentPart",

tests_e2e/test_wire_prompt.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,13 @@ def test_max_steps_reached(tmp_path) -> None:
321321
"extras": None,
322322
},
323323
},
324-
}, {
325-
"method": "event",
326-
"type": "TodoListUpdated",
327-
"payload": {"items": [["x", "pending"]], "complete": False, "source": "tool"},
328-
}, {
324+
},
325+
{
326+
"method": "event",
327+
"type": "TodoListUpdated",
328+
"payload": {"items": [["x", "pending"]], "complete": False, "source": "tool"},
329+
},
330+
{
329331
"method": "event",
330332
"type": "TurnEnd",
331333
"payload": {},

0 commit comments

Comments
 (0)