Describe the bug
to_geotiff(arr, path, compression=None) raises a raw AttributeError: 'NoneType' object has no attribute 'lower' from _compression_tag (xrspatial/geotiff/_encode.py).
The compression parameter is typed and documented as str (default 'zstd'), so None was never a supported value. PR #2977 added a type guard at the public boundary that rejects non-string compression, but it exempts None to keep the same guard shape as the low-level writer, so None still falls through to the downstream .lower() call.
Reproduction
import numpy as np
from xrspatial.geotiff import to_geotiff
to_geotiff(np.ones((4, 4), dtype="float32"), "out.tif", compression=None)
# AttributeError: 'NoneType' object has no attribute 'lower'
Decision needed
This needs a small design call before fixing:
- Treat
None as an alias for the 'none' codec (no compression), or
- Reject
None at the public boundary with the same TypeError as other invalid types.
Either one is a few lines, but the choice affects the documented contract, which is why I'm splitting it out from the type-guard fix in #2977.
Context
Surfaced during review of #2977 (issue #2975).
Describe the bug
to_geotiff(arr, path, compression=None)raises a rawAttributeError: 'NoneType' object has no attribute 'lower'from_compression_tag(xrspatial/geotiff/_encode.py).The
compressionparameter is typed and documented asstr(default'zstd'), soNonewas never a supported value. PR #2977 added a type guard at the public boundary that rejects non-string compression, but it exemptsNoneto keep the same guard shape as the low-level writer, soNonestill falls through to the downstream.lower()call.Reproduction
Decision needed
This needs a small design call before fixing:
Noneas an alias for the'none'codec (no compression), orNoneat the public boundary with the sameTypeErroras other invalid types.Either one is a few lines, but the choice affects the documented contract, which is why I'm splitting it out from the type-guard fix in #2977.
Context
Surfaced during review of #2977 (issue #2975).