Skip to content

Commit a4d41d1

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: add slots=True to all remaining dataclasses for consistency
Two dataclasses (_ToolConfig, _ScrollbarMetrics) already used slots=True but the other nine did not. This adds it to ProcessResult, AgentResult, RunResult, _StreamResult, Command, RunConfig, RunState, Event, and ManagedRun. Slots prevent accidental dynamic attribute assignment, reduce per-instance memory, and speed up attribute access. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent 1545ee4 commit a4d41d1

6 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/ralphify/_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def _deliver_prompt(proc: subprocess.Popen[Any], prompt: str) -> None:
222222
pass
223223

224224

225-
@dataclass
225+
@dataclass(slots=True)
226226
class AgentResult(ProcessResult):
227227
"""Result of running the agent subprocess."""
228228

@@ -233,7 +233,7 @@ class AgentResult(ProcessResult):
233233
captured_stderr: str | None = None
234234

235235

236-
@dataclass(frozen=True)
236+
@dataclass(frozen=True, slots=True)
237237
class _StreamResult:
238238
"""Accumulated output from reading the agent's JSON stream."""
239239

src/ralphify/_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class LogMessageData(TypedDict):
174174
"""Union of all typed event data payloads."""
175175

176176

177-
@dataclass
177+
@dataclass(slots=True)
178178
class Event:
179179
"""A structured event emitted by the run loop."""
180180

src/ralphify/_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
SESSION_KWARGS: dict[str, Any] = {} if IS_WINDOWS else {"start_new_session": True}
3030

3131

32-
@dataclass
32+
@dataclass(slots=True)
3333
class ProcessResult:
3434
"""Base result for any subprocess execution.
3535

src/ralphify/_run_types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def reason(self) -> StopReason:
6767
}
6868

6969

70-
@dataclass
70+
@dataclass(slots=True)
7171
class Command:
7272
"""A named command from RALPH.md frontmatter."""
7373

@@ -76,7 +76,7 @@ class Command:
7676
timeout: float = DEFAULT_COMMAND_TIMEOUT
7777

7878

79-
@dataclass
79+
@dataclass(slots=True)
8080
class RunConfig:
8181
"""All settings for a single run.
8282
@@ -99,7 +99,7 @@ class RunConfig:
9999
credit: bool = True
100100

101101

102-
@dataclass
102+
@dataclass(slots=True)
103103
class RunState:
104104
"""Observable state for a run.
105105

src/ralphify/_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from ralphify._output import SUBPROCESS_TEXT_KWARGS, ProcessResult, collect_output
1717

1818

19-
@dataclass
19+
@dataclass(slots=True)
2020
class RunResult(ProcessResult):
2121
"""Result of running a command or script."""
2222

src/ralphify/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ralphify.engine import run_loop
1515

1616

17-
@dataclass
17+
@dataclass(slots=True)
1818
class ManagedRun:
1919
"""A run bundled with its background thread and event queue.
2020

0 commit comments

Comments
 (0)