CI typecheck job fails: 273 mypy errors in easystitch src/ #72

Closed
opened 2026-06-22 18:39:52 +00:00 by Mark · 2 comments
Owner

Problem

The Lint & Type Check workflow in .forgejo/workflows/ci.yml runs mypy src/ --ignore-missing-imports --no-error-summary as the Type Check job. As of commit f456bc7 (CI path correction + ruff format), this job produces 273 mypy errors across 34 files and exits non-zero.

This blocks PR merges via the required CI check. The Lint sub-step (ruff check .) and Tests (pytest tests/ -q) both pass. The pipeline itself (kilo-gsd) is not blocked — its Lint gate is ruff only — but a clean CI baseline is required for the pipeline to be useful for anything that produces a PR.

Error Breakdown (mypy src/, default flags + --ignore-missing-imports)

[error-code]              count    notes
assignment                  78    int vs float, mostly literal-float assigned to int param
index                       42    typed collection (tuple/list/dict) item assignment
list-item                   32    "Right hand side values are not supported in unions"
attr-defined                29    mostly env-version drift (PIL.Image.MEDIANCUT removed, skimage.filters.MeanFilter removed, etc.)
var-annotated               19    missing type hints on local vars
no-redef                    14    duplicate `from X import Y` / re-bind
return-value                13    function annotated return type doesn't match what is returned
union-attr                  11    attribute access on Optional[Type]
arg-type                    11    wrong argument type
operator                    10    unsupported operand types
dict-item                    6    dict key/value type mismatches
valid-type                   4    bare `any` instead of `typing.Any`
empty-body                   3    function with `...` body but annotated return type
misc                        1

Files with the most errors (top 10):

src/utils/validation.py                  39
src/utils/formats/format_validator.py    22
src/post_processing/post_processor.py    19
src/post_processing/pull_comp.py         17
src/visualization/visualizer.py          17
src/intent_resolver/dom_resolver.py      15
src/svg_parser/parser.py                 12
src/utils/stitch_utils.py                11
src/utils/data_structures.py             10
src/svg_annotation/annotator.py          10

Cause

The codebase is ~30K LOC of Python with type hints on many function signatures but no enforcement until now. mypy default mode is being applied (pyproject.toml [tool.mypy] only sets ignore_missing_imports = true and no_error_summary = true). Some errors are real type bugs; others are incomplete annotation coverage; a smaller subset is env-version drift in Pillow/skimage APIs.

Fix

Bring mypy src/ to zero errors while preserving run-time behavior. Strategy:

  1. Configure mypy honestly in pyproject.toml:
    • Add [[tool.mypy.overrides]] for modules that are intentionally untyped (# type: ignore is fine for env-version drift on third-party APIs).
    • Set disallow_untyped_defs = false for now; flip to true module-by-module as coverage improves.
    • Keep ignore_missing_imports = true.
  2. Fix the real type bugs first (highest-trafficked files in src/main_pipeline.py, src/embroidery_converter/, src/output_generators/, src/machine/, src/raster/).
  3. Use targeted # type: ignore[error-code] for env-version drift where the code works at runtime but the typing library disagrees (e.g. MEDIANCUT on Image.Quantize).
  4. Add missing annotations for var-annotated errors.
  5. Verify with the same mypy src/ --ignore-missing-imports --no-error-summary command used in CI.

Acceptance

  • mypy src/ --ignore-missing-imports --no-error-summary exits 0.
  • ruff check . and pytest tests/ -q still pass (regression check).
  • No runtime behavior change (CI Tests job still green).

Scope / Out of Scope

In scope: Reduce mypy error count to zero on src/.
Out of scope: Adding tests for code paths that have none today; re-typing tests/; introducing strict mode module-by-module (track as a follow-up issue).

Files likely touched

pyproject.toml                          (mypy config)
src/utils/validation.py
src/utils/formats/format_validator.py
src/post_processing/post_processor.py
src/post_processing/pull_comp.py
src/visualization/visualizer.py
src/intent_resolver/dom_resolver.py
src/svg_parser/parser.py
src/utils/stitch_utils.py
src/utils/data_structures.py
src/svg_annotation/annotator.py
... and ~24 more src/ files (each <=10 errors)

Context

  • Repo: Mark/easystitch
  • Working branch: main at f456bc7
  • Verified environment: Python 3.12, Pillow (env-version drift noted), scikit-image (env-version drift noted), ruff 0.x, mypy 1.x
  • mypy invocation: mypy src/ --ignore-missing-imports --no-error-summary (matches .forgejo/workflows/ci.yml line ~55)
  • Error counts above were captured by mypy src/ --ignore-missing-imports | grep -E '^src/' | awk '{print $1}' | sort | uniq -c | sort -rn
## Problem The `Lint & Type Check` workflow in `.forgejo/workflows/ci.yml` runs `mypy src/ --ignore-missing-imports --no-error-summary` as the **Type Check** job. As of commit `f456bc7` (CI path correction + ruff format), this job produces **273 mypy errors across 34 files** and exits non-zero. This blocks PR merges via the required CI check. The Lint sub-step (`ruff check .`) and Tests (`pytest tests/ -q`) both pass. The pipeline itself (kilo-gsd) is not blocked — its Lint gate is `ruff` only — but a clean CI baseline is required for the pipeline to be useful for anything that produces a PR. ## Error Breakdown (mypy src/, default flags + --ignore-missing-imports) ``` [error-code] count notes assignment 78 int vs float, mostly literal-float assigned to int param index 42 typed collection (tuple/list/dict) item assignment list-item 32 "Right hand side values are not supported in unions" attr-defined 29 mostly env-version drift (PIL.Image.MEDIANCUT removed, skimage.filters.MeanFilter removed, etc.) var-annotated 19 missing type hints on local vars no-redef 14 duplicate `from X import Y` / re-bind return-value 13 function annotated return type doesn't match what is returned union-attr 11 attribute access on Optional[Type] arg-type 11 wrong argument type operator 10 unsupported operand types dict-item 6 dict key/value type mismatches valid-type 4 bare `any` instead of `typing.Any` empty-body 3 function with `...` body but annotated return type misc 1 ``` **Files with the most errors (top 10):** ``` src/utils/validation.py 39 src/utils/formats/format_validator.py 22 src/post_processing/post_processor.py 19 src/post_processing/pull_comp.py 17 src/visualization/visualizer.py 17 src/intent_resolver/dom_resolver.py 15 src/svg_parser/parser.py 12 src/utils/stitch_utils.py 11 src/utils/data_structures.py 10 src/svg_annotation/annotator.py 10 ``` ## Cause The codebase is ~30K LOC of Python with type hints on many function signatures but no enforcement until now. mypy default mode is being applied (`pyproject.toml [tool.mypy]` only sets `ignore_missing_imports = true` and `no_error_summary = true`). Some errors are real type bugs; others are incomplete annotation coverage; a smaller subset is env-version drift in Pillow/skimage APIs. ## Fix Bring mypy src/ to zero errors while preserving run-time behavior. Strategy: 1. **Configure mypy honestly** in `pyproject.toml`: - Add `[[tool.mypy.overrides]]` for modules that are intentionally untyped (`# type: ignore` is fine for env-version drift on third-party APIs). - Set `disallow_untyped_defs = false` for now; flip to `true` module-by-module as coverage improves. - Keep `ignore_missing_imports = true`. 2. **Fix the real type bugs** first (highest-trafficked files in `src/main_pipeline.py`, `src/embroidery_converter/`, `src/output_generators/`, `src/machine/`, `src/raster/`). 3. **Use targeted `# type: ignore[error-code]`** for env-version drift where the code works at runtime but the typing library disagrees (e.g. `MEDIANCUT` on `Image.Quantize`). 4. **Add missing annotations** for `var-annotated` errors. 5. **Verify** with the same `mypy src/ --ignore-missing-imports --no-error-summary` command used in CI. ## Acceptance - `mypy src/ --ignore-missing-imports --no-error-summary` exits 0. - `ruff check .` and `pytest tests/ -q` still pass (regression check). - No runtime behavior change (CI Tests job still green). ## Scope / Out of Scope **In scope:** Reduce mypy error count to zero on `src/`. **Out of scope:** Adding tests for code paths that have none today; re-typing `tests/`; introducing strict mode module-by-module (track as a follow-up issue). ## Files likely touched ``` pyproject.toml (mypy config) src/utils/validation.py src/utils/formats/format_validator.py src/post_processing/post_processor.py src/post_processing/pull_comp.py src/visualization/visualizer.py src/intent_resolver/dom_resolver.py src/svg_parser/parser.py src/utils/stitch_utils.py src/utils/data_structures.py src/svg_annotation/annotator.py ... and ~24 more src/ files (each <=10 errors) ``` ## Context - Repo: `Mark/easystitch` - Working branch: `main` at `f456bc7` - Verified environment: Python 3.12, Pillow (env-version drift noted), scikit-image (env-version drift noted), ruff 0.x, mypy 1.x - mypy invocation: `mypy src/ --ignore-missing-imports --no-error-summary` (matches `.forgejo/workflows/ci.yml` line ~55) - Error counts above were captured by `mypy src/ --ignore-missing-imports | grep -E '^src/' | awk '{print $1}' | sort | uniq -c | sort -rn`
Author
Owner

Auto-triage: needs decompose

Marked triage-approved + needs-decompose. decompose-executor will pick this up and break it into implementable sub-issues.

## Auto-triage: needs decompose Marked `triage-approved` + `needs-decompose`. decompose-executor will pick this up and break it into implementable sub-issues.
Author
Owner

Auto-triage: needs decompose

Marked triage-approved + needs-decompose. decompose-executor will pick this up and break it into implementable sub-issues.

## Auto-triage: needs decompose Marked `triage-approved` + `needs-decompose`. decompose-executor will pick this up and break it into implementable sub-issues.
Mark 2026-06-22 19:14:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/easystitch#72
No description provided.