resample: add type annotations to public signature (#2544)#2546
Merged
Conversation
API consistency sweep finding (Cat 3 MEDIUM). resample() was the only public symbol in xrspatial.resample without type annotations on any parameter or return type. Sibling terrain modules (slope, aspect, hillshade, curvature) all annotate `agg: xr.DataArray` and declare `-> xr.DataArray`; the docstring already declared the intended types, so this was a doc-vs-signature drift. - Annotate agg, scale_factor, target_resolution, method, nodata, name and the return type using `from __future__ import annotations` for the `|` union syntax already in use. - Note in the docstring that `agg` accepts xr.Dataset via the @supports_dataset decorator. - Add test_resample_signature_annot_2544.py pinning every param and the return type so future contributors cannot silently drop them.
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.
Closes #2544.
Summary
xrspatial.resample.resample(), matching the docstring contract and the convention used byslope,aspect,hillshade,curvature, and the recently-fixedrasterize(rasterize: add type annotations to geometries, columns, merge params #2250) /polygonize(polygonize: add return type annotation to public signature #2148) /open_geotiff(geotiff: open_geotiff(max_cloud_bytes=...) missing type annotation #2106).aggacceptsxr.Datasettoo (the@supports_datasetdecorator already handles it).test_resample_signature_annot_2544.pyto pin the annotations so a future contributor cannot silently drop them.Annotations use
from __future__ import annotations(already at top of the file) for the|union syntax.typing.get_type_hints(resample)resolves all 7 names without error.Findings NOT fixed in this PR
Documented in the sweep state CSV; left for separate design issues:
method(resample) vsresampling(reproject/merge) — same conceptual parameter, different name. Cross-cutting rename that needs a deprecation shim on either side.aggvsrasteracross the wider library — library-wide drift, not per-module.Test plan
xrspatial/tests/test_resample.pytests pass.test_resample_signature_annot_2544.py(3 tests) passes.typing.get_type_hints(resample)resolves all annotations at runtime.nearest,bilinear, andaveragemethods on host with CUDA_AVAILABLE=True.