From 7e7de19ef6c3bcbebc4d2227755767ceff2430e2 Mon Sep 17 00:00:00 2001 From: Vinta Chen Date: Sun, 19 Apr 2026 21:57:30 +0800 Subject: [PATCH] refactor(build): remove StarData TypedDict, loosen load_stars return to dict[str, dict] Cache-write shape mismatches the TypedDict and callers mix .get() and direct access, so the stricter type was providing false safety. Using dict[str, dict] accurately reflects the actual runtime contract. Co-Authored-By: Claude --- website/build.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/website/build.py b/website/build.py index f9deb480..6f864a11 100644 --- a/website/build.py +++ b/website/build.py @@ -6,19 +6,10 @@ import re import shutil from datetime import UTC, datetime from pathlib import Path -from typing import TypedDict from jinja2 import Environment, FileSystemLoader from readme_parser import ParsedGroup, ParsedSection, parse_readme, parse_sponsors - -class StarData(TypedDict): - stars: int - owner: str - last_commit_at: str - fetched_at: str - - GITHUB_REPO_URL_RE = re.compile(r"^https?://github\.com/([^/]+/[^/]+?)(?:\.git)?/?$") SOURCE_TYPE_DOMAINS = { @@ -46,7 +37,7 @@ def extract_github_repo(url: str) -> str | None: return m.group(1) if m else None -def load_stars(path: Path) -> dict[str, StarData]: +def load_stars(path: Path) -> dict[str, dict]: """Load star data from JSON. Returns empty dict if file doesn't exist or is corrupt.""" if path.exists(): try: