Skip to content

Commit

Permalink
Fix mypy error
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerkclark authored Sep 7, 2024
1 parent 7649cb4 commit 50b69d9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xarray/coding/cftime_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from collections.abc import Mapping
from datetime import datetime, timedelta
from functools import partial
from typing import TYPE_CHECKING, ClassVar, Literal
from typing import TYPE_CHECKING, ClassVar, Literal, TypeVar

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -80,6 +80,7 @@


DayOption: TypeAlias = Literal["start", "end"]
T_FreqStr = TypeVar("T_FreqStr", str, None)


def _nanosecond_precision_timestamp(*args, **kwargs):
Expand Down Expand Up @@ -783,7 +784,7 @@ def to_offset(
if isinstance(freq, timedelta | pd.Timedelta):
return delta_to_tick(freq)
if isinstance(freq, pd.DateOffset):
freq = _legacy_to_new_freq(freq.freqstr)
freq = _new_freq(freq.freqstr)

match = re.match(_PATTERN, freq)
if match is None:
Expand Down Expand Up @@ -1367,7 +1368,7 @@ def _new_to_legacy_freq(freq):
return freq


def _legacy_to_new_freq(freq):
def _legacy_to_new_freq(freq: T_FreqStr) -> T_FreqStr:
# to avoid internal deprecation warnings when freq is determined using pandas < 2.2

# TODO: remove once requiring pandas >= 2.2
Expand Down

0 comments on commit 50b69d9

Please sign in to comment.