Widen write_vrt nodata type hint to accept int (#1684)#1687
Merged
brendancol merged 2 commits intoMay 12, 2026
Merged
Conversation
write_vrt advertised `nodata: float | None` while the sibling writers to_geotiff and write_geotiff_gpu accept "float, int, or None" with no type annotation. Integer sentinels (65535 for uint16, -9999 for int32) round-trip through the rest of the I/O surface; the float-only hint was a static-typing trap, not a runtime constraint. Widen to `float | int | None` on the public wrapper and the internal _vrt.write_vrt, and document the surface match in both docstrings. Add a round-trip regression so future drift surfaces.
brendancol
added a commit
to brendancol/xarray-spatial
that referenced
this pull request
May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and xarray-contrib#1689. cuda-validated.
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and xarray-contrib#1689. cuda-validated.
brendancol
added a commit
to brendancol/xarray-spatial
that referenced
this pull request
May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and xarray-contrib#1689. cuda-validated.
brendancol
added a commit
that referenced
this pull request
May 12, 2026
* Document bigtiff kwarg in to_geotiff docstring (#1683) The Parameters block jumped from overview_resampling to gpu, omitting the bigtiff entry that has been on the signature for several releases. write_geotiff_gpu documents the same kwarg, so callers who learned the API from the GPU writer and ported a call to to_geotiff had no way to discover the option from help(to_geotiff). Pin the entry against future drift with a test that walks the Parameters block and compares it to inspect.signature(). * Update api-consistency sweep state for geotiff v2 (2026-05-12) Three MEDIUM findings filed and fixed: #1683 (bigtiff docstring gap on to_geotiff), #1684 (write_vrt nodata float|None widened to float|int|None), and #1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs #1686, #1687, and #1689. cuda-validated.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the xrspatial.geotiff.write_vrt API surface with sibling GeoTIFF writers by widening the nodata type annotation to accept integer sentinel values, avoiding false positives from strict type checkers while preserving existing runtime behavior.
Changes:
- Widen
write_vrt(..., nodata=...)type hints fromfloat | Nonetofloat | int | Nonein both the public wrapper and internal implementation. - Update
write_vrtdocstrings to explicitly documentnodataas “float, int, or None” and clarify integer sentinel use cases. - Add a regression test that (1) pins the widened annotations and (2) verifies an integer nodata value flows through
write_vrt→parse_vrt.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
xrspatial/geotiff/__init__.py |
Widens public write_vrt nodata annotation and updates docstring wording to include int. |
xrspatial/geotiff/_vrt.py |
Widens internal write_vrt nodata annotation and updates docstring wording to include int. |
xrspatial/geotiff/tests/test_write_vrt_int_nodata_1684.py |
Adds regression coverage for widened annotations and an int-sentinel round-trip through VRT parsing. |
.claude/sweep-api-consistency-state.csv |
Records the sweep finding/fix status for #1684 in the consistency tracking file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
write_vrtannotatednodata: float | None, butto_geotiffandwrite_geotiff_gpuleave the kwarg untyped and document it as "float, int, or None". Integer sentinels (65535 for uint16, -9999 for int32) round-trip through<NoDataValue>already; the float-only hint only tripped strict type checkers and IDEs.float | int | Noneon the public wrapper (__init__.py) and the internal helper (_vrt.py), update both docstrings to read "float, int, or None", and add a round-trip regression covering an int sentinel.Fixes #1684. Found during the geotiff API consistency sweep (Cat 3, MEDIUM).
Test plan
pytest xrspatial/geotiff/tests/test_write_vrt_int_nodata_1684.pywrite_vrtannotation includesint_vrt.write_vrtannotation does toowrite_vrt(..., nodata=65535)round-trips throughparse_vrt