Skip to content

Commit bac439f

Browse files
committed
TimedeltaIndex
1 parent 4c6f81c commit bac439f

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

pandas-stubs/core/indexes/timedeltas.pyi

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ from collections.abc import (
55
import datetime as dt
66
from typing import (
77
Literal,
8+
TypeAlias,
89
final,
910
overload,
1011
)
1112

1213
import numpy as np
13-
from pandas import (
14-
Index,
15-
Period,
16-
)
1714
from pandas.core.indexes.accessors import TimedeltaIndexProperties
15+
from pandas.core.indexes.base import Index
1816
from pandas.core.indexes.datetimelike import DatetimeTimedeltaMixin
1917
from pandas.core.indexes.datetimes import DatetimeIndex
2018
from pandas.core.indexes.period import PeriodIndex
@@ -26,6 +24,7 @@ from typing_extensions import (
2624

2725
from pandas._libs import Timedelta
2826
from pandas._libs.tslibs import BaseOffset
27+
from pandas._libs.tslibs.period import Period
2928
from pandas._typing import (
3029
AxesData,
3130
Frequency,
@@ -40,6 +39,20 @@ from pandas._typing import (
4039
num,
4140
)
4241

42+
_NUM_FACTOR: TypeAlias = Just[int] | Just[float] | np.integer | np.floating
43+
_NUM_FACTORS: TypeAlias = (
44+
_NUM_FACTOR
45+
| Sequence[_NUM_FACTOR]
46+
| np_ndarray_anyint
47+
| np_ndarray_float
48+
| Index[int]
49+
| Index[float]
50+
)
51+
_DT_FACTOR: TypeAlias = dt.timedelta | np.timedelta64 | Timedelta
52+
_DT_FACTORS: TypeAlias = (
53+
_DT_FACTOR | Sequence[_DT_FACTOR] | np_ndarray_td | Index[Timedelta]
54+
)
55+
4356
class TimedeltaIndex(
4457
DatetimeTimedeltaMixin[Timedelta, np.timedelta64], TimedeltaIndexProperties
4558
):
@@ -89,43 +102,20 @@ class TimedeltaIndex(
89102
@overload # type: ignore[override]
90103
def __mul__(self, other: np_ndarray_bool | np_ndarray_complex) -> Never: ...
91104
@overload
92-
def __mul__(
93-
self,
94-
other: (
95-
Just[int]
96-
| Just[float]
97-
| Sequence[Just[int]]
98-
| Sequence[Just[float]]
99-
| np_ndarray_anyint
100-
| np_ndarray_float
101-
| Index[int]
102-
| Index[float]
103-
),
104-
) -> Self: ...
105+
def __mul__(self, other: _NUM_FACTORS) -> Self: ...
105106
@overload # type: ignore[override]
106107
def __rmul__(self, other: np_ndarray_bool | np_ndarray_complex) -> Never: ...
107108
@overload
108-
def __rmul__(
109-
self,
110-
other: (
111-
Just[int]
112-
| Just[float]
113-
| Sequence[Just[int]]
114-
| Sequence[Just[float]]
115-
| np_ndarray_anyint
116-
| np_ndarray_float
117-
| Index[int]
118-
| Index[float]
119-
),
120-
) -> Self: ...
109+
def __rmul__(self, other: _NUM_FACTORS) -> Self: ...
121110
@overload # type: ignore[override]
122-
# pyrefly: ignore # bad-override
123-
def __truediv__(self, other: float | Sequence[float]) -> Self: ...
111+
def __truediv__(self, other: _NUM_FACTORS) -> Self: ...
124112
@overload
125113
def __truediv__( # pyright: ignore[reportIncompatibleMethodOverride]
126-
self, other: dt.timedelta | Sequence[dt.timedelta]
114+
self, other: _DT_FACTORS | Self
115+
) -> Index[float]: ...
116+
def __rtruediv__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
117+
self, other: _DT_FACTORS | Self
127118
) -> Index[float]: ...
128-
def __rtruediv__(self, other: dt.timedelta | Sequence[dt.timedelta]) -> Index[float]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
129119
@overload # type: ignore[override]
130120
# pyrefly: ignore # bad-override
131121
def __floordiv__(self, other: num | Sequence[float]) -> Self: ...

0 commit comments

Comments
 (0)