4343
4444import re
4545from datetime import datetime , timedelta
46- from enum import Enum
4746from functools import partial
48- from typing import TYPE_CHECKING , ClassVar , Literal
47+ from typing import TYPE_CHECKING , ClassVar
4948
5049import numpy as np
5150import pandas as pd
5857 format_cftime_datetime ,
5958)
6059from xarray .core .common import _contains_datetime_like_objects , is_np_datetime_like
61- from xarray .core .pdcompat import count_not_none
60+ from xarray .core .pdcompat import NoDefault , count_not_none , no_default
6261from xarray .core .utils import emit_user_level_warning
6362
6463try :
@@ -855,29 +854,6 @@ def _generate_range(start, end, periods, offset):
855854 current = next_date
856855
857856
858- class _NoDefault (Enum ):
859- """Used by pandas to specify a default value for a deprecated argument.
860- Copied from pandas._libs.lib._NoDefault.
861-
862- See also:
863- - pandas-dev/pandas#30788
864- - pandas-dev/pandas#40684
865- - pandas-dev/pandas#40715
866- - pandas-dev/pandas#47045
867- """
868-
869- no_default = "NO_DEFAULT"
870-
871- def __repr__ (self ) -> str :
872- return "<no_default>"
873-
874-
875- no_default = (
876- _NoDefault .no_default
877- ) # Sentinel indicating the default value following pandas
878- NoDefault = Literal [_NoDefault .no_default ] # For typing following pandas
879-
880-
881857def _translate_closed_to_inclusive (closed ):
882858 """Follows code added in pandas #43504."""
883859 emit_user_level_warning (
@@ -939,12 +915,11 @@ def cftime_range(
939915 Normalize start/end dates to midnight before generating date range.
940916 name : str, default: None
941917 Name of the resulting index
942- closed : {"left", "right"} or None , default: "NO_DEFAULT"
918+ closed : {None, "left", "right"}, default: "NO_DEFAULT"
943919 Make the interval closed with respect to the given frequency to the
944920 "left", "right", or both sides (None).
945921
946922 .. deprecated:: 2023.01.1
947-
948923 Following pandas, the ``closed`` parameter is deprecated in favor
949924 of the ``inclusive`` parameter, and will be removed in a future
950925 version of xarray.
@@ -968,6 +943,7 @@ def cftime_range(
968943 features of ``pandas.date_range`` (e.g. specifying how the index is
969944 ``closed`` on either side, or whether or not to ``normalize`` the start and
970945 end bounds); however, there are some notable exceptions:
946+
971947 - You cannot specify a ``tz`` (time zone) argument.
972948 - Start or end dates specified as partial-datetime strings must use the
973949 `ISO-8601 format <https://en.wikipedia.org/wiki/ISO_8601>`_.
@@ -1186,18 +1162,20 @@ def date_range(
11861162 Normalize start/end dates to midnight before generating date range.
11871163 name : str, default: None
11881164 Name of the resulting index
1189- closed : {"left", "right"} or None , default: "NO_DEFAULT"
1165+ closed : {None, "left", "right"}, default: "NO_DEFAULT"
11901166 Make the interval closed with respect to the given frequency to the
11911167 "left", "right", or both sides (None).
11921168
11931169 .. deprecated:: 2023.01.1
11941170 Following pandas, the `closed` parameter is deprecated in favor
11951171 of the `inclusive` parameter, and will be removed in a future
11961172 version of xarray.
1197- inclusive : {None, "both", "neither", "left", "right"}, default None
1173+
1174+ inclusive : {None, "both", "neither", "left", "right"}, default: None
11981175 Include boundaries; whether to set each bound as closed or open.
11991176
12001177 .. versionadded:: 2023.01.1
1178+
12011179 calendar : str, default: "standard"
12021180 Calendar type for the datetimes.
12031181 use_cftime : boolean, optional
0 commit comments