Fix mypy errors and align make lint with CI#67
Merged
Conversation
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>
0810ef1 to
adbfa62
Compare
There was a problem hiding this comment.
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 lintrun 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.,
Callabletyping, 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.
Collaborator
Author
|
Verified linting updates do not break packing workflows |
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
Makes the CI lint gate pass green by clearing the pre-existing mypy type-checking debt (132 errors across 27 files), and aligns
make lintwith the CI config so local and CI behavior match.Changes
mypy: 132 → 0 errors
.*/notebooks/.*from[tool.mypy] exclude(66 errors), mirroring the ruff notebook per-file-ignore.Figure | Nonenarrowing, tuple return types), and use a few narrowly-scoped# type: ignorewith reasons (e.g.np.mgridfloat slices).make lintnow matches CI--disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs) so it runs plainmypy cellpack_analysis, identical tolint.yml.Clear pre-existing ruff/black debt (independent of mypy; surfaced once lint was run end-to-end)
"**/notebooks/*.py" = ["D", "E501"]ruff per-file-ignore.B007false positive and aC901via scoped# noqa).Verification
All four CI lint steps pass clean:
🤖 Generated with Claude Code