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 -3
View File
@@ -7,6 +7,7 @@ import sys
import typing
RELOAD_FLAG = "--reloaded"
T = typing.TypeVar("T")
# A field change stops a running loop at its next reload: the new script rejects the old fields.
@@ -17,7 +18,7 @@ class LoopState:
task: str
def decode_state(handed, kind):
def decode_state(handed, kind: type[T]) -> T | None:
try:
fields = json.loads(handed)
except ValueError:
@@ -30,7 +31,7 @@ def decode_state(handed, kind):
return kind(**fields)
def fingerprint(launcher):
def fingerprint(launcher) -> str:
digest = hashlib.sha256()
for path in [launcher, *sorted((launcher.parent / "loop_claude").rglob("*.py"))]:
try:
@@ -41,7 +42,7 @@ def fingerprint(launcher):
return digest.hexdigest()
def exec_if_edited(launcher, baseline, state):
def exec_if_edited(launcher, baseline, state) -> None:
if fingerprint(launcher) == baseline:
return
trial = subprocess.run([sys.executable, launcher, "--help"], capture_output=True, text=True)