Skip to content

Commit 60bc816

Browse files
authored
Guard typing_extension import (#10413)
1 parent f1a2c08 commit 60bc816

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xarray/core/accessor_dt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import numpy as np
77
import pandas as pd
8-
from typing_extensions import Self
98

109
from xarray.coding.calendar_ops import _decimal_year
1110
from xarray.coding.times import infer_calendar_name
@@ -21,12 +20,19 @@
2120
from xarray.namedarray.utils import is_duck_dask_array
2221

2322
if TYPE_CHECKING:
23+
import sys
24+
2425
from numpy.typing import DTypeLike
2526

2627
from xarray.core.dataarray import DataArray
2728
from xarray.core.dataset import Dataset
2829
from xarray.core.types import CFCalendar
2930

31+
if sys.version_info >= (3, 11):
32+
from typing import Self
33+
else:
34+
from typing_extensions import Self
35+
3036

3137
def _season_from_months(months):
3238
"""Compute season (DJF, MAM, JJA, SON) from month ordinal"""

0 commit comments

Comments
 (0)