chore(typecheck): clean datasets/eval/export/inference; enforce mypy on 12 packages#834
Draft
xieofxie wants to merge 3 commits into
Draft
chore(typecheck): clean datasets/eval/export/inference; enforce mypy on 12 packages#834xieofxie wants to merge 3 commits into
xieofxie wants to merge 3 commits into
Conversation
xieofxie
commented
Jun 8, 2026
| # Generate config(s). The ``module: str | None`` overload of | ||
| # generate_hf_build_config returns WinMLBuildConfig | list[...], | ||
| # which isinstance(result, list) narrows for the branches below. | ||
| result = generate_hf_build_config( |
Contributor
Author
There was a problem hiding this comment.
xieofxie
commented
Jun 8, 2026
| # overload, which returns WinMLBuildConfig | list[WinMLBuildConfig] — matching | ||
| # this dispatcher's implementation return type. The dispatcher's own | ||
| # narrowing overloads above still tighten the return type for its callers. | ||
| return generate_hf_build_config( |
…on 12 packages - Clear all mypy errors across the 4 folders (189 → 0). Notable source-level fixes that cleared cascades: - core/time_utils.format_timestamp_iso: added @overload variants so float→str and None→None propagate to all 4 export call sites. - export/htp/base_writer.step: replaced `-> Any` decorator factory with `Callable[[F], F]` and dropped the no-op @wraps wrapper — one source fix cleared 18 [untyped-decorator] errors across console_writer / markdown_report_writer / metadata_writer. - export/htp/exporter: typed the `None`-init core fields with proper Optional class annotations and a single non-None assert in `_apply_hierarchy_tags` cleared the union-attr chain. - export/htp/hierarchy.trace_model_execution: widened the example_inputs param to tuple|dict (callee already handled both via isinstance). - Added missing third-party stubs / ignores in pyproject.toml: - dev dep: scipy-stubs, types-psutil. - ignore_missing_imports: soundfile, sklearn.*, evaluate(.*). - Extended .github/workflows/lint.yml required mypy loop from 8 to 12 packages. New errors in any of the listed folders now block PRs. - Silenced two unguarded `winml.modelkit.inference.onnx_config.*` imports in export/htp/config_generator.py with `# type: ignore[import-not-found]` referencing #859, which tracks whether to restore or delete the dead integration.
xieofxie
commented
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extend the strict-mypy required-CI gate from 8 → 12 packages by cleaning
datasets/,eval/,export/, andinference/(189 errors → 0). Also restructures the dispatcher pattern inconfig/build.pyto fix a regression timenick flagged on #825 (kwarg type-checking lost behind**dict[str, Any]).What's in this PR
Dispatcher / overload cleanup (
config/build.py,commands/config.py)generate_hf_build_config: added a third@overloadacceptingmodule: str | Noneand returning the union of the two narrow returns. Lets thegenerate_build_configdispatcher collapse to a single call (no kwarg duplication, noAnywidening, nocast).commands.configcommand: ripped out the_shared_kwargs: dict[str, Any] = {...}workaround and replaced theif module:discriminator withisinstance(result, list)narrowing. Restores full call-site type checking against the callee's signature.Cleaning 4 new folders (189 → 0)
Notable source-level fixes that cascaded:
core/time_utils.format_timestamp_iso— added@overloads sofloat → strandNone → Nonepropagate; cleared 3 downstream[arg-type]chains.export/htp/base_writer.stepdecorator — replaced-> Anyfactory withCallable[[F], F], dropped no-op@wrapswrapper. One source fix cleared 18 cascading[untyped-decorator]errors across writers.export/htp/exporter— typed theNone-init core fields with properOptionalannotations + single non-Noneassertin_apply_hierarchy_tags; cleared the union-attr chain.datasets/*— common pattern: class-level_image_col: str = ""default instead of runtimeNone-init in_detect_columns; eliminatesAny | Noneproperty-return errors across image/segmentation/detection/depth datasets.eval/*—BaseImageProcessor | Noneguards across evaluators;pipeline()call-overload suppressions for runtime task strings that can't be statically matched against transformers' 60+ Literal overloads.Configuration
pyproject.tomlignore_missing_imports: addedsoundfile,sklearn.*,evaluate(.*).scipy-stubs,types-psutil..github/workflows/lint.yml: switched dependency install touv sync --all-extras --all-groupsso type stubs in[dependency-groups] devare present in CI. Extended the required mypy loop from 8 to 12 packages.Tracked follow-ups
winml.modelkit.inference.onnx_config.*imports inexport/htp/config_generator.pyreference a subpackage that doesn't exist in the repo. Silenced with# type: ignore[import-not-found]referencing the issue; Remove dead reference to inference.onnx_config.* subpackage in HTP config generator #859 tracks delete-vs-restore decision.🤖 Generated with Claude Code