Skip to content

Widen write_vrt nodata type hint to accept int (#1684)#1687

Merged
brendancol merged 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-api-consistency-geotiff-2026-05-12-v2-02
May 12, 2026
Merged

Widen write_vrt nodata type hint to accept int (#1684)#1687
brendancol merged 2 commits into
xarray-contrib:mainfrom
brendancol:deep-sweep-api-consistency-geotiff-2026-05-12-v2-02

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • write_vrt annotated nodata: float | None, but to_geotiff and write_geotiff_gpu leave 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.
  • Widen the annotation to float | int | None on 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.py
  • Confirms the public write_vrt annotation includes int
  • Confirms the internal _vrt.write_vrt annotation does too
  • Confirms write_vrt(..., nodata=65535) round-trips through parse_vrt

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.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 12, 2026
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.
@brendancol brendancol requested a review from Copilot May 12, 2026 17:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from float | None to float | int | None in both the public wrapper and internal implementation.
  • Update write_vrt docstrings to explicitly document nodata as “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_vrtparse_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.

@brendancol brendancol merged commit 6530d9e into xarray-contrib:main May 12, 2026
9 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geotiff: write_vrt nodata type hint is float-only but to_geotiff/write_geotiff_gpu accept int

2 participants