Name each entry shape written_by_human checks, and annotate every parameter in loop_claude
This commit is contained in:
@@ -4,7 +4,7 @@ from loop_claude.claude_code.formats import assistant_parts, human_text, parse,
|
||||
from loop_claude.outcome import Failure
|
||||
|
||||
|
||||
def read(path) -> list[dict] | Failure:
|
||||
def read(path: str) -> list[dict] | Failure:
|
||||
try:
|
||||
with open(path, "rb") as handle:
|
||||
return [entry for raw in handle if (entry := parse(raw))]
|
||||
@@ -12,11 +12,11 @@ def read(path) -> list[dict] | Failure:
|
||||
return Failure(f"could not read the transcript {path}: {failure.strerror}")
|
||||
|
||||
|
||||
def human_turns(entries) -> int:
|
||||
def human_turns(entries: list[dict]) -> int:
|
||||
return sum(1 for entry in entries if human_text(entry) is not None)
|
||||
|
||||
|
||||
def render(entries) -> str:
|
||||
def render(entries: list[dict]) -> str:
|
||||
lines = []
|
||||
for entry in entries:
|
||||
lines += [line for part in assistant_parts(entry) if (line := part_line(part))]
|
||||
@@ -25,7 +25,7 @@ def render(entries) -> str:
|
||||
return "\n\n".join(lines)
|
||||
|
||||
|
||||
def part_line(part, limit=400) -> str:
|
||||
def part_line(part: object, limit: int = 400) -> str:
|
||||
if (text := part_text(part)) and text.strip():
|
||||
return text
|
||||
if call := tool_call(part):
|
||||
|
||||
Reference in New Issue
Block a user