Pass mypy on loop_claude
This commit is contained in:
@@ -43,7 +43,7 @@ def written_by_human(entry) -> bool:
|
||||
texts = [part_text(part) for part in parts(entry)]
|
||||
# {"type": "user", "message": {"content": [{"tool_use_id": "toolu_01…", "type": "tool_result", "content": "hi"}]}}
|
||||
# {"type": "user", "message": {"content": [{"type": "text", "text": "[Request interrupted by user]"}]}}
|
||||
return bool(texts) and None not in texts and not any(text.startswith("[Request interrupted") for text in texts)
|
||||
return bool(texts) and all(text is not None and not text.startswith("[Request interrupted") for text in texts)
|
||||
|
||||
|
||||
def human_text(entry) -> str | None:
|
||||
@@ -100,11 +100,11 @@ def mark_trusted(config, roots) -> tuple[dict, list[str]] | Failure:
|
||||
# A model catalog file: {"fetchedAt": 1790618085238, "catalog": {"config": {"models": [{"id": "claude-opus-5-5", "name": "Opus 5.5", ...}]}}}
|
||||
def models_in(files) -> list[tuple[str, object]]:
|
||||
"""The (id, name) of each model in the newest of the parsed catalog files."""
|
||||
newest = {}
|
||||
newest: dict = {}
|
||||
for data in files:
|
||||
if isinstance(data, dict) and isinstance(data.get("fetchedAt"), (int, float)) and data["fetchedAt"] > newest.get("fetchedAt", -1):
|
||||
newest = data
|
||||
models = newest
|
||||
models: object = newest
|
||||
for key in ("catalog", "config", "models"):
|
||||
models = models.get(key) if isinstance(models, dict) else None
|
||||
return [(entry["id"], entry.get("name", entry["id"])) for entry in models if isinstance(entry, dict) and isinstance(entry.get("id"), str)] if isinstance(models, list) else []
|
||||
|
||||
@@ -21,7 +21,7 @@ def trust(config, roots) -> None:
|
||||
updated, untrusted = marked
|
||||
if not untrusted:
|
||||
return
|
||||
if failure := replace_json(config, updated, indent=2):
|
||||
print(f"could not write {config}: {failure.reason}", file=sys.stderr)
|
||||
if unwritten := replace_json(config, updated, indent=2):
|
||||
print(f"could not write {config}: {unwritten.reason}", file=sys.stderr)
|
||||
return
|
||||
print("trusted for the interrupt: " + ", ".join(untrusted), file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user