Skip to content

Fix mypy errors and align make lint with CI#67

Merged
mogres merged 1 commit into
mainfrom
chore/mypy-cleanup
Jun 17, 2026
Merged

Fix mypy errors and align make lint with CI#67
mogres merged 1 commit into
mainfrom
chore/mypy-cleanup

Conversation

@mogres

@mogres mogres commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes the CI lint gate pass green by clearing the pre-existing mypy type-checking debt (132 errors across 27 files), and aligns make lint with the CI config so local and CI behavior match.

Changes

mypy: 132 → 0 errors

  • Exclude .*/notebooks/.* from [tool.mypy] exclude (66 errors), mirroring the ruff notebook per-file-ignore.
  • Fix the remaining 66 library/workflow errors properly: add function/variable annotations, correct real type mismatches (ndarray/list, float/int, Figure | None narrowing, tuple return types), and use a few narrowly-scoped # type: ignore with reasons (e.g. np.mgrid float slices).

make lint now matches CI

  • Drop the extra Makefile mypy flags (--disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs) so it runs plain mypy cellpack_analysis, identical to lint.yml.

Clear pre-existing ruff/black debt (independent of mypy; surfaced once lint was run end-to-end)

  • Add "**/notebooks/*.py" = ["D", "E501"] ruff per-file-ignore.
  • Hand-fix remaining ruff errors (E501 line wraps; a B007 false positive and a C901 via scoped # noqa).
  • Apply black to 5 files.

Verification

All four CI lint steps pass clean:

ruff check cellpack_analysis   → All checks passed!
black --check cellpack_analysis → unchanged
isort --check cellpack_analysis → ok
mypy cellpack_analysis          → Success: no issues found

🤖 Generated with Claude Code

Clear the 132 pre-existing mypy errors so `mypy cellpack_analysis` (the CI
gate) passes:
- Exclude `.*/notebooks/.*` from `[tool.mypy] exclude` (66 errors), mirroring
  the ruff notebook per-file-ignore.
- Fix the remaining 66 library/workflow errors properly: add function and
  variable annotations, correct real type mismatches (ndarray/list, float/int,
  Figure|None narrowing, tuple return types), and use a few narrowly-scoped
  `# type: ignore` with reasons (e.g. np.mgrid float slices).

Align `make lint` with CI: drop the extra Makefile mypy flags
(`--disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs`)
so it runs plain `mypy cellpack_analysis`, identical to lint.yml.

Clear pre-existing ruff/black debt so all CI lint steps pass: add the
`"**/notebooks/*.py" = ["D", "E501"]` ruff per-file-ignore, hand-fix the
remaining ruff errors (E501 line wraps, a B007 false positive and a C901 via
scoped `# noqa`), and apply black.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mogres mogres force-pushed the chore/mypy-cleanup branch from 0810ef1 to adbfa62 Compare June 13, 2026 05:02
@mogres mogres requested a review from Copilot June 13, 2026 05:03
@mogres mogres marked this pull request as ready for review June 13, 2026 05:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR clears existing mypy type-checking failures across the codebase and makes local make lint behavior match the CI lint workflow, so developers get consistent results locally and in CI.

Changes:

  • Update mypy configuration and local lint invocation so CI and make lint run the same mypy command and scope.
  • Add/adjust type annotations and narrow a few value types (notably NumPy scalar → float) to resolve mypy errors.
  • Apply small refactors to satisfy lint/type tooling (e.g., Callable typing, figure/axes narrowing, minor array variable renames).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Excludes notebooks/ from mypy discovery and adds ruff notebook per-file ignores to keep linting consistent.
Makefile Aligns make lint mypy invocation with CI by removing extra strict CLI flags.
cellpack_analysis/preprocessing/get_structure_coordinates.py Ensures numeric outputs are JSON-serializable floats and adds explicit dict typing + return annotation.
cellpack_analysis/preprocessing/get_meshes_from_images.py Adds explicit main() -> int return typing for script entrypoint.
cellpack_analysis/packing/run_packing_workflow.py Adds return type to _run_packing_workflow() consistent with downstream usage (total_failed).
cellpack_analysis/packing/pack_recipes.py Broadens internal dictionary typing to satisfy mypy where mixed value types are stored.
cellpack_analysis/lib/visualization.py Tightens return types and figure retrieval/narrowing; resolves type issues around colormaps and plotting arrays.
cellpack_analysis/lib/stats.py Clarifies tobs/tobs_joint numeric typing across envelope implementations.
cellpack_analysis/lib/simularium_utils.py Adds Any typing for untyped external clients/dataframes to satisfy mypy.
cellpack_analysis/lib/s3_utils.py Adds Any typing for boto3 S3 client plumbing and get_s3_client() return.
cellpack_analysis/lib/rule_interpolation.py Adds precise Callable[...] annotations for MSE getter callbacks.
cellpack_analysis/lib/occupancy.py Minor variable renames to keep types consistent through NumPy percentile/max operations.
cellpack_analysis/lib/mesh_tools.py Adds narrowly-scoped type: ignore[misc] for np.mgrid float-slice stubs and simplifies return.
cellpack_analysis/lib/label_tables.py Updates projection label mapping to a tuple form consistent with unpacking usage.
cellpack_analysis/lib/img_io.py Declares generate_composite_thumbnail() as -> None to match behavior.
cellpack_analysis/lib/distance.py Tightens return and intermediate collection types and normalizes dtypes in aggregation.
cellpack_analysis/data_release/run_data_release_workflow.py Adds Any typing for helper return values and S3 client parameter typing.
cellpack_analysis/data_release/export_simularium_paths_as_csv.py Adds Any typing and list annotations for script-level structures and processing lists.
cellpack_analysis/data_release/data_release_config.py Adds explicit -> None return typing for internal setup methods.
cellpack_analysis/analysis/workflows/run_analysis_workflow.py Adds explicit -> None return typing for internal methods and main().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mogres

mogres commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

Verified linting updates do not break packing workflows

@mogres mogres merged commit 317e85f into main Jun 17, 2026
8 checks passed
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