Annotate the return type of every function in loop_claude

This commit is contained in:
2026-09-29 12:23:37 +02:00
parent 0842135b87
commit d13658967a
20 changed files with 62 additions and 58 deletions
+4 -4
View File
@@ -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):
def read(path) -> 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):
return Failure(f"could not read the transcript {path}: {failure.strerror}")
def human_turns(entries):
def human_turns(entries) -> int:
return sum(1 for entry in entries if human_text(entry) is not None)
def render(entries):
def render(entries) -> 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):
return "\n\n".join(lines)
def part_line(part, limit=400):
def part_line(part, limit=400) -> str:
if (text := part_text(part)) and text.strip():
return text
if call := tool_call(part):