Name each entry shape written_by_human checks, and annotate every parameter in loop_claude
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user