From 3e2587025968ef9489af9286f5ef2e937fecbb92 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 6 Nov 2026 18:43:05 +0100 Subject: [PATCH] fix: type errors outside the mypy baseline Code moved to sitecollection.py and the triage progress added errors the baseline did not hold. A reused loop name, two lists without a type, returns without a value, and a regex match read without a test for None. Two baseline entries no longer occur and are removed. --- mypy-baseline.txt | 2 -- scripts/generate_readme.py | 2 ++ scripts/profile_sync.py | 11 ++++++----- scripts/sitecollection.py | 12 ++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mypy-baseline.txt b/mypy-baseline.txt index 6aed090c2..7a2310dd3 100644 --- a/mypy-baseline.txt +++ b/mypy-baseline.txt @@ -405,8 +405,6 @@ scripts/generate_site.py:0: error: Expected iterable as variadic argument [misc scripts/generate_site.py:0: error: Generator has incompatible item type "int"; expected "bool" [misc] scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "Optional[Any]", target has type "str") [assignment] scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str") [assignment] -scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str") [assignment] -scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "Union[dict[Any, Any], str, None]", variable has type "str") [assignment] scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "int") [assignment] scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "dict[str, set[str]]", variable has type "set[str]") [assignment] scripts/generate_site.py:0: error: Incompatible types in assignment (expression has type "dict[str, str]", variable has type "dict[str, tuple[str, dict[str, list[Any]]]]") [assignment] diff --git a/scripts/generate_readme.py b/scripts/generate_readme.py index 4489173df..2d33474d9 100644 --- a/scripts/generate_readme.py +++ b/scripts/generate_readme.py @@ -927,6 +927,8 @@ def ci_install_lines() -> tuple[str, str]: text = (_REPO / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8") main = re.search(r'^\s*run: (pip install pyyaml "jsonschema.*markdown.*)$', text, re.M) floor = re.search(r"^\s*run: (python3\.8 -m pip install .*)$", text, re.M) + if main is None or floor is None: + raise RuntimeError("validate.yml no longer installs the packages CONTRIBUTING quotes") return main.group(1), floor.group(1) diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index 16e47ffba..a4a34e3e7 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -5018,7 +5018,7 @@ def _print_triage( ) -> bool: """Profiles ranked by drift, worst first. False when Ctrl-C cut the scoring short: the ranking then covers the profiles scored.""" - ranked = [] + ranked: list[tuple] = [] sampled = 0 progress = _Progress(len(reports), "scored", args.offline or len(reports) < 2) complete = True @@ -5299,7 +5299,7 @@ def main() -> None: raise SystemExit(1) return - reports = [] + reports: list[ProfileReport] = [] quiet = args.offline or len(selected) < 2 if not quiet: print( @@ -5474,18 +5474,18 @@ def _emit( triage was cut short.""" if args.as_json: print(json.dumps([report_to_dict(r) for r in shown], indent=2)) - return + return None if args.markdown: target = Path(args.report_dir) / f"profile-sync-{date.today().isoformat()}.md" target.parent.mkdir(parents=True, exist_ok=True) target.write_text(format_markdown(shown), encoding="utf-8") print(f"written: {target}") - return + return None if args.fetch_plan: for report in shown: for url in fetch_plan(report): print(url) - return + return None if args.triage: return _print_triage(args, selected, shown) for report in shown: @@ -5494,6 +5494,7 @@ def _emit( print() if args.changed_only: _print_elided(reports, len(shown), frozenset(report.name for report in shown)) + return None def _print_elided( diff --git a/scripts/sitecollection.py b/scripts/sitecollection.py index 937bebe77..08ad817ba 100644 --- a/scripts/sitecollection.py +++ b/scripts/sitecollection.py @@ -128,11 +128,11 @@ def _engine_sections(manufacturers: dict[str, dict[str, list]]) -> dict[str, dic # A variant answers its primary's name: scummvm.zip.a93f1c4b. base = parts[-1].rsplit(".", 1)[0] if console.startswith(".") else parts[-1] keys = sorted(readers.get(base, ())) - key = keys[0] if len(keys) == 1 else own + reader = keys[0] if len(keys) == 1 else own found = next((c for c, held in regrouped.items() if any(h.get("name") == base for h in held)), None) - target = found or (next((c for c in consoles if c == key), None) - or (engine(key) if key else base)) + target = found or (next((c for c in consoles if c == reader), None) + or (engine(reader) if reader else base)) if target != console: record_card_move(mfr, console, str(f.get("sha1", "")), mfr, target) regrouped.setdefault(target, []).append(f) @@ -154,9 +154,9 @@ def _engine_sections(manufacturers: dict[str, dict[str, list]]) -> dict[str, dic *(f for f in others.pop(folder) if str(f.get("sha1", "")) not in held)] for mfr in GAME_DATA_TOPS: for console in out.get(mfr, {}): - key = profiles.get(console) and console - if key and engine(key) != console: - SECTION_LABELS[(mfr, console)] = engine(key) + named = console if console in profiles else None + if named and engine(named) != console: + SECTION_LABELS[(mfr, console)] = engine(named) return {mfr: consoles for mfr, consoles in out.items() if consoles}