Skip to content

geotiff: writer return-type drift (to_geotiff/write_geotiff_gpu return None, write_vrt returns str) #1938

@brendancol

Description

@brendancol

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions