Skip to content

Commit 1e4ff54

Browse files
committed
refactor(demo): type the existing replay records
Signed-off-by: huangruiteng <huangrt01@163.com>
1 parent f88ac31 commit 1e4ff54

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎demo/workspace/__main__.py‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import subprocess
1212
import sys
1313
import tempfile
14+
from typing import Any
1415

1516
from loopx.bootstrap import bootstrap_project
1617
from loopx.configure_goal import configure_goal
@@ -23,13 +24,13 @@
2324
REGISTRY_NAME = "registry.json"
2425

2526

26-
def checked(result: dict) -> dict:
27+
def checked(result: dict[str, Any]) -> dict[str, Any]:
2728
if not result.get("ok"):
2829
raise RuntimeError(json.dumps(result, ensure_ascii=False))
2930
return result
3031

3132

32-
def write_story_artifacts(project: Path, story: dict, notice: str) -> None:
33+
def write_story_artifacts(project: Path, story: dict[str, Any], notice: str) -> None:
3334
(project / "BRIEF.md").write_text(f"# {story['title']}\n\n{story['brief']}\n")
3435
with (project / "working-table.csv").open("w", newline="") as table:
3536
writer = csv.writer(table)
@@ -68,9 +69,10 @@ def write_story_artifacts(project: Path, story: dict, notice: str) -> None:
6869
)
6970

7071

71-
def seed_delivery_tasks(story: dict, registry: Path, runtime: Path) -> list:
72+
def seed_delivery_tasks(story: dict[str, Any], registry: Path, runtime: Path) -> list[dict[str, Any]]:
7273
"""Record each story dependency as the typed relation its state allows."""
73-
todos, ids = [], {}
74+
todos: list[dict[str, Any]] = []
75+
ids: dict[str, str] = {}
7476
by_key = {task["key"]: task for task in story["tasks"]}
7577
dependents: dict[str, list[str]] = {}
7678
for task in story["tasks"]:
@@ -132,7 +134,7 @@ def seed_delivery_tasks(story: dict, registry: Path, runtime: Path) -> list:
132134
return todos
133135

134136

135-
def seed_story(root: Path, story: dict, notice: str) -> dict:
137+
def seed_story(root: Path, story: dict[str, Any], notice: str) -> dict[str, Any]:
136138
runtime = root / "runtime"
137139
registry = root / REGISTRY_NAME
138140
project = root / "projects" / story["id"]
@@ -263,14 +265,14 @@ def seed_story(root: Path, story: dict, notice: str) -> dict:
263265
}
264266

265267

266-
def prepare(root: Path) -> dict:
268+
def prepare(root: Path) -> dict[str, Any]:
267269
root = root.expanduser()
268270
if root.is_symlink():
269271
raise ValueError("Demo root must not be a symlink")
270272
root = root.resolve()
271273
marker = root / MARKER
272274
if marker.exists():
273-
manifest = json.loads(marker.read_text())
275+
manifest: dict[str, Any] = json.loads(marker.read_text())
274276
if manifest.get("schema_version") != "workspace_story_demo_v3":
275277
raise ValueError("Unrecognized demo manifest")
276278
if manifest.get("root") != str(root) or manifest.get("registry") != str(
@@ -302,7 +304,7 @@ def prepare(root: Path) -> dict:
302304

303305

304306
def advance(
305-
root: Path, manifest: dict, story_id: str, decision_key: str | None
307+
root: Path, manifest: dict[str, Any], story_id: str, decision_key: str | None
306308
) -> None:
307309
story = next(s for s in manifest["goals"] if s["id"] == story_id)
308310
registry = root / REGISTRY_NAME

0 commit comments

Comments
 (0)