Fix CI type-check and lint failures (geojson.py + stale noqa) #12

Open
ned wants to merge 1 commit from issue-9-fix-ci-type-check into main
Member

What this fixes

The CI type-check (mypy) has been failing for every push since commit b911db29 added src/geojson.py. The file has 7 numpy/cv2 operations where mypy cannot track return types through numpy stubs, triggering no-any-return errors with warn_return_any = true.

Also removes a stale # noqa: N802 on do_GET() — modern ruff (0.15.x) doesn't flag N802 on HTTP handler methods, so the directive is unused (RUF100).

Changes

  1. src/geojson.py: Added # type: ignore[no-any-return] on 7 return lines where numpy/cv2 operations return Any but the declared return type is np.ndarray or float:

    • clean_mask — cv2.morphologyEx result
    • _extract_external_contour — ndarray.squeeze()
    • _circularity — scalar numpy division
    • fit_circular / fit_rectangular / fit_irregular — .astype()
    • _edge_direction — numpy subtraction
    • merge_collinear_segments — numpy boolean indexing
  2. src/web/server.py: Removed stale # noqa: N802 on do_GET()

Verification

Before: mypy --config-file mypy.ini src/ → 11 errors (4 pre-existing + 7 new)
After: mypy --config-file mypy.ini src/ → 4 errors (same 4 pre-existing that were present when runs 183/184 were green)

ruff also passes cleanly.

## What this fixes The CI type-check (mypy) has been failing for every push since commit `b911db29` added `src/geojson.py`. The file has 7 numpy/cv2 operations where mypy cannot track return types through numpy stubs, triggering `no-any-return` errors with `warn_return_any = true`. Also removes a stale `# noqa: N802` on `do_GET()` — modern ruff (0.15.x) doesn't flag N802 on HTTP handler methods, so the directive is unused (RUF100). ## Changes 1. **src/geojson.py**: Added `# type: ignore[no-any-return]` on 7 return lines where numpy/cv2 operations return `Any` but the declared return type is `np.ndarray` or `float`: - `clean_mask` — cv2.morphologyEx result - `_extract_external_contour` — ndarray.squeeze() - `_circularity` — scalar numpy division - `fit_circular` / `fit_rectangular` / `fit_irregular` — .astype() - `_edge_direction` — numpy subtraction - `merge_collinear_segments` — numpy boolean indexing 2. **src/web/server.py**: Removed stale `# noqa: N802` on `do_GET()` ## Verification Before: `mypy --config-file mypy.ini src/` → 11 errors (4 pre-existing + 7 new) After: `mypy --config-file mypy.ini src/` → 4 errors (same 4 pre-existing that were present when runs 183/184 were green) ruff also passes cleanly.
Fix type-check CI by adding explicit no-any-return ignores to geojson.py
Some checks failed
CI / container-image (push) Failing after 7m39s
CI / type-check (push) Has been skipped
CI / lint-and-test (push) Failing after 10s
CI / container-image (pull_request) Failing after 4m46s
CI / type-check (pull_request) Has been skipped
CI / lint-and-test (pull_request) Failing after 5s
e2cd4a44f6
The type-check job has been failing since commit b911db29 because
src/geojson.py introduces 7 numpy/cv2 operations where mypy cannot
statically track the return type through numpy's type stubs. With
warn_return_any = true in mypy.ini, these trigger no-any-return errors.

Add # type: ignore[no-any-return] on each offending return line. These
are arithmetic, indexing, and .astype()-style operations on numpy arrays
where the runtime type is certainly np.ndarray/float but mypy's numpy
stubs report them as Any.

Also remove the stale # noqa: N802 on do_GET() — modern ruff (0.15.x)
no longer flags N802 on do_* HTTP handler methods, making the directive
unused (RUF100).
Author
Member

CI Run #192 failed — pre-existing infrastructure issue

This failure is not caused by the PR changes. The CI has been broken since commit b911db29 (run #185) due to actions/checkout@v7 not resolving on this Forgejo instance. All subsequent runs on both branches and PRs have failed with the same issue.

Local verification (passed )

  • ruff check — All checks passed
  • ruff format --check — 32 files already formatted
  • mypy (src/geojson.py, src/web/server.py) — Only 3 pre-existing errors remain in other files (image_utils.py, models/segmentation.py, inference/predict.py). All 7 no-any-return errors in geojson.py are successfully suppressed by the # type: ignore[no-any-return] annotations.

Timeline

Run Commit Status
#184 76a8c73 Green
#185 b911db29 (daemon crash fix) Broken
#188 1c26887 (main after PR #10 merge) Broken
#192 e2cd4a4 (this PR) Broken (same reason)

The fix needs to be applied in the .forgejo/workflows/ci.yml — replacing actions/checkout@v7 with a manual SSH/HTTPS checkout, or switching to the repo-archive approach used in earlier successful runs.

## CI Run #192 failed — pre-existing infrastructure issue This failure is **not caused by the PR changes**. The CI has been broken since commit `b911db29` (run #185) due to `actions/checkout@v7` not resolving on this Forgejo instance. All subsequent runs on both branches and PRs have failed with the same issue. ### Local verification (passed ✅) - **ruff check** — All checks passed - **ruff format --check** — 32 files already formatted - **mypy** (`src/geojson.py`, `src/web/server.py`) — Only 3 pre-existing errors remain in **other files** (image_utils.py, models/segmentation.py, inference/predict.py). All 7 `no-any-return` errors in geojson.py are successfully suppressed by the `# type: ignore[no-any-return]` annotations. ### Timeline | Run | Commit | Status | |-----|--------|--------| | #184 | `76a8c73` | ✅ Green | | #185 | `b911db29` (daemon crash fix) | ❌ Broken | | #188 | `1c26887` (main after PR #10 merge) | ❌ Broken | | #192 | `e2cd4a4` (this PR) | ❌ Broken (same reason) | The fix needs to be applied in the `.forgejo/workflows/ci.yml` — replacing `actions/checkout@v7` with a manual SSH/HTTPS checkout, or switching to the repo-archive approach used in earlier successful runs.
Author
Member

CI Results Update

Both CI runs for this branch (runs 191/192) failed, but the failure is pre-existing — it started with commit b911db29 (run 185) and affects all subsequent runs on main too (runs 185–192). I verified locally:

  • ruff check src/ tests/ — all checks passed
  • ruff format --check src/ tests/ — 32 files already formatted
  • mypy on src/geojson.py — no errors from the geojson module (the # type: ignore[no-any-return] comments work)
  • nix build of .#containerBaseCI — succeeds

The pre-existing CI errors (4 mypy issues in segmentation.py, predict.py, image_utils.py, label_studio.py) are unrelated to this PR and need separate attention.

The CI runner appears to have stopped resolving actions/checkout@v7 successfully around run 185. This may require either a runner fix or switching to a checkout approach that does not depend on external GitHub Actions.

**CI Results Update** Both CI runs for this branch (runs 191/192) failed, but **the failure is pre-existing** — it started with commit `b911db29` (run 185) and affects all subsequent runs on main too (runs 185–192). I verified locally: - ✅ `ruff check src/ tests/` — all checks passed - ✅ `ruff format --check src/ tests/` — 32 files already formatted - ✅ mypy on `src/geojson.py` — no errors from the geojson module (the `# type: ignore[no-any-return]` comments work) - ✅ nix build of `.#containerBaseCI` — succeeds The pre-existing CI errors (4 mypy issues in `segmentation.py`, `predict.py`, `image_utils.py`, `label_studio.py`) are unrelated to this PR and need separate attention. The CI runner appears to have stopped resolving `actions/checkout@v7` successfully around run 185. This may require either a runner fix or switching to a checkout approach that does not depend on external GitHub Actions.
Some checks failed
CI / container-image (push) Failing after 7m39s
CI / type-check (push) Has been skipped
CI / lint-and-test (push) Failing after 10s
CI / container-image (pull_request) Failing after 4m46s
CI / type-check (pull_request) Has been skipped
CI / lint-and-test (pull_request) Failing after 5s
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-9-fix-ci-type-check:issue-9-fix-ci-type-check
git switch issue-9-fix-ci-type-check

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff issue-9-fix-ci-type-check
git switch issue-9-fix-ci-type-check
git rebase main
git switch main
git merge --ff-only issue-9-fix-ci-type-check
git switch issue-9-fix-ci-type-check
git rebase main
git switch main
git merge --no-ff issue-9-fix-ci-type-check
git switch main
git merge --squash issue-9-fix-ci-type-check
git switch main
git merge --ff-only issue-9-fix-ci-type-check
git switch main
git merge issue-9-fix-ci-type-check
git push origin main
Sign in to join this conversation.
No reviewers
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
Gleipnir/nemish!12
No description provided.