Skip to content

Commit 6e3e65f

Browse files
Kasper Jungeclaude
authored andcommitted
fix: remove unused imports and fix type errors so ruff-lint and ty-type-check pass
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7a94f45 commit 6e3e65f

6 files changed

Lines changed: 14 additions & 20 deletions

File tree

src/ralphify/engine.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
from datetime import datetime
1616
from enum import Enum
1717
from pathlib import Path
18-
from typing import Optional
19-
2018
from ralphify._events import Event, EventEmitter, EventType, NullEmitter
2119
from ralphify._output import collect_output
2220
from ralphify.checks import (
23-
CheckResult,
2421
discover_checks,
2522
format_check_failures,
2623
run_all_checks,

src/ralphify/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from dataclasses import dataclass, field
1111

1212
from ralphify._events import Event, EventEmitter, QueueEmitter
13-
from ralphify.engine import RunConfig, RunState, RunStatus, run_loop
13+
from ralphify.engine import RunConfig, RunState, run_loop
1414

1515

1616
@dataclass

src/ralphify/ui/api/ws.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from __future__ import annotations
33

44
import asyncio
5-
import json
6-
from datetime import datetime
75

86
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
97

tests/test_engine.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import subprocess
44
import threading
55
import time
6-
from pathlib import Path
6+
from dataclasses import replace
77
from unittest.mock import patch
88

9-
from ralphify._events import Event, EventType, NullEmitter, QueueEmitter
9+
from ralphify._events import EventType, NullEmitter, QueueEmitter
1010
from ralphify.engine import RunConfig, RunState, RunStatus, _format_duration, run_loop
1111

1212
_MOCK_SUBPROCESS = "ralphify.engine.subprocess.run"
@@ -17,15 +17,14 @@ def _make_config(tmp_path, **overrides):
1717
prompt_path = tmp_path / "PROMPT.md"
1818
if not prompt_path.exists():
1919
prompt_path.write_text("test prompt")
20-
defaults = dict(
20+
config = RunConfig(
2121
command="echo",
2222
args=[],
2323
prompt_file=str(prompt_path),
2424
max_iterations=1,
2525
project_root=tmp_path,
2626
)
27-
defaults.update(overrides)
28-
return RunConfig(**defaults)
27+
return replace(config, **overrides) if overrides else config
2928

3029

3130
def _make_state():

tests/test_manager.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import subprocess
44
import threading
55
import time
6-
from pathlib import Path
6+
from dataclasses import replace
77
from unittest.mock import patch
88

9-
from ralphify._events import Event, EventType, NullEmitter, QueueEmitter
10-
from ralphify.engine import RunConfig, RunState, RunStatus
9+
from ralphify._events import Event, EventType, QueueEmitter
10+
from ralphify.engine import RunConfig, RunStatus
1111
from ralphify.manager import ManagedRun, RunManager, _FanoutEmitter
1212

1313
_MOCK_SUBPROCESS = "ralphify.engine.subprocess.run"
@@ -18,15 +18,14 @@ def _make_config(tmp_path, **overrides):
1818
prompt_path = tmp_path / "PROMPT.md"
1919
if not prompt_path.exists():
2020
prompt_path.write_text("test prompt")
21-
defaults = dict(
21+
config = RunConfig(
2222
command="echo",
2323
args=[],
2424
prompt_file=str(prompt_path),
2525
max_iterations=1,
2626
project_root=tmp_path,
2727
)
28-
defaults.update(overrides)
29-
return RunConfig(**defaults)
28+
return replace(config, **overrides) if overrides else config
3029

3130

3231
def _ok(*args, **kwargs):
@@ -104,6 +103,7 @@ def test_start_run_emits_events_to_queue(self, mock_run, tmp_path):
104103
run_id = managed.state.run_id
105104

106105
manager.start_run(run_id)
106+
assert managed.thread is not None
107107
managed.thread.join(timeout=5)
108108

109109
events = []
@@ -128,6 +128,7 @@ def test_stop_run_stops_running_run(self, mock_run, tmp_path):
128128
time.sleep(0.05)
129129

130130
manager.stop_run(run_id)
131+
assert managed.thread is not None
131132
managed.thread.join(timeout=5)
132133

133134
assert managed.state.status == RunStatus.STOPPED
@@ -169,6 +170,7 @@ def counting_ok(*args, **kwargs):
169170
time.sleep(0.05)
170171
manager.resume_run(run_id)
171172

173+
assert managed.thread is not None
172174
managed.thread.join(timeout=5)
173175
assert managed.state.completed == 3
174176

@@ -232,6 +234,7 @@ def test_extra_listeners_receive_events(self, mock_run, tmp_path):
232234
managed.add_listener(extra)
233235

234236
manager.start_run(run_id)
237+
assert managed.thread is not None
235238
managed.thread.join(timeout=5)
236239

237240
# Both the primary emitter and the extra listener should have events

tests/test_persistence.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import asyncio
44
import json
5-
from pathlib import Path
65

76
import pytest
87

@@ -56,8 +55,6 @@ def test_init_creates_parent_directories(self, tmp_path):
5655
assert db_path.exists()
5756

5857
def test_init_creates_tables(self, store, db_path):
59-
import aiosqlite
60-
6158
async def check_tables():
6259
await store.init()
6360
cursor = await store._db.execute(

0 commit comments

Comments
 (0)