Name each entry shape written_by_human checks, and annotate every parameter in loop_claude

This commit is contained in:
2026-10-01 23:47:03 +02:00
parent 70ad9a9caa
commit 39acf6dff0
24 changed files with 113 additions and 84 deletions
+5 -3
View File
@@ -1,10 +1,12 @@
import json
import os
import pathlib
import typing
from loop_claude.outcome import Failure
def make_private(folder) -> None:
def make_private(folder: pathlib.Path) -> None:
mask = os.umask(0o077)
try:
os.makedirs(folder, exist_ok=True)
@@ -12,11 +14,11 @@ def make_private(folder) -> None:
os.umask(mask)
def replace_json(path, data, **dump) -> Failure | None:
def replace_json(path: pathlib.Path, data: object, **dump: typing.Any) -> Failure | None:
return replace_file(path, json.dumps(data, **dump).encode())
def replace_file(path, data) -> Failure | None:
def replace_file(path: pathlib.Path, data: bytes) -> Failure | None:
staged = f"{path}.{os.getpid()}"
try:
mode = os.stat(path).st_mode & 0o7777 if os.path.exists(path) else 0o600