All three documented writer entry points live next to each other in xrspatial.geotiff's public API, but their return types drift:
| function |
declared return |
to_geotiff |
None |
write_geotiff_gpu |
None |
write_vrt |
str (the path written) |
write_vrt returning the path is intentional (callers may have passed an auto-generated name and want it back), but the drift breaks mypy consumers who handle the three writers uniformly, and makes the Sphinx docs surface inconsistent.
Fix: make all three return str (the path they wrote to). The change is additive for to_geotiff and write_geotiff_gpu since existing callers discarded the None return. write_vrt's existing str contract is preserved.
When the writer was passed a file-like (io.BytesIO) rather than a path, return its getattr(path, 'name', None) or repr as best-effort, or fall back to None and document it. The exact rule lands in the PR.
Scope:
xrspatial/geotiff/_writers/eager.py: to_geotiff
xrspatial/geotiff/_writers/gpu.py: write_geotiff_gpu
xrspatial/geotiff/_writers/vrt.py: write_vrt (already returns str; covered by the regression test)
- New regression test under
xrspatial/geotiff/tests/
All three documented writer entry points live next to each other in
xrspatial.geotiff's public API, but their return types drift:to_geotiffNonewrite_geotiff_gpuNonewrite_vrtstr(the path written)write_vrtreturning the path is intentional (callers may have passed an auto-generated name and want it back), but the drift breaksmypyconsumers who handle the three writers uniformly, and makes the Sphinx docs surface inconsistent.Fix: make all three return
str(the path they wrote to). The change is additive forto_geotiffandwrite_geotiff_gpusince existing callers discarded theNonereturn.write_vrt's existingstrcontract is preserved.When the writer was passed a file-like (
io.BytesIO) rather than a path, return itsgetattr(path, 'name', None)orrepras best-effort, or fall back toNoneand document it. The exact rule lands in the PR.Scope:
xrspatial/geotiff/_writers/eager.py:to_geotiffxrspatial/geotiff/_writers/gpu.py:write_geotiff_gpuxrspatial/geotiff/_writers/vrt.py:write_vrt(already returnsstr; covered by the regression test)xrspatial/geotiff/tests/