45
45
from datetime import datetime , timedelta
46
46
from enum import Enum
47
47
from functools import partial
48
- from typing import TYPE_CHECKING , ClassVar
48
+ from typing import TYPE_CHECKING , ClassVar , Literal
49
49
50
50
import numpy as np
51
51
import pandas as pd
@@ -866,6 +866,12 @@ def __repr__(self) -> str:
866
866
return "<no_default>"
867
867
868
868
869
+ no_default = (
870
+ _NoDefault .no_default
871
+ ) # Sentinel indicating the default value following pandas
872
+ NoDefault = Literal [_NoDefault .no_default ] # For typing following pandas
873
+
874
+
869
875
def _translate_closed_to_inclusive (closed ):
870
876
"""Follows code added in pandas #43504."""
871
877
emit_user_level_warning (
@@ -888,12 +894,12 @@ def _translate_closed_to_inclusive(closed):
888
894
889
895
def _infer_inclusive (closed , inclusive ):
890
896
"""Follows code added in pandas #43504."""
891
- if closed is not _NoDefault and inclusive is not None :
897
+ if closed is not no_default and inclusive is not None :
892
898
raise ValueError (
893
899
"Following pandas, deprecated argument `closed` cannot be "
894
900
"passed if argument `inclusive` is not None."
895
901
)
896
- if closed is not _NoDefault :
902
+ if closed is not no_default :
897
903
inclusive = _translate_closed_to_inclusive (closed )
898
904
elif inclusive is None :
899
905
inclusive = "both"
@@ -907,7 +913,7 @@ def cftime_range(
907
913
freq = "D" ,
908
914
normalize = False ,
909
915
name = None ,
910
- closed : _NoDefault | SideOptions = _NoDefault ,
916
+ closed : NoDefault | SideOptions = no_default ,
911
917
inclusive : None | InclusiveOptions = None ,
912
918
calendar = "standard" ,
913
919
):
@@ -1143,7 +1149,7 @@ def date_range(
1143
1149
tz = None ,
1144
1150
normalize = False ,
1145
1151
name = None ,
1146
- closed : _NoDefault | SideOptions = _NoDefault ,
1152
+ closed : NoDefault | SideOptions = no_default ,
1147
1153
inclusive : None | InclusiveOptions = None ,
1148
1154
calendar = "standard" ,
1149
1155
use_cftime = None ,
0 commit comments