Skip to content

Annotate every function in the package and its tests - #68

Merged
roytsmart merged 1 commit into
mainfrom
annotate-functions
Oct 1, 2026
Merged

roytsmart merged 1 commit into
mainfrom
annotate-functions

Conversation

@roytsmart

Copy link
Copy Markdown
Collaborator

Adds type annotations to every function in the package and its tests that was missing them. There are no behavior changes.

Package (13 functions)

  • Clipping kernel bodies: area_signed, num_pair and clip_cell, which build() compiles for each target. They now match the module-level helpers beside them, which were already annotated.
  • CUDA kernels: _fill, _scatter, count_cells and clip_cells. Device arrays are annotated as Any, as they already are where the host passes them in, because numba ships no type for DeviceNDArray.
  • Host: _jit() in the clipping kernel.
  • Return types and **kwargs: sign() -> int, index_in_bounds() -> bool, ndarray_linear_interpolation() -> np.ndarray, _calc_and_save_weights() -> None, and fill(**kwargs: Any).

Numba ignores annotations, so the compiled kernels are unchanged.

Tests (154 functions)

  • -> None: added to every test function (133, done mechanically).
  • Helpers: the helpers and nested helpers (_grids, _lattice, _flat, _triple, dense, totals, ...) are annotated by hand.
  • Parametrized tests: the untyped parameters of four parametrized tests are typed (dtype, func, unit).

Checks

  • An AST scan finds no function in regridding/ without full annotations.
  • Pyright at CI's 1.1.411 with the repo config is unchanged.
  • The tests are excluded from pyright in pyproject.toml, and pyright skips an excluded file even when it is named on the command line. I therefore checked them with a temporary config that includes them:
    • On main: 127 errors.
    • With this PR: 81 errors, none of them new. The annotations remove 46.
    • What remains: errors that already existed, mostly astropy unit expressions and keyword arguments collected with dict(...) and splatted.
  • Full suite locally, including the CUDA tests on an RTX 4090: 405 passed and 2 xfailed. black and ruff pass.
  • A real trial merge with Add convolve_weights() to fold a point-spread function into a set of weights #67 is clean, and the merged tree is fully annotated with its tests passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GqceVSp8s2msxj1Dr9MrGU

Thirteen functions in the package had none: the bodies of the clipping
kernel that `build()` compiles for each target, the three CUDA kernels, the
host's `_jit()`, and a few return types (`sign()`, `index_in_bounds()`,
`ndarray_linear_interpolation()`, `_calc_and_save_weights()`, and `fill()`'s
`**kwargs`).  Device arrays are annotated as `Any`, as they already are
where they are passed in, since `numba` ships no type for them.

In the tests, every test function now returns `-> None`, and the helpers
and the parameters of parametrized tests are annotated.  The tests are still
excluded from the type check, but with a configuration that includes them
these annotations add no errors and remove 46 of the 127 already there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GqceVSp8s2msxj1Dr9MrGU
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.62%. Comparing base (a3966eb) to head (f7d7cd8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #68   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files          55       55           
  Lines        3188     3192    +4     
=======================================
+ Hits         3176     3180    +4     
  Misses         12       12           
Flag Coverage Δ
unittests 99.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roytsmart
roytsmart merged commit c76e994 into main Oct 1, 2026
19 checks passed
@roytsmart
roytsmart deleted the annotate-functions branch October 3, 2026 00:31
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.

1 participant