Proposed new feature or change:
Now that #1760 ships the py.typed marker, uxarray is telling type checkers to trust its annotations — but nothing checks that they are true. Running mypy uxarray/core uxarray/grid --ignore-missing-imports today reports 109 errors in 17 files, and some are real: _is_structured (uxarray/io/utils.py:131) is declared -> bool but returns a 3-tuple at all three exits, and its only caller unpacks three values. mypy is not in ci/environment.yml, so this needs adding there as well.
Done when a non-blocking mypy job runs on uxarray/core and uxarray/grid in CI. Non-blocking to start (continue-on-error: true): the errors are a backlog, not a regression, and 24 open PRs should not be held up by it — the job reports, and the count gets ratcheted down module by module.
What the 109 look like
Roughly a third are one mechanical pattern: 32 [attr-defined] from x = x.setter(make_setter("x")) (uxarray/grid/grid.py:977 and 20 similar), which mypy cannot follow because the property is rebound to a plain function. That is a # type: ignore or a small refactor, not a bug hunt.
Another cluster is the int | None = 1 pattern from #1593: TreeQuery.query(k: int | None = 1) then if k < 1 (uxarray/grid/neighbors.py:249) — mypy reports int > None. Unreachable in practice, but it shows the annotation is wrong, which is exactly what #1593 asks to fix.
Breakdown: 32 attr-defined, 19 union-attr, 16 assignment, 13 arg-type, 12 index, 5 misc, 4 return-value, 4 operator, 4 other. By file: grid/grid.py 42, grid/neighbors.py 21, core/dataarray.py 14, core/dataset.py 12.
Why not --strict yet
--disallow-untyped-defs reports 775 errors in 63 files, because coverage is thin: 213/798 functions have return annotations and 227 public functions have none. mypy skips the body of an unannotated function by default, so the useful sequence is to annotate first and tighten second, rather than turn everything on and suppress. Annotating open_grid first needs a decision on return_chunks (undocumented, untested, one private caller at uxarray/core/api.py:574, and returns an unusable value on the documented chunks=-1 path).
Related: #1760, #1593
Proposed new feature or change:
Now that #1760 ships the
py.typedmarker, uxarray is telling type checkers to trust its annotations — but nothing checks that they are true. Runningmypy uxarray/core uxarray/grid --ignore-missing-importstoday reports 109 errors in 17 files, and some are real:_is_structured(uxarray/io/utils.py:131) is declared-> boolbut returns a 3-tuple at all three exits, and its only caller unpacks three values.mypyis not inci/environment.yml, so this needs adding there as well.Done when a non-blocking mypy job runs on
uxarray/coreanduxarray/gridin CI. Non-blocking to start (continue-on-error: true): the errors are a backlog, not a regression, and 24 open PRs should not be held up by it — the job reports, and the count gets ratcheted down module by module.What the 109 look like
Roughly a third are one mechanical pattern: 32
[attr-defined]fromx = x.setter(make_setter("x"))(uxarray/grid/grid.py:977 and 20 similar), which mypy cannot follow because the property is rebound to a plain function. That is a# type: ignoreor a small refactor, not a bug hunt.Another cluster is the
int | None = 1pattern from #1593:TreeQuery.query(k: int | None = 1)thenif k < 1(uxarray/grid/neighbors.py:249) — mypy reportsint > None. Unreachable in practice, but it shows the annotation is wrong, which is exactly what #1593 asks to fix.Breakdown: 32
attr-defined, 19union-attr, 16assignment, 13arg-type, 12index, 5misc, 4return-value, 4operator, 4 other. By file: grid/grid.py 42, grid/neighbors.py 21, core/dataarray.py 14, core/dataset.py 12.Why not
--strictyet--disallow-untyped-defsreports 775 errors in 63 files, because coverage is thin: 213/798 functions have return annotations and 227 public functions have none. mypy skips the body of an unannotated function by default, so the useful sequence is to annotate first and tighten second, rather than turn everything on and suppress. Annotatingopen_gridfirst needs a decision onreturn_chunks(undocumented, untested, one private caller at uxarray/core/api.py:574, and returns an unusable value on the documentedchunks=-1path).Related: #1760, #1593