@@ -42,7 +42,7 @@ from pandas._typing import (
4242
4343class Properties (PandasDelegate , NoNewAttributesMixin ): ...
4444
45- _DTFieldOpsReturnType = TypeVar ("_DTFieldOpsReturnType" , Series [int ], Index [int ])
45+ _DTFieldOpsReturnType = TypeVar ("_DTFieldOpsReturnType" , bound = Series [int ] | Index [int ])
4646
4747class _DayLikeFieldOps (Generic [_DTFieldOpsReturnType ]):
4848 @property
@@ -84,7 +84,9 @@ class _DatetimeFieldOps(
8484 _DayLikeFieldOps [_DTFieldOpsReturnType ], _MiniSeconds [_DTFieldOpsReturnType ]
8585): ...
8686
87- _DTBoolOpsReturnType = TypeVar ("_DTBoolOpsReturnType" , Series [bool ], np_ndarray_bool )
87+ _DTBoolOpsReturnType = TypeVar (
88+ "_DTBoolOpsReturnType" , bound = Series [bool ] | np_ndarray_bool
89+ )
8890
8991class _IsLeapYearProperty (Generic [_DTBoolOpsReturnType ]):
9092 @property
@@ -106,7 +108,7 @@ class _DatetimeBoolOps(
106108 @property
107109 def is_year_end (self ) -> _DTBoolOpsReturnType : ...
108110
109- _DTFreqReturnType = TypeVar ("_DTFreqReturnType" , str , BaseOffset )
111+ _DTFreqReturnType = TypeVar ("_DTFreqReturnType" , bound = str | BaseOffset )
110112
111113class _FreqProperty (Generic [_DTFreqReturnType ]):
112114 @property
@@ -121,10 +123,10 @@ class _DatetimeObjectOps(
121123): ...
122124
123125_DTOtherOpsDateReturnType = TypeVar (
124- "_DTOtherOpsDateReturnType" , Series [dt .date ], np .ndarray
126+ "_DTOtherOpsDateReturnType" , bound = Series [dt .date ] | np .ndarray
125127)
126128_DTOtherOpsTimeReturnType = TypeVar (
127- "_DTOtherOpsTimeReturnType" , Series [dt .time ], np .ndarray
129+ "_DTOtherOpsTimeReturnType" , bound = Series [dt .time ] | np .ndarray
128130)
129131
130132class _DatetimeOtherOps (Generic [_DTOtherOpsDateReturnType , _DTOtherOpsTimeReturnType ]):
@@ -157,11 +159,7 @@ class _DatetimeLikeOps(
157159
158160_DTTimestampTimedeltaReturnType = TypeVar (
159161 "_DTTimestampTimedeltaReturnType" ,
160- Series ,
161- TimestampSeries ,
162- TimedeltaSeries ,
163- DatetimeIndex ,
164- TimedeltaIndex ,
162+ bound = Series | TimestampSeries | TimedeltaSeries | DatetimeIndex | TimedeltaIndex ,
165163)
166164
167165class _DatetimeRoundingMethods (Generic [_DTTimestampTimedeltaReturnType ]):
@@ -199,8 +197,10 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
199197_DTNormalizeReturnType = TypeVar (
200198 "_DTNormalizeReturnType" , TimestampSeries , DatetimeIndex
201199)
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+ )
204204
205205class _DatetimeLikeNoTZMethods (
206206 _DatetimeRoundingMethods [_DTTimestampTimedeltaReturnType ],
@@ -289,9 +289,11 @@ class DatetimeProperties(
289289 def as_unit (self , unit : TimeUnit ) -> _DTTimestampTimedeltaReturnType : ...
290290
291291_TDNoRoundingMethodReturnType = TypeVar (
292- "_TDNoRoundingMethodReturnType" , Series [int ], Index
292+ "_TDNoRoundingMethodReturnType" , bound = Series [int ] | Index
293+ )
294+ _TDTotalSecondsReturnType = TypeVar (
295+ "_TDTotalSecondsReturnType" , bound = Series [float ] | Index
293296)
294- _TDTotalSecondsReturnType = TypeVar ("_TDTotalSecondsReturnType" , Series [float ], Index )
295297
296298class _TimedeltaPropertiesNoRounding (
297299 Generic [_TDNoRoundingMethodReturnType , _TDTotalSecondsReturnType ]
@@ -318,11 +320,15 @@ class TimedeltaProperties(
318320 def unit (self ) -> TimeUnit : ...
319321 def as_unit (self , unit : TimeUnit ) -> TimedeltaSeries : ...
320322
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 )
326332
327333class _PeriodProperties (
328334 Generic [
0 commit comments