From 1126c9ba4533437ff2a4f163140c9a8e856f6deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Mon, 20 Jan 2025 07:41:05 +0100 Subject: [PATCH] cast type to PDDatetimeUnitOptions (#9963) --- xarray/coding/times.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xarray/coding/times.py b/xarray/coding/times.py index 0f9a7a48ef8..fd99a55a2a2 100644 --- a/xarray/coding/times.py +++ b/xarray/coding/times.py @@ -595,7 +595,9 @@ def _numbers_to_timedelta( # estimate fitting resolution for floating point values # this iterates until all floats are fractionless or time_unit == "ns" if flat_num.dtype.kind == "f" and time_unit != "ns": - flat_num, new_time_unit = _check_higher_resolution(flat_num, time_unit) + flat_num, new_time_unit = _check_higher_resolution( + flat_num, cast(PDDatetimeUnitOptions, time_unit) + ) if time_unit != new_time_unit: msg = ( f"Can't decode floating point {datatype} to {time_unit!r} without "