Skip to content

Commit 253e61a

Browse files
committed
Merge branch 'main' into hotfix/cmp0xff/gh718-drop-tss
2 parents 0a84cd0 + ffa88e5 commit 253e61a

34 files changed

+1210
-213
lines changed

pandas-stubs/_typing.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ MaskType: TypeAlias = Series[bool] | np_ndarray_bool | list[bool]
845845

846846
# Scratch types for generics
847847

848+
T_INT = TypeVar("T_INT", bound=int)
849+
T_COMPLEX = TypeVar("T_COMPLEX", bound=complex)
848850
SeriesDType: TypeAlias = (
849851
str
850852
| bytes

pandas-stubs/_version.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ from typing import Literal
22

33
version_json: str = ...
44

5-
_stub_version: Literal["2.3.0.250703"]
5+
_stub_version: Literal["2.3.2.250827"]

pandas-stubs/core/arraylike.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class OpsMixin:
1919
def __rxor__(self, other: Any) -> Self: ...
2020
# -------------------------------------------------------------
2121
# Arithmetic Methods
22-
def __add__(self, other: Any) -> Self: ...
23-
def __radd__(self, other: Any) -> Self: ...
2422
def __mul__(self, other: Any) -> Self: ...
2523
def __rmul__(self, other: Any) -> Self: ...
2624
# Handled by subclasses that specify only the valid values

pandas-stubs/core/base.pyi

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from typing import (
66
Any,
77
Generic,
88
Literal,
9+
TypeAlias,
910
final,
1011
overload,
1112
)
@@ -22,18 +23,22 @@ from typing_extensions import Self
2223

2324
from pandas._typing import (
2425
S1,
26+
ArrayLike,
2527
AxisIndex,
2628
DropKeep,
2729
DTypeLike,
2830
GenericT,
2931
GenericT_co,
3032
NDFrameT,
3133
Scalar,
34+
SequenceNotStr,
3235
SupportsDType,
3336
np_1darray,
3437
)
3538
from pandas.util._decorators import cache_readonly
3639

40+
_ListLike: TypeAlias = ArrayLike | dict[str, np.ndarray] | SequenceNotStr[S1]
41+
3742
class NoNewAttributesMixin:
3843
def __setattr__(self, key: str, value: Any) -> None: ...
3944

@@ -51,7 +56,7 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
5156
@property
5257
def T(self) -> Self: ...
5358
@property
54-
def shape(self) -> tuple: ...
59+
def shape(self) -> tuple[int, ...]: ...
5560
@property
5661
def ndim(self) -> int: ...
5762
def item(self) -> S1: ...
@@ -67,41 +72,45 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
6772
dtype: None = None,
6873
copy: bool = False,
6974
na_value: Scalar = ...,
70-
**kwargs,
75+
**kwargs: Any,
7176
) -> np_1darray[GenericT_co]: ...
7277
@overload
7378
def to_numpy(
7479
self,
7580
dtype: np.dtype[GenericT] | SupportsDType[GenericT] | type[GenericT],
7681
copy: bool = False,
7782
na_value: Scalar = ...,
78-
**kwargs,
83+
**kwargs: Any,
7984
) -> np_1darray[GenericT]: ...
8085
@overload
8186
def to_numpy(
8287
self,
8388
dtype: DTypeLike,
8489
copy: bool = False,
8590
na_value: Scalar = ...,
86-
**kwargs,
91+
**kwargs: Any,
8792
) -> np_1darray: ...
8893
@property
8994
def empty(self) -> bool: ...
90-
def max(self, axis=..., skipna: bool = ..., **kwargs): ...
91-
def min(self, axis=..., skipna: bool = ..., **kwargs): ...
95+
def max(
96+
self, axis: AxisIndex | None = ..., skipna: bool = ..., **kwargs: Any
97+
) -> S1: ...
98+
def min(
99+
self, axis: AxisIndex | None = ..., skipna: bool = ..., **kwargs: Any
100+
) -> S1: ...
92101
def argmax(
93102
self,
94103
axis: AxisIndex | None = ...,
95104
skipna: bool = True,
96-
*args,
97-
**kwargs,
105+
*args: Any,
106+
**kwargs: Any,
98107
) -> np.int64: ...
99108
def argmin(
100109
self,
101110
axis: AxisIndex | None = ...,
102111
skipna: bool = True,
103-
*args,
104-
**kwargs,
112+
*args: Any,
113+
**kwargs: Any,
105114
) -> np.int64: ...
106115
def tolist(self) -> list[S1]: ...
107116
def to_list(self) -> list[S1]: ...
@@ -114,7 +123,7 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
114123
normalize: Literal[False] = ...,
115124
sort: bool = ...,
116125
ascending: bool = ...,
117-
bins=...,
126+
bins: int | None = ...,
118127
dropna: bool = ...,
119128
) -> Series[int]: ...
120129
@overload
@@ -123,7 +132,7 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
123132
normalize: Literal[True],
124133
sort: bool = ...,
125134
ascending: bool = ...,
126-
bins=...,
135+
bins: int | None = ...,
127136
dropna: bool = ...,
128137
) -> Series[float]: ...
129138
def nunique(self, dropna: bool = True) -> int: ...
@@ -136,7 +145,18 @@ class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]):
136145
def factorize(
137146
self, sort: bool = False, use_na_sentinel: bool = True
138147
) -> tuple[np_1darray, np_1darray | Index | Categorical]: ...
148+
@overload
149+
def searchsorted(
150+
self,
151+
value: _ListLike,
152+
side: Literal["left", "right"] = ...,
153+
sorter: _ListLike | None = ...,
154+
) -> np_1darray[np.intp]: ...
155+
@overload
139156
def searchsorted(
140-
self, value, side: Literal["left", "right"] = ..., sorter=...
141-
) -> int | list[int]: ...
157+
self,
158+
value: Scalar,
159+
side: Literal["left", "right"] = ...,
160+
sorter: _ListLike | None = ...,
161+
) -> np.intp: ...
142162
def drop_duplicates(self, *, keep: DropKeep = ...) -> Self: ...

pandas-stubs/core/frame.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,13 +1772,22 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
17721772
# methods
17731773
@final
17741774
def abs(self) -> Self: ...
1775+
def __add__(self, other: Any) -> Self: ...
17751776
def add(
17761777
self,
17771778
other: num | ListLike | DataFrame,
17781779
axis: Axis | None = "columns",
17791780
level: Level | None = None,
17801781
fill_value: float | None = None,
17811782
) -> Self: ...
1783+
def __radd__(self, other: Any) -> Self: ...
1784+
def radd(
1785+
self,
1786+
other,
1787+
axis: Axis = "columns",
1788+
level: Level | None = None,
1789+
fill_value: float | None = None,
1790+
) -> Self: ...
17821791
@final
17831792
def add_prefix(self, prefix: _str, axis: Axis | None = None) -> Self: ...
17841793
@final
@@ -2222,13 +2231,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
22222231
min_count: int = 0,
22232232
**kwargs: Any,
22242233
) -> Series: ...
2225-
def radd(
2226-
self,
2227-
other,
2228-
axis: Axis = "columns",
2229-
level: Level | None = None,
2230-
fill_value: float | None = None,
2231-
) -> Self: ...
22322234
@final
22332235
def rank(
22342236
self,

pandas-stubs/core/indexes/base.pyi

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ from pandas.core.strings.accessor import StringMethods
3939
from typing_extensions import (
4040
Never,
4141
Self,
42+
TypeAlias,
4243
)
4344

4445
from pandas._libs.interval import _OrderableT
4546
from pandas._typing import (
4647
C2,
4748
S1,
49+
T_COMPLEX,
50+
T_INT,
4851
AnyAll,
4952
ArrayLike,
5053
AxesData,
@@ -70,18 +73,32 @@ from pandas._typing import (
7073
TimestampDtypeArg,
7174
np_1darray,
7275
np_ndarray_anyint,
76+
np_ndarray_bool,
7377
np_ndarray_complex,
7478
np_ndarray_float,
79+
np_ndarray_str,
7580
type_t,
7681
)
7782

7883
class InvalidIndexError(Exception): ...
7984

85+
_ListLike: TypeAlias = ArrayLike | dict[_str, np.ndarray] | SequenceNotStr[S1]
86+
8087
class Index(IndexOpsMixin[S1]):
8188
__hash__: ClassVar[None] # type: ignore[assignment]
8289
# overloads with additional dtypes
8390
@overload
8491
def __new__( # pyright: ignore[reportOverlappingOverload]
92+
cls,
93+
data: Sequence[bool | np.bool_] | IndexOpsMixin[bool] | np_ndarray_bool,
94+
*,
95+
dtype: Literal["bool"] | type_t[bool | np.bool_] = ...,
96+
copy: bool = ...,
97+
name: Hashable = ...,
98+
tupleize_cols: bool = ...,
99+
) -> Index[bool]: ...
100+
@overload
101+
def __new__(
85102
cls,
86103
data: Sequence[int | np.integer] | IndexOpsMixin[int] | np_ndarray_anyint,
87104
*,
@@ -462,6 +479,155 @@ class Index(IndexOpsMixin[S1]):
462479
def __sub__(self, other: Any) -> Self: ...
463480
def __rsub__(self, other: Any) -> Self: ...
464481
@overload
482+
def __add__(self: Index[Never], other: _str) -> Never: ...
483+
@overload
484+
def __add__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
485+
@overload
486+
def __add__(self, other: Index[Never]) -> Index: ...
487+
@overload
488+
def __add__(
489+
self: Index[bool],
490+
other: T_COMPLEX | Sequence[T_COMPLEX] | Index[T_COMPLEX],
491+
) -> Index[T_COMPLEX]: ...
492+
@overload
493+
def __add__(self: Index[bool], other: np_ndarray_bool) -> Index[bool]: ...
494+
@overload
495+
def __add__(self: Index[bool], other: np_ndarray_anyint) -> Index[int]: ...
496+
@overload
497+
def __add__(self: Index[bool], other: np_ndarray_float) -> Index[float]: ...
498+
@overload
499+
def __add__(self: Index[bool], other: np_ndarray_complex) -> Index[complex]: ...
500+
@overload
501+
def __add__(
502+
self: Index[int],
503+
other: (
504+
bool | Sequence[bool] | np_ndarray_bool | np_ndarray_anyint | Index[bool]
505+
),
506+
) -> Index[int]: ...
507+
@overload
508+
def __add__(
509+
self: Index[int],
510+
other: T_COMPLEX | Sequence[T_COMPLEX] | Index[T_COMPLEX],
511+
) -> Index[T_COMPLEX]: ...
512+
@overload
513+
def __add__(self: Index[int], other: np_ndarray_float) -> Index[float]: ...
514+
@overload
515+
def __add__(self: Index[int], other: np_ndarray_complex) -> Index[complex]: ...
516+
@overload
517+
def __add__(
518+
self: Index[float],
519+
other: (
520+
int
521+
| Sequence[int]
522+
| np_ndarray_bool
523+
| np_ndarray_anyint
524+
| np_ndarray_float
525+
| Index[T_INT]
526+
),
527+
) -> Index[float]: ...
528+
@overload
529+
def __add__(
530+
self: Index[float],
531+
other: T_COMPLEX | Sequence[T_COMPLEX] | Index[T_COMPLEX],
532+
) -> Index[T_COMPLEX]: ...
533+
@overload
534+
def __add__(self: Index[float], other: np_ndarray_complex) -> Index[complex]: ...
535+
@overload
536+
def __add__(
537+
self: Index[complex],
538+
other: (
539+
T_COMPLEX
540+
| Sequence[T_COMPLEX]
541+
| np_ndarray_bool
542+
| np_ndarray_anyint
543+
| np_ndarray_float
544+
| np_ndarray_complex
545+
| Index[T_COMPLEX]
546+
),
547+
) -> Index[complex]: ...
548+
@overload
549+
def __add__(
550+
self: Index[_str],
551+
other: (
552+
np_ndarray_bool | np_ndarray_anyint | np_ndarray_float | np_ndarray_complex
553+
),
554+
) -> Never: ...
555+
@overload
556+
def __add__(
557+
self: Index[_str], other: _str | Sequence[_str] | np_ndarray_str | Index[_str]
558+
) -> Index[_str]: ...
559+
@overload
560+
def __radd__(self: Index[Never], other: _str) -> Never: ...
561+
@overload
562+
def __radd__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
563+
@overload
564+
def __radd__(
565+
self: Index[bool],
566+
other: T_COMPLEX | Sequence[T_COMPLEX] | Index[T_COMPLEX],
567+
) -> Index[T_COMPLEX]: ...
568+
@overload
569+
def __radd__(self: Index[bool], other: np_ndarray_bool) -> Index[bool]: ...
570+
@overload
571+
def __radd__(self: Index[bool], other: np_ndarray_anyint) -> Index[int]: ...
572+
@overload
573+
def __radd__(self: Index[bool], other: np_ndarray_float) -> Index[float]: ...
574+
@overload
575+
def __radd__(
576+
self: Index[int],
577+
other: (
578+
bool | Sequence[bool] | np_ndarray_bool | np_ndarray_anyint | Index[bool]
579+
),
580+
) -> Index[int]: ...
581+
@overload
582+
def __radd__(
583+
self: Index[int], other: T_COMPLEX | Sequence[T_COMPLEX] | Index[T_COMPLEX]
584+
) -> Index[T_COMPLEX]: ...
585+
@overload
586+
def __radd__(self: Index[int], other: np_ndarray_float) -> Index[float]: ...
587+
@overload
588+
def __radd__(
589+
self: Index[float],
590+
other: (
591+
int
592+
| Sequence[int]
593+
| np_ndarray_bool
594+
| np_ndarray_anyint
595+
| np_ndarray_float
596+
| Index[T_INT]
597+
),
598+
) -> Index[float]: ...
599+
@overload
600+
def __radd__(
601+
self: Index[float], other: T_COMPLEX | Sequence[T_COMPLEX] | Index[T_COMPLEX]
602+
) -> Index[T_COMPLEX]: ...
603+
@overload
604+
def __radd__(
605+
self: Index[complex],
606+
other: (
607+
T_COMPLEX
608+
| Sequence[T_COMPLEX]
609+
| np_ndarray_bool
610+
| np_ndarray_anyint
611+
| np_ndarray_float
612+
| Index[T_COMPLEX]
613+
),
614+
) -> Index[complex]: ...
615+
@overload
616+
def __radd__(
617+
self: Index[T_COMPLEX], other: np_ndarray_complex
618+
) -> Index[complex]: ...
619+
@overload
620+
def __radd__(
621+
self: Index[_str],
622+
other: (
623+
np_ndarray_bool | np_ndarray_anyint | np_ndarray_float | np_ndarray_complex
624+
),
625+
) -> Never: ...
626+
@overload
627+
def __radd__(
628+
self: Index[_str], other: _str | Sequence[_str] | np_ndarray_str | Index[_str]
629+
) -> Index[_str]: ...
630+
@overload
465631
def __mul__(
466632
self: Index[int] | Index[float], other: timedelta
467633
) -> TimedeltaIndex: ...

0 commit comments

Comments
 (0)