diff --git a/xarray/coding/cftime_offsets.py b/xarray/coding/cftime_offsets.py index 90478dffe2d..9dbc60ef0f3 100644 --- a/xarray/coding/cftime_offsets.py +++ b/xarray/coding/cftime_offsets.py @@ -112,8 +112,8 @@ def get_date_type(calendar, use_cftime=True): class BaseCFTimeOffset: - _freq: ClassVar[str] - _day_option: ClassVar[DayOption] + _freq: ClassVar[str | None] = None + _day_option: ClassVar[DayOption | None] = None n: int def __init__(self, n: int = 1) -> None: @@ -124,7 +124,7 @@ def __init__(self, n: int = 1) -> None: ) self.n = n - def rule_code(self) -> str: + def rule_code(self) -> str | None: return self._freq def __eq__(self, other: object) -> bool: diff --git a/xarray/tests/test_cftime_offsets.py b/xarray/tests/test_cftime_offsets.py index eabb7d2f4d6..78aa49c7f83 100644 --- a/xarray/tests/test_cftime_offsets.py +++ b/xarray/tests/test_cftime_offsets.py @@ -511,7 +511,7 @@ def test_Microsecond_multiplied_float_error(): ], ids=_id_func, ) -def test_neg(offset, expected): +def test_neg(offset: BaseCFTimeOffset, expected: BaseCFTimeOffset) -> None: assert -offset == expected