Skip to content

Commit 445ba91

Browse files
committed
fix typing
1 parent cddfeec commit 445ba91

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

xarray/coding/variables.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def _choose_float_dtype(dtype: np.dtype, has_offset: bool) -> type[np.floating[A
319319

320320

321321
def _ensure_scale_offset_conformance(
322-
mapping: MutableMapping, strict: bool = False
322+
mapping: MutableMapping[str, Any], strict: bool = False
323323
) -> bool | None:
324324
"""Check conformance of scale_factor and add_offset for cf encoding/decoding.
325325
@@ -365,12 +365,10 @@ def _ensure_scale_offset_conformance(
365365
if len(scale_offset_dtype) == 1:
366366
# OK, we have at least one of scale_factor or add_offset
367367
# and if both are given, they are of the same dtype
368-
scale_offset_dtype = scale_offset_dtype[0]
369-
370-
if scale_offset_dtype != ptype:
371-
if scale_offset_dtype not in [np.float32, np.float64]:
368+
if scale_offset_dtype[0] != ptype:
369+
if scale_offset_dtype[0] not in [np.float32, np.float64]:
372370
msg = (
373-
f"scale_factor and/or add_offset dtype {scale_offset_dtype} "
371+
f"scale_factor and/or add_offset dtype {scale_offset_dtype[0]} "
374372
"mismatch. Must be either float32 or float64 dtype."
375373
)
376374
if strict:
@@ -389,7 +387,7 @@ def _ensure_scale_offset_conformance(
389387
else:
390388
warnings.warn(msg, SerializationWarning, stacklevel=3)
391389
conforms = False
392-
if ptype == np.int32 and scale_offset_dtype == np.float32:
390+
if ptype == np.int32 and scale_offset_dtype[0] == np.float32:
393391
warnings.warn(
394392
"Trying to pack float32 into int32. This is not advised per CF Convention "
395393
"because of potential precision loss!",

0 commit comments

Comments
 (0)