geotiff: writers return the written path (#1938)#1942
Merged
brendancol merged 1 commit intoMay 15, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the GeoTIFF writer entry points’ return values so callers (and generated docs/type-checkers) can treat to_geotiff, write_geotiff_gpu, and write_vrt uniformly by returning the destination they wrote to.
Changes:
- Update
to_geotiffto return the providedpath(string path or file-like object) instead ofNone. - Update
write_geotiff_gputo return the providedpathand document the return contract. - Add a regression test covering writer return values and pinned return annotations/signatures (with GPU runtime asserted only when cupy+CUDA is available).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
xrspatial/geotiff/_writers/eager.py |
Changes to_geotiff to return path across all successful write paths and documents the return value. |
xrspatial/geotiff/_writers/gpu.py |
Changes write_geotiff_gpu return type/behavior to return path and documents the new return contract. |
xrspatial/geotiff/tests/test_writer_return_path_1938.py |
Adds regression coverage ensuring writers don’t regress to returning None and that return annotations remain consistent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
45
to
47
| bigtiff: bool | None = None, | ||
| max_z_error: float = 0.0, | ||
| streaming_buffer_bytes: int = 256 * 1024 * 1024, |
to_geotiff and write_geotiff_gpu returned None while write_vrt returned str. The drift broke mypy consumers who handled the three writers uniformly and made the Sphinx-rendered docs surface inconsistent. Make to_geotiff and write_geotiff_gpu return the path argument (a str for filesystem paths, the file-like object for BytesIO destinations). The change is additive: existing callers that discarded the previous None return are unaffected, and chained writes (path = to_geotiff(da, out); da2 = open_geotiff(path)) work without round-tripping through a variable. write_vrt's existing str return is preserved. Regression test pins the runtime return value for to_geotiff and write_vrt across str + BytesIO + COG + dask-streaming destinations, plus a GPU branch gated on cupy+CUDA. A signature-level assertion pins the return annotations of all three writers so a future change cannot silently revert the contract.
5f75ca9 to
3999ffd
Compare
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
to_geotiffandwrite_geotiff_gpureturnedNonewhilewrite_vrtreturnedstr(the path written). The drift brokemypyconsumers handling the three writers uniformly and made the Sphinx-rendered docs surface inconsistent.to_geotiffandwrite_geotiff_gpureturn thepathargument: astrfor filesystem paths, the file-like object forBytesIOdestinations. The change is additive (callers that discarded the previousNoneare unaffected) and lets callers chain a write into a read.write_vrt's existingstrcontract is preserved.Closes #1938.
Test plan
pytest xrspatial/geotiff/tests/test_writer_return_path_1938.py -x -q(8 passed, GPU test skipped without cupy)pytest xrspatial/geotiff/tests/test_writer.py xrspatial/geotiff/tests/test_writer_matrix.py xrspatial/geotiff/tests/test_signature_parity_1631.py xrspatial/geotiff/tests/test_signature_annotations_1654.py xrspatial/geotiff/tests/test_signature_annotations_1705.py xrspatial/geotiff/tests/test_to_geotiff_allow_internal_only_jpeg_parity.py xrspatial/geotiff/tests/test_vrt_write.py xrspatial/geotiff/tests/test_streaming_write.py -q(176 passed)