Skip to content

type: clean mypy in optracing, quant, serve, session, sysinfo, telemetry, utils and enforce in CI#916

Open
xieofxie wants to merge 5 commits into
mainfrom
hualxie/type_5
Open

type: clean mypy in optracing, quant, serve, session, sysinfo, telemetry, utils and enforce in CI#916
xieofxie wants to merge 5 commits into
mainfrom
hualxie/type_5

Conversation

@xieofxie

Copy link
Copy Markdown
Contributor

@

Summary

Brings seven more winml.modelkit packages to zero mypy errors under the strict [tool.mypy] config and wires them into the required CI type-check gate (16 → 23 packages). Continues the incremental cleanup from #896.

Cleaned: optracing, quant, serve, session, sysinfo, telemetry, utils (sysinfo was already clean). Fixes follow the repos typing playbook — fix at the source first; cast() only at genuine untyped third-party boundaries; Any only for true dynamic pass-throughs.

Real bugs surfaced (not just typing)

  • utils/hub_utils.py version importfrom ..version import __version__ referenced a non-existent module; guarded by try/except, so the export version was silently always "unknown". Fixed to from .. import __version__. (The containing helper inject_hub_metadata is dead code — tracked in Clean up unused inject_hub_metadata in utils/hub_utils.py #913.)
  • utils/hub_utils.pymodel_info.modelIdmodel_info.id (huggingface_hub renamed the attribute).

Notable fixes

  • session — bound a non-None local after auto-compile so narrowing survives into the lambda/comprehension; explicit guards for resolved_ep is None and single-mode model_path; widened PDH counter containers to float; class-level _initialized annotation; distinct ctypes struct locals.
  • telemetry — annotated the LoggerProvider/Logger instance attributes (were inferred as None, cascading into unreachable/attr-defined); OTel/JSON boundary casts; typed the @contextmanager/@asynccontextmanager generators.
  • servecast() at json.loads/app.state boundaries; import binascii to use binascii.Error (typeshed doesnt expose base64.binascii); explicit single-mode model_path guard.
  • utils — removed stale # type: ignores; DataclassInstance cast for generic-TypeVar dataclass reflection; EPAlias key cast for the alias lookup; loop-variable rename to fix InputTensorSpec/OutputTensorSpec shadowing.

Config changes (pyproject.toml)

  • qairt.*ignore_missing_imports (external Qualcomm AI Runtime SDK; imported only inside compile_qairt_bin.py, which runs in a separate venv-winml subprocess — absent from the CI env).
  • windowsmlfollow_untyped_imports = true (installed but ships no py.typed; analyzing its source is clean and keeps its inline annotations instead of collapsing to Any).

Verification

  • Combined required-gate invocation (all 23 packages): Success: no issues found in 300 source files.
  • ruff clean; unit tests green for the touched packages (2 pre-existing OpenVINO-EP-unavailable failures in this env, confirmed unrelated).
  • Branch-vs-main diff is content-only (line endings normalized to LF to match main).
    @

@xieofxie xieofxie requested a review from a team as a code owner June 18, 2026 06:22
Comment thread src/winml/modelkit/utils/config_utils.py Dismissed
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.

2 participants