From 1d6fdae6dd37fc307869630effb7410a2ae1747a Mon Sep 17 00:00:00 2001 From: Scout Date: Tue, 13 Oct 2026 00:01:52 -0500 Subject: [PATCH] Ruff cleanup: the 12 lint errors, all in the three facts/sitemap scripts Every error was in scripts/build_site_facts.py, scripts/check_site_facts.py or scripts/build_sitemap.py: os.path.join/abspath/getsize/exists (PTH118/ 100/202/110) and one lambda assignment (E731). Converted to the pathlib idioms the rest of the repo already uses, with the repo's pinned ruff 0.15.22 (same as lint.yml): ruff check . -> All checks passed (was 12 errors) ruff format --check -> 167 files already formatted (unchanged) Behavior proven, not assumed: build_site_facts.py regenerates assets/site_facts.json byte-identically, build_sitemap.py regenerates sitemap.xml with no diff, check_site_facts.py passes. --- scripts/build_site_facts.py | 13 ++++++++----- scripts/build_sitemap.py | 8 ++++---- scripts/check_site_facts.py | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/build_site_facts.py b/scripts/build_site_facts.py index ae31d756..5120dfad 100644 --- a/scripts/build_site_facts.py +++ b/scripts/build_site_facts.py @@ -10,10 +10,13 @@ Stdlib only. Every fact names its source file so a reader can recompute. """ import json -import os +from pathlib import Path -ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") -A = lambda p: os.path.join(ROOT, "assets", p) +ROOT = Path(__file__).resolve().parent.parent + + +def A(p): + return str(ROOT / "assets" / p) def load(name): @@ -53,8 +56,8 @@ def compute_facts(): "recall_at_10": meta["test_recall_at_10"], "purity_at_20": round(meta["purity_at_20"], 4), "archetype_top1": round(meta["archetype_top1_acc"], 4), - "onnx_bytes": os.path.getsize(A("mtnn.onnx")), - "embeddings_bytes": os.path.getsize(A("mtnn_embeddings.f32")), + "onnx_bytes": Path(A("mtnn.onnx")).stat().st_size, + "embeddings_bytes": Path(A("mtnn_embeddings.f32")).stat().st_size, "eligibility": vectors["eligibility"]["method"], "drift_pairs": len(drift["pairs"]), "drift_biggest": { diff --git a/scripts/build_sitemap.py b/scripts/build_sitemap.py index 8374cc1c..73cffa10 100644 --- a/scripts/build_sitemap.py +++ b/scripts/build_sitemap.py @@ -3,17 +3,17 @@ were removed from the sitemap in the 2026-10-12 focus cuts.) Run: python3 scripts/build_sitemap.py. Stdlib only.""" import json -import os from datetime import date +from pathlib import Path -ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") +ROOT = Path(__file__).resolve().parent.parent BASE = "https://hoops.dumbmodel.com" PAGES = ["/", "/play", "/live", "/players", "/insights", "/taxonomy", "/methods", "/props-lab", "/playoff-runs"] def main(): - with open(os.path.join(ROOT, "assets", "insights.json"), encoding="utf-8") as f: + with open(ROOT / "assets" / "insights.json", encoding="utf-8") as f: slugs = [c["slug"] for c in json.load(f)["insights"]] # Insight stubs stay live for social unfurls but leave the sitemap # (Wave 5): the hub page is the indexable surface. @@ -24,7 +24,7 @@ def main(): for u in urls: lines.append(f" {BASE}{u}{today}") lines.append("") - with open(os.path.join(ROOT, "sitemap.xml"), "w", encoding="utf-8") as f: + with open(ROOT / "sitemap.xml", "w", encoding="utf-8") as f: f.write("\n".join(lines) + "\n") print(f"wrote sitemap.xml — {len(urls)} URLs ({len(PAGES)} pages)") diff --git a/scripts/check_site_facts.py b/scripts/check_site_facts.py index 3243dec5..fdcdb940 100644 --- a/scripts/check_site_facts.py +++ b/scripts/check_site_facts.py @@ -3,16 +3,16 @@ data files. Fails (exit 1) when data moved and the sheet was not rebuilt — the same contract as stamp_assets.py --check. Stdlib only.""" import json -import os import sys +from pathlib import Path -sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, str(Path(__file__).resolve().parent)) from build_site_facts import compute_facts, A def main(): path = A("site_facts.json") - if not os.path.exists(path): + if not Path(path).exists(): print("FAIL assets/site_facts.json missing — run scripts/build_site_facts.py") return 1 with open(path, encoding="utf-8") as f: