Skip to content

Commit 24deb37

Browse files
committed
index
1 parent cf7e941 commit 24deb37

File tree

10 files changed

+110
-123
lines changed

10 files changed

+110
-123
lines changed

pandas-stubs/core/base.pyi

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ from pandas._typing import (
4343
Scalar,
4444
SupportsDType,
4545
np_1darray,
46-
np_ndarray,
4746
np_ndarray_anyint,
4847
np_ndarray_bool,
4948
np_ndarray_complex,
@@ -181,7 +180,7 @@ ScalarArrayIndexJustInt: TypeAlias = (
181180
| IntegerArray
182181
| Index[int]
183182
)
184-
ScalarArraySeriesJustInt: TypeAlias = ScalarArrayIndexJustInt | Series[int]
183+
ScalarArrayIndexSeriesJustInt: TypeAlias = ScalarArrayIndexJustInt | Series[int]
185184
ScalarArrayIndexJustFloat: TypeAlias = (
186185
Just[float]
187186
| np.floating
@@ -190,15 +189,17 @@ ScalarArrayIndexJustFloat: TypeAlias = (
190189
# | FloatingArray # TODO: after pandas-dev/pandas-stubs#1469
191190
| Index[float]
192191
)
193-
ScalarArraySeriesJustFloat: TypeAlias = ScalarArrayIndexJustFloat | Series[float]
192+
ScalarArrayIndexSeriesJustFloat: TypeAlias = ScalarArrayIndexJustFloat | Series[float]
194193
ScalarArrayIndexJustComplex: TypeAlias = (
195194
Just[complex]
196195
| np.complexfloating
197196
| Sequence[Just[complex] | np.complexfloating]
198197
| np_ndarray_complex
199198
| Index[complex]
200199
)
201-
ScalarArraySeriesJustComplex: TypeAlias = ScalarArrayIndexJustComplex | Series[complex]
200+
ScalarArrayIndexSeriesJustComplex: TypeAlias = (
201+
ScalarArrayIndexJustComplex | Series[complex]
202+
)
202203

203204
ScalarArrayIndexIntNoBool: TypeAlias = (
204205
Just[int]
@@ -208,15 +209,15 @@ ScalarArrayIndexIntNoBool: TypeAlias = (
208209
| IntegerArray
209210
| Index[int]
210211
)
211-
ScalarArraySeriesIntNoBool: TypeAlias = ScalarArrayIndexIntNoBool | Series[int]
212+
ScalarArrayIndexSeriesIntNoBool: TypeAlias = ScalarArrayIndexIntNoBool | Series[int]
212213

213214
NumpyRealScalar: TypeAlias = np.bool | np.integer | np.floating
214215
IndexReal: TypeAlias = Index[bool] | Index[int] | Index[float]
215216
ScalarArrayIndexReal: TypeAlias = (
216217
float
217218
| Sequence[float | NumpyRealScalar]
218219
| NumpyRealScalar
219-
| np_ndarray[tuple[int, ...], NumpyRealScalar]
220+
| np.typing.NDArray[NumpyRealScalar]
220221
| ExtensionArray
221222
| IndexReal
222223
)
@@ -229,7 +230,7 @@ ScalarArrayIndexComplex: TypeAlias = (
229230
complex
230231
| Sequence[complex | NumpyComplexScalar]
231232
| NumpyComplexScalar
232-
| np_ndarray[tuple[int, ...], NumpyComplexScalar]
233+
| np.typing.NDArray[NumpyComplexScalar]
233234
| ExtensionArray
234235
| IndexComplex
235236
)

pandas-stubs/core/indexes/base.pyi

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ from _typeshed import (
3131
import numpy as np
3232
from pandas.core.arrays.boolean import BooleanArray
3333
from pandas.core.base import (
34+
ArrayIndexTimedeltaNoSeq,
3435
ElementOpsMixin,
36+
IndexComplex,
3537
IndexOpsMixin,
38+
IndexReal,
39+
ScalarArrayIndexComplex,
40+
ScalarArrayIndexIntNoBool,
41+
ScalarArrayIndexJustComplex,
42+
ScalarArrayIndexJustFloat,
3643
ScalarArrayIndexReal,
44+
ScalarArrayIndexTimedelta,
3745
Supports_ProtoAdd,
3846
Supports_ProtoFloorDiv,
3947
Supports_ProtoMul,
@@ -939,17 +947,19 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
939947
self: Index[T_COMPLEX], other: np_ndarray_complex | Index[complex]
940948
) -> Index[complex]: ...
941949
@overload
942-
def __truediv__(
943-
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
950+
def __truediv__(self, other: np_ndarray_dt) -> Never: ...
951+
@overload
952+
def __truediv__( # type: ignore[overload-overlap]
953+
self: Index[Never], other: ScalarArrayIndexComplex
944954
) -> Index: ...
945955
@overload
946-
def __truediv__(self, other: Index[Never]) -> Index: ...
956+
def __truediv__(self: Index[Never], other: ArrayIndexTimedeltaNoSeq) -> Never: ...
947957
@overload
948-
def __truediv__(self: Index[bool], other: np_ndarray_bool) -> Never: ...
958+
def __truediv__(self: Index[T_COMPLEX], other: np_ndarray_td) -> Never: ...
949959
@overload
950-
def __truediv__(self, other: np_ndarray_dt) -> Never: ...
960+
def __truediv__(self: Index[bool], other: np_ndarray_bool) -> Never: ...
951961
@overload
952-
def __truediv__(self: Index[T_COMPLEX], other: np_ndarray_td) -> Never: ...
962+
def __truediv__(self: IndexComplex, other: Index[Never]) -> Index: ...
953963
@overload
954964
def __truediv__(
955965
self: Supports_ProtoTrueDiv[_T_contra, S2],
@@ -961,8 +971,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
961971
) -> Index[float]: ...
962972
@overload
963973
def __truediv__(
964-
self: Index[bool] | Index[int],
965-
other: Just[int] | Sequence[int] | np_ndarray_anyint | Index[int],
974+
self: Index[bool] | Index[int], other: ScalarArrayIndexIntNoBool
966975
) -> Index[float]: ...
967976
@overload
968977
def __truediv__(
@@ -976,36 +985,32 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
976985
) -> Index[complex]: ...
977986
@overload
978987
def __truediv__(
979-
self: Index[bool] | Index[int],
980-
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
988+
self: Index[bool] | Index[int], other: ScalarArrayIndexJustFloat
981989
) -> Index[float]: ...
982990
@overload
983991
def __truediv__(
984-
self: Index[T_COMPLEX],
985-
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
992+
self: Index[T_COMPLEX], other: ScalarArrayIndexJustFloat
986993
) -> Index[T_COMPLEX]: ...
987994
@overload
988995
def __truediv__(
989-
self: Index[T_COMPLEX],
990-
other: (
991-
Just[complex]
992-
| Sequence[Just[complex]]
993-
| np_ndarray_complex
994-
| Index[complex]
995-
),
996+
self: IndexComplex, other: ScalarArrayIndexJustComplex
996997
) -> Index[complex]: ...
997998
@overload
998-
def __truediv__(self, other: Path) -> Index: ...
999+
def __truediv__(self: Index[_str], other: Path) -> Index: ...
9991000
@overload
1000-
def __rtruediv__(
1001-
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
1002-
) -> Index: ...
1001+
def __rtruediv__(self, other: np_ndarray_dt) -> Never: ...
10031002
@overload
1004-
def __rtruediv__(self, other: Index[Never]) -> Index: ... # type: ignore[overload-overlap]
1003+
def __rtruediv__( # type: ignore[overload-overlap]
1004+
self: Index[Never], other: ScalarArrayIndexComplex | ScalarArrayIndexTimedelta
1005+
) -> Index: ...
10051006
@overload
1006-
def __rtruediv__(self: Index[bool], other: np_ndarray_bool) -> Never: ...
1007+
def __rtruediv__( # type: ignore[overload-overlap]
1008+
self: IndexComplex, other: Index[Never]
1009+
) -> Index: ...
10071010
@overload
1008-
def __rtruediv__(self, other: np_ndarray_dt) -> Never: ...
1011+
def __rtruediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
1012+
self: Index[int] | Index[float], other: Sequence[timedelta | np.timedelta64]
1013+
) -> Index: ...
10091014
@overload
10101015
def __rtruediv__(
10111016
self: Supports_ProtoRTrueDiv[_T_contra, S2],
@@ -1017,8 +1022,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
10171022
) -> Index[float]: ...
10181023
@overload
10191024
def __rtruediv__(
1020-
self: Index[bool] | Index[int],
1021-
other: Just[int] | Sequence[int] | np_ndarray_anyint | Index[int],
1025+
self: Index[bool] | Index[int], other: ScalarArrayIndexIntNoBool
10221026
) -> Index[float]: ...
10231027
@overload
10241028
def __rtruediv__( # type: ignore[misc]
@@ -1032,43 +1036,35 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
10321036
) -> Index[complex]: ...
10331037
@overload
10341038
def __rtruediv__(
1035-
self: Index[bool] | Index[int],
1036-
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
1039+
self: Index[bool] | Index[int], other: ScalarArrayIndexJustFloat
10371040
) -> Index[float]: ...
10381041
@overload
10391042
def __rtruediv__(
1040-
self: Index[T_COMPLEX],
1041-
other: Just[float] | Sequence[Just[float]] | np_ndarray_float | Index[float],
1043+
self: Index[T_COMPLEX], other: ScalarArrayIndexJustFloat
10421044
) -> Index[T_COMPLEX]: ...
10431045
@overload
10441046
def __rtruediv__(
1045-
self: Index[T_COMPLEX],
1046-
other: (
1047-
Just[complex]
1048-
| Sequence[Just[complex]]
1049-
| np_ndarray_complex
1050-
| Index[complex]
1051-
),
1047+
self: IndexComplex, other: ScalarArrayIndexJustComplex
10521048
) -> Index[complex]: ...
10531049
@overload
10541050
def __rtruediv__(
1055-
self: Index[int] | Index[float],
1056-
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaIndex,
1051+
self: Index[int] | Index[float], other: ScalarArrayIndexTimedelta
10571052
) -> TimedeltaIndex: ...
10581053
@overload
1059-
def __rtruediv__(self, other: Path) -> Index: ...
1054+
def __rtruediv__(self: Index[_str], other: Path) -> Index: ...
10601055
@overload
1061-
def __floordiv__(self: Index[Never], other: ScalarArrayIndexReal) -> Index: ...
1056+
def __floordiv__(self, other: np_ndarray_dt) -> Never: ...
10621057
@overload
1063-
def __floordiv__(
1064-
self: Index[bool] | Index[int] | Index[float], other: Index[Never]
1065-
) -> Index: ...
1058+
def __floordiv__(self: Index[Never], other: np_ndarray_td) -> Never: ...
10661059
@overload
10671060
def __floordiv__(
1068-
self: Index[int] | Index[float],
1069-
other: np_ndarray_complex | np_ndarray_dt | np_ndarray_td,
1061+
self: Index[int] | Index[float], other: np_ndarray_complex | np_ndarray_td
10701062
) -> Never: ...
10711063
@overload
1064+
def __floordiv__(self: Index[Never], other: ScalarArrayIndexReal) -> Index: ...
1065+
@overload
1066+
def __floordiv__(self: IndexReal, other: Index[Never]) -> Index: ...
1067+
@overload
10721068
def __floordiv__(
10731069
self: Index[bool] | Index[complex], other: np_ndarray
10741070
) -> Never: ...
@@ -1099,21 +1095,24 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
10991095
other: float | Sequence[float] | np_ndarray_float | Index[float],
11001096
) -> Index[float]: ...
11011097
@overload
1102-
def __rfloordiv__(self: Index[Never], other: ScalarArrayIndexReal) -> Index: ...
1103-
@overload
11041098
def __rfloordiv__( # type: ignore[overload-overlap]
1105-
self: Index[bool] | Index[int] | Index[float], other: Index[Never]
1099+
self: Index[Never], other: ScalarArrayIndexReal
11061100
) -> Index: ...
11071101
@overload
1102+
def __rfloordiv__(self, other: np_ndarray_complex | np_ndarray_dt) -> Never: ...
1103+
@overload
11081104
def __rfloordiv__(
1109-
self: Index[int] | Index[float],
1110-
other: np_ndarray_complex | np_ndarray_dt | np_ndarray_td,
1105+
self: Index[int] | Index[float], other: np_ndarray_td
11111106
) -> Never: ...
11121107
@overload
11131108
def __rfloordiv__(
11141109
self: Index[bool] | Index[complex], other: np_ndarray
11151110
) -> Never: ...
11161111
@overload
1112+
def __rfloordiv__( # type: ignore[overload-overlap]
1113+
self: IndexReal, other: Index[Never]
1114+
) -> Index: ...
1115+
@overload
11171116
def __rfloordiv__(
11181117
self: Supports_ProtoRFloorDiv[_T_contra, S2],
11191118
other: _T_contra | Sequence[_T_contra],
@@ -1142,8 +1141,12 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
11421141
@overload
11431142
def __rfloordiv__(
11441143
self: Index[int] | Index[float],
1145-
other: timedelta | np_ndarray_td | TimedeltaIndex,
1144+
other: timedelta | np.timedelta64 | ArrayIndexTimedeltaNoSeq,
11461145
) -> TimedeltaIndex: ...
1146+
@overload
1147+
def __rfloordiv__(
1148+
self: Index[int] | Index[float], other: Sequence[timedelta | np.timedelta64]
1149+
) -> Index: ...
11471150
def infer_objects(self, copy: bool = True) -> Self: ...
11481151

11491152
@type_check_only

pandas-stubs/core/indexes/datetimes.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ class DatetimeIndex(
7676
def __sub__( # pyright: ignore[reportIncompatibleMethodOverride]
7777
self, other: timedelta | np.timedelta64 | np_ndarray_td | BaseOffset
7878
) -> Self: ...
79-
def __truediv__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore[bad-override]
79+
def __truediv__( # type: ignore[override] # pyrefly: ignore[bad-override]
8080
self, other: np_ndarray
8181
) -> Never: ...
82-
def __rtruediv__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] # pyrefly: ignore[bad-override]
82+
def __rtruediv__( # type: ignore[override] # pyrefly: ignore[bad-override]
8383
self, other: np_ndarray
8484
) -> Never: ...
8585
@final

pandas-stubs/core/indexes/timedeltas.pyi

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from pandas._typing import (
3838
np_ndarray_complex,
3939
np_ndarray_dt,
4040
np_ndarray_float,
41+
np_ndarray_num,
4142
np_ndarray_td,
4243
)
4344

@@ -106,6 +107,10 @@ class TimedeltaIndex(
106107
@overload
107108
def __rmul__(self, other: _NUM_FACTOR_SEQ) -> Self: ...
108109
@overload # type: ignore[override]
110+
def __truediv__( # type: ignore[overload-overlap]
111+
self, other: Index[Never]
112+
) -> Index: ...
113+
@overload
109114
def __truediv__( # pyrefly: ignore[bad-override]
110115
self, other: np_ndarray_bool | np_ndarray_complex | np_ndarray_dt
111116
) -> Never: ...
@@ -135,14 +140,7 @@ class TimedeltaIndex(
135140
) -> Index[int]: ...
136141
@overload
137142
def __rfloordiv__( # pyrefly: ignore[bad-override]
138-
self,
139-
other: (
140-
np_ndarray_bool
141-
| np_ndarray_anyint
142-
| np_ndarray_float
143-
| np_ndarray_complex
144-
| np_ndarray_dt
145-
),
143+
self, other: np_ndarray_num | np_ndarray_dt
146144
) -> Never: ...
147145
@overload
148146
def __rfloordiv__( # pyright: ignore[reportIncompatibleMethodOverride]

0 commit comments

Comments
 (0)