Skip to content

chore(types): make ModuleUpdate.py strict-clean and add it to the type-check gate#45

Merged
lallaria merged 1 commit into
mainfrom
chore/typecheck-moduleupdate
Jun 5, 2026
Merged

chore(types): make ModuleUpdate.py strict-clean and add it to the type-check gate#45
lallaria merged 1 commit into
mainfrom
chore/typecheck-moduleupdate

Conversation

@lallaria

@lallaria lallaria commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What

Brings ModuleUpdate.py from 143 strict pyright errors to 0 and adds it to the
type-check gate's include list. The gate stays green — validated against the real
.github/pyright-config.json (22 files, 0 errors, 0 warnings) via the same pyright
console script CI runs.

The 143 were heavily clustered, not independent:

Lever Errors cleared
_uv_run: inline the untyped kwargs dict as explicit keyword args + -> CompletedProcess[str] ~64 (restores result.returncode/stdout/stderr types repo-wide)
typings/mwgg_igdb.pyi stub (GameIndex singleton + __variant__) ~20
Generic RequirementsSet(set[_T]) + @override + typed file-set annotations, queue.Queue[...], list/parse_requirements annotations ~43
Documented platform/constant suppressions (fcntl, variant globals) 12
Genuine fixes (below) 4

Genuine fixes (real, not suppressed)

  • APWorldContainer(world) was passing a str where the constructor wants Path | None. Surfaced only after typing made world: str concrete (it was Unknown before, masking the mismatch). Use the already-computed world_path.
  • Coerce the untrusted manifest["world_version"] (object, from an apworld zip) to str before tuplize_version so a non-string version can't crash it.
  • Explicit new_version is not None narrowing at the Optional[Version] compare/access — safe at runtime but unprovable by pyright; de-fragilized.

Suppressions — genuine noise only, documented inline

  • fcntl flock/LOCK_*: Unix-only branch flagged under pythonPlatform=Windows (typeshed hides them). Correctly guarded at runtime.
  • reportConstantRedefinition on the public UPPERCASE variant globals (MWGG_IGDB_VARIANT/BRANCH/GIT_URL, _EXPLICIT_VARIANT) — intentionally reassigned in _resolve_variant()/set_variant(); renaming would break the public API and test_module_update.
  • _venv_has_worlds: flagged reportUnusedFunction (unused within the module) but consumed by tools/mwgg_upgrade.py and tools/mcp_mwgg_upgrader.py — so it was kept, not deleted.

Notes / deviations from the original plan

  • RequirementsSet is made generic set[_T], not set[str]: requirements_files holds Path while worlds_files holds str.
  • _venv_has_worlds is not dead (see above) — suppressed + documented instead of removed.

Validation

  • pyright -p .github/pyright-config.json → 22 files, 0 errors / 0 warnings (exit 0).
  • test/general/test_module_update.py23 passed.
  • Import smoke + RequirementsSet behavior verified.
  • No CRLF flips (git diff --ignore-cr-at-eol --stat matches; new files are pure LF).

…e-check gate

Brings ModuleUpdate.py from 143 strict pyright errors to 0 and adds it to the
gate's include list (.github/pyright-config.json). The bulk was cascade, not 143
independent problems:

- _uv_run: inline the untyped kwargs dict as explicit keyword args (creationflags
  computed once, 0 off-Windows) and annotate -> CompletedProcess[str]. This alone
  cleared ~64 errors by restoring result.returncode/stdout/stderr types everywhere.
- Add typings/mwgg_igdb.pyi modeling the GameIndex singleton + __variant__; clears
  the missing-stub cascade (get_all_games and downstream .get access).
- RequirementsSet is now generic (set[_T]) with @OverRide + typed add/update;
  requirements_files (Path) and worlds_files (str) annotated accordingly.

Genuine fixes (not suppressions):
- update_world_from_package passed a str to APWorldContainer(path: Path|None); use
  the already-computed world_path.
- Coerce the untrusted manifest['world_version'] (object) to str before tuplize_version.
- Add explicit new_version-is-not-None narrowing at the Optional[Version] compare/access.

Documented suppressions for genuine noise only: fcntl flock/LOCK_* (Unix-only branch
  flagged under pythonPlatform=Windows), the intentionally-reassigned public UPPERCASE
  variant globals (reportConstantRedefinition; renaming would break the public API and
  test_module_update), and _venv_has_worlds (unused in-module but consumed by
  tools/mwgg_upgrade.py + tools/mcp_mwgg_upgrader.py — NOT dead, so not deleted).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lallaria lallaria merged commit 30eb4ba into main Jun 5, 2026
19 of 20 checks passed
@lallaria lallaria deleted the chore/typecheck-moduleupdate branch June 5, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant