From 1145f4b2a8826c4232b1032d8936d8736d8fd5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Fri, 3 Jan 2025 09:57:29 +0100 Subject: [PATCH] fix typing --- xarray/coding/times.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xarray/coding/times.py b/xarray/coding/times.py index 12efeb4a762..41dc5dc2e1a 100644 --- a/xarray/coding/times.py +++ b/xarray/coding/times.py @@ -365,12 +365,14 @@ def _check_date_for_units_since_refdate( return pd.Timestamp("NaT") -def _align_reference_date_and_unit(ref_date: pd.Timestamp, unit: str) -> pd.Timestamp: +def _align_reference_date_and_unit( + ref_date: pd.Timestamp, unit: NPDatetimeUnitOptions +) -> pd.Timestamp: # align to the highest needed resolution of ref_date or unit if np.timedelta64(1, ref_date.unit) > np.timedelta64(1, unit): # this will raise accordingly # if data can't be represented in the higher resolution - return timestamp_as_unit(ref_date, unit) + return timestamp_as_unit(ref_date, cast(PDDatetimeUnitOptions, unit)) return ref_date