Bug Report: Mypy Static Type Checking Errors in Export Modules
Description
When running mypy python/src on the coreai-models Python package, several static type checking errors occur due to variable scoping/shadowing and type annotations in model export modules:
-
Union type ambiguity in segmentation/export.py:
The config variable is assigned a FullExportConfig instance in the if args.full: branch and a SegmentationExportConfig instance in the else: branch. Consequently, static type checkers evaluate config as a union (FullExportConfig | SegmentationExportConfig), causing type errors when accessing fields unique to SegmentationExportConfig (such as max_text_seq_len, image_n_bits, image_group_size, text_n_bits, text_group_size).
-
ExportConfig variant literal assignment in llm/export.py:
The variant string parsed from command-line arguments is passed to ExportConfig(...), which expects Literal['macOS', 'iOS'], causing an arg-type mismatch.
-
Variable name shadowing in vlm/export.py:
The spec variable used in the --list-models iteration loop (for name, spec in SUPPORTED_MODELS.items():) shadows the lookup result of spec = SUPPORTED_MODELS.get(args.model) later in main().
Steps to Reproduce
- In the repository root, install dependencies with
uv sync.
- Run
uv run mypy python/src.
- Observe the reported type errors.
Expected Behavior
mypy python/src should evaluate exported CLI tools and pipeline modules with zero static type errors.
Suggested Fix
- Disambiguate
config -> seg_config in segmentation/export.py.
- Explicitly cast/narrow
variant to Literal["macOS", "iOS"] in llm/export.py.
- Rename loop variable in
vlm/export.py from spec to target_spec.
Bug Report: Mypy Static Type Checking Errors in Export Modules
Description
When running
mypy python/srcon thecoreai-modelsPython package, several static type checking errors occur due to variable scoping/shadowing and type annotations in model export modules:Union type ambiguity in
segmentation/export.py:The
configvariable is assigned aFullExportConfiginstance in theif args.full:branch and aSegmentationExportConfiginstance in theelse:branch. Consequently, static type checkers evaluateconfigas a union (FullExportConfig | SegmentationExportConfig), causing type errors when accessing fields unique toSegmentationExportConfig(such asmax_text_seq_len,image_n_bits,image_group_size,text_n_bits,text_group_size).ExportConfigvariantliteral assignment inllm/export.py:The
variantstring parsed from command-line arguments is passed toExportConfig(...), which expectsLiteral['macOS', 'iOS'], causing anarg-typemismatch.Variable name shadowing in
vlm/export.py:The
specvariable used in the--list-modelsiteration loop (for name, spec in SUPPORTED_MODELS.items():) shadows the lookup result ofspec = SUPPORTED_MODELS.get(args.model)later inmain().Steps to Reproduce
uv sync.uv run mypy python/src.Expected Behavior
mypy python/srcshould evaluate exported CLI tools and pipeline modules with zero static type errors.Suggested Fix
config->seg_configinsegmentation/export.py.varianttoLiteral["macOS", "iOS"]inllm/export.py.vlm/export.pyfromspectotarget_spec.