@@ -42,7 +42,7 @@ from pandas._typing import (
42
42
43
43
class Properties (PandasDelegate , NoNewAttributesMixin ): ...
44
44
45
- _DTFieldOpsReturnType = TypeVar ("_DTFieldOpsReturnType" , Series [int ], Index [int ])
45
+ _DTFieldOpsReturnType = TypeVar ("_DTFieldOpsReturnType" , bound = Series [int ] | Index [int ])
46
46
47
47
class _DayLikeFieldOps (Generic [_DTFieldOpsReturnType ]):
48
48
@property
@@ -84,7 +84,9 @@ class _DatetimeFieldOps(
84
84
_DayLikeFieldOps [_DTFieldOpsReturnType ], _MiniSeconds [_DTFieldOpsReturnType ]
85
85
): ...
86
86
87
- _DTBoolOpsReturnType = TypeVar ("_DTBoolOpsReturnType" , Series [bool ], np_ndarray_bool )
87
+ _DTBoolOpsReturnType = TypeVar (
88
+ "_DTBoolOpsReturnType" , bound = Series [bool ] | np_ndarray_bool
89
+ )
88
90
89
91
class _IsLeapYearProperty (Generic [_DTBoolOpsReturnType ]):
90
92
@property
@@ -106,7 +108,7 @@ class _DatetimeBoolOps(
106
108
@property
107
109
def is_year_end (self ) -> _DTBoolOpsReturnType : ...
108
110
109
- _DTFreqReturnType = TypeVar ("_DTFreqReturnType" , str , BaseOffset )
111
+ _DTFreqReturnType = TypeVar ("_DTFreqReturnType" , bound = str | BaseOffset )
110
112
111
113
class _FreqProperty (Generic [_DTFreqReturnType ]):
112
114
@property
@@ -121,10 +123,10 @@ class _DatetimeObjectOps(
121
123
): ...
122
124
123
125
_DTOtherOpsDateReturnType = TypeVar (
124
- "_DTOtherOpsDateReturnType" , Series [dt .date ], np .ndarray
126
+ "_DTOtherOpsDateReturnType" , bound = Series [dt .date ] | np .ndarray
125
127
)
126
128
_DTOtherOpsTimeReturnType = TypeVar (
127
- "_DTOtherOpsTimeReturnType" , Series [dt .time ], np .ndarray
129
+ "_DTOtherOpsTimeReturnType" , bound = Series [dt .time ] | np .ndarray
128
130
)
129
131
130
132
class _DatetimeOtherOps (Generic [_DTOtherOpsDateReturnType , _DTOtherOpsTimeReturnType ]):
@@ -157,11 +159,7 @@ class _DatetimeLikeOps(
157
159
158
160
_DTTimestampTimedeltaReturnType = TypeVar (
159
161
"_DTTimestampTimedeltaReturnType" ,
160
- Series ,
161
- TimestampSeries ,
162
- TimedeltaSeries ,
163
- DatetimeIndex ,
164
- TimedeltaIndex ,
162
+ bound = Series | TimestampSeries | TimedeltaSeries | DatetimeIndex | TimedeltaIndex ,
165
163
)
166
164
167
165
class _DatetimeRoundingMethods (Generic [_DTTimestampTimedeltaReturnType ]):
@@ -199,8 +197,10 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
199
197
_DTNormalizeReturnType = TypeVar (
200
198
"_DTNormalizeReturnType" , TimestampSeries , DatetimeIndex
201
199
)
202
- _DTStrKindReturnType = TypeVar ("_DTStrKindReturnType" , Series [str ], Index )
203
- _DTToPeriodReturnType = TypeVar ("_DTToPeriodReturnType" , PeriodSeries , PeriodIndex )
200
+ _DTStrKindReturnType = TypeVar ("_DTStrKindReturnType" , bound = Series [str ] | Index )
201
+ _DTToPeriodReturnType = TypeVar (
202
+ "_DTToPeriodReturnType" , bound = PeriodSeries | PeriodIndex
203
+ )
204
204
205
205
class _DatetimeLikeNoTZMethods (
206
206
_DatetimeRoundingMethods [_DTTimestampTimedeltaReturnType ],
@@ -289,9 +289,11 @@ class DatetimeProperties(
289
289
def as_unit (self , unit : TimeUnit ) -> _DTTimestampTimedeltaReturnType : ...
290
290
291
291
_TDNoRoundingMethodReturnType = TypeVar (
292
- "_TDNoRoundingMethodReturnType" , Series [int ], Index
292
+ "_TDNoRoundingMethodReturnType" , bound = Series [int ] | Index
293
+ )
294
+ _TDTotalSecondsReturnType = TypeVar (
295
+ "_TDTotalSecondsReturnType" , bound = Series [float ] | Index
293
296
)
294
- _TDTotalSecondsReturnType = TypeVar ("_TDTotalSecondsReturnType" , Series [float ], Index )
295
297
296
298
class _TimedeltaPropertiesNoRounding (
297
299
Generic [_TDNoRoundingMethodReturnType , _TDTotalSecondsReturnType ]
@@ -318,11 +320,15 @@ class TimedeltaProperties(
318
320
def unit (self ) -> TimeUnit : ...
319
321
def as_unit (self , unit : TimeUnit ) -> TimedeltaSeries : ...
320
322
321
- _PeriodDTReturnTypes = TypeVar ("_PeriodDTReturnTypes" , TimestampSeries , DatetimeIndex )
322
- _PeriodIntReturnTypes = TypeVar ("_PeriodIntReturnTypes" , Series [int ], Index [int ])
323
- _PeriodStrReturnTypes = TypeVar ("_PeriodStrReturnTypes" , Series [str ], Index )
324
- _PeriodDTAReturnTypes = TypeVar ("_PeriodDTAReturnTypes" , DatetimeArray , DatetimeIndex )
325
- _PeriodPAReturnTypes = TypeVar ("_PeriodPAReturnTypes" , PeriodArray , PeriodIndex )
323
+ _PeriodDTReturnTypes = TypeVar (
324
+ "_PeriodDTReturnTypes" , bound = TimestampSeries | DatetimeIndex
325
+ )
326
+ _PeriodIntReturnTypes = TypeVar ("_PeriodIntReturnTypes" , bound = Series [int ] | Index [int ])
327
+ _PeriodStrReturnTypes = TypeVar ("_PeriodStrReturnTypes" , bound = Series [str ] | Index )
328
+ _PeriodDTAReturnTypes = TypeVar (
329
+ "_PeriodDTAReturnTypes" , bound = DatetimeArray | DatetimeIndex
330
+ )
331
+ _PeriodPAReturnTypes = TypeVar ("_PeriodPAReturnTypes" , bound = PeriodArray | PeriodIndex )
326
332
327
333
class _PeriodProperties (
328
334
Generic [
0 commit comments