@@ -186,7 +186,6 @@ from pandas._typing import (
186
186
np_ndarray_anyint ,
187
187
np_ndarray_bool ,
188
188
np_ndarray_complex ,
189
- np_ndarray_dt ,
190
189
np_ndarray_float ,
191
190
np_ndarray_str ,
192
191
np_ndarray_td ,
@@ -261,9 +260,20 @@ class _LocIndexerSeries(_LocIndexer, Generic[S1]):
261
260
value : S1 | ArrayLike | Series [S1 ] | None ,
262
261
) -> None : ...
263
262
264
- _ListLike : TypeAlias = (
263
+ _ListLike : TypeAlias = ArrayLike | dict [_str , np .ndarray ] | SequenceNotStr [S1 ]
264
+ _ListLikeS1 : TypeAlias = (
265
265
ArrayLike | dict [_str , np .ndarray ] | Sequence [S1 ] | IndexOpsMixin [S1 ]
266
266
)
267
+ _NumListLike : TypeAlias = (
268
+ ExtensionArray
269
+ | np_ndarray_bool
270
+ | np_ndarray_anyint
271
+ | np_ndarray_float
272
+ | np_ndarray_complex
273
+ | dict [_str , np .ndarray ]
274
+ | Sequence [complex ]
275
+ | IndexOpsMixin [complex ]
276
+ )
267
277
268
278
class Series (IndexOpsMixin [S1 ], NDFrame ):
269
279
# Define __index__ because mypy thinks Series follows protocol `SupportsIndex` https://github.com/pandas-dev/pandas-stubs/pull/1332#discussion_r2285648790
@@ -419,7 +429,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
419
429
@overload
420
430
def __new__ (
421
431
cls ,
422
- data : S1 | _ListLike [S1 ] | dict [HashableT1 , S1 ] | KeysView [S1 ] | ValuesView [S1 ],
432
+ data : (
433
+ S1 | _ListLikeS1 [S1 ] | dict [HashableT1 , S1 ] | KeysView [S1 ] | ValuesView [S1 ]
434
+ ),
423
435
index : AxesData | None = ...,
424
436
dtype : Dtype = ...,
425
437
name : Hashable = ...,
@@ -1619,7 +1631,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
1619
1631
# just failed to generate these so I couldn't match
1620
1632
# them up.
1621
1633
@overload
1622
- def __add__ (self : Series [Never ], other : Scalar | _ListLike | Series ) -> Series : ...
1634
+ def __add__ (self : Series [Never ], other : _str ) -> Never : ...
1635
+ @overload
1636
+ def __add__ (self : Series [Never ], other : complex | _ListLike | Series ) -> Series : ...
1623
1637
@overload
1624
1638
def __add__ (self , other : Series [Never ]) -> Series : ...
1625
1639
@overload
@@ -1697,7 +1711,15 @@ class Series(IndexOpsMixin[S1], NDFrame):
1697
1711
@overload
1698
1712
def add (
1699
1713
self : Series [Never ],
1700
- other : Scalar | _ListLike | Series ,
1714
+ other : _str ,
1715
+ level : Level | None = None ,
1716
+ fill_value : float | None = None ,
1717
+ axis : int = 0 ,
1718
+ ) -> Never : ...
1719
+ @overload
1720
+ def add (
1721
+ self : Series [Never ],
1722
+ other : complex | _ListLike | Series ,
1701
1723
level : Level | None = None ,
1702
1724
fill_value : float | None = None ,
1703
1725
axis : int = 0 ,
@@ -1840,7 +1862,11 @@ class Series(IndexOpsMixin[S1], NDFrame):
1840
1862
axis : int = 0 ,
1841
1863
) -> Series [_str ]: ...
1842
1864
@overload # type: ignore[override]
1843
- def __radd__ (self : Series [Never ], other : Scalar | _ListLike ) -> Series : ...
1865
+ def __radd__ (self : Series [Never ], other : _str ) -> Never : ...
1866
+ @overload
1867
+ def __radd__ (
1868
+ self : Series [Never ], other : complex | _ListLike | Series
1869
+ ) -> Series : ...
1844
1870
@overload
1845
1871
def __radd__ (
1846
1872
self : Series [bool ],
@@ -1912,7 +1938,23 @@ class Series(IndexOpsMixin[S1], NDFrame):
1912
1938
@overload
1913
1939
def radd (
1914
1940
self : Series [Never ],
1915
- other : Scalar | _ListLike | Series ,
1941
+ other : _str ,
1942
+ level : Level | None = None ,
1943
+ fill_value : float | None = None ,
1944
+ axis : int = 0 ,
1945
+ ) -> Never : ...
1946
+ @overload
1947
+ def radd (
1948
+ self : Series [Never ],
1949
+ other : complex | _ListLike | Series ,
1950
+ level : Level | None = None ,
1951
+ fill_value : float | None = None ,
1952
+ axis : int = 0 ,
1953
+ ) -> Series : ...
1954
+ @overload
1955
+ def radd (
1956
+ self : Series [S1 ],
1957
+ other : Series [Never ],
1916
1958
level : Level | None = None ,
1917
1959
fill_value : float | None = None ,
1918
1960
axis : int = 0 ,
@@ -2051,7 +2093,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
2051
2093
self , other : S1 | _ListLike | Series [S1 ] | datetime | timedelta | date
2052
2094
) -> Series [_bool ]: ...
2053
2095
@overload
2054
- def __mul__ (self : Series [Never ], other : complex | _ListLike | Series ) -> Series : ...
2096
+ def __mul__ (
2097
+ self : Series [Never ], other : complex | _NumListLike | Series
2098
+ ) -> Series : ...
2055
2099
@overload
2056
2100
def __mul__ (self , other : Series [Never ]) -> Series : ... # type: ignore[overload-overlap]
2057
2101
@overload
@@ -2246,7 +2290,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
2246
2290
) -> TimedeltaSeries : ...
2247
2291
@overload
2248
2292
def __rmul__ (
2249
- self : Series [Never ], other : complex | _ListLike | Series
2293
+ self : Series [Never ], other : complex | _NumListLike | Series
2250
2294
) -> Series : ...
2251
2295
@overload
2252
2296
def __rmul__ (self , other : Series [Never ]) -> Series : ... # type: ignore[overload-overlap]
@@ -2475,12 +2519,11 @@ class Series(IndexOpsMixin[S1], NDFrame):
2475
2519
@overload
2476
2520
def __rxor__ (self , other : int | np_ndarray_anyint | Series [int ]) -> Series [int ]: ...
2477
2521
@overload
2478
- def __sub__ (
2479
- self : Series [Never ],
2480
- other : datetime | np .datetime64 | np_ndarray_dt | TimestampSeries ,
2481
- ) -> TimedeltaSeries : ...
2522
+ def __sub__ (self : Series [Never ], other : TimestampSeries ) -> Never : ...
2482
2523
@overload
2483
- def __sub__ (self : Series [Never ], other : complex | _ListLike | Series ) -> Series : ...
2524
+ def __sub__ (
2525
+ self : Series [Never ], other : complex | _NumListLike | Series
2526
+ ) -> Series : ...
2484
2527
@overload
2485
2528
def __sub__ (self , other : Series [Never ]) -> Series : ... # type: ignore[overload-overlap]
2486
2529
@overload
@@ -2571,15 +2614,15 @@ class Series(IndexOpsMixin[S1], NDFrame):
2571
2614
@overload
2572
2615
def sub (
2573
2616
self : Series [Never ],
2574
- other : datetime | np . datetime64 | np_ndarray_dt | TimestampSeries ,
2617
+ other : TimestampSeries ,
2575
2618
level : Level | None = None ,
2576
2619
fill_value : float | None = None ,
2577
2620
axis : int = 0 ,
2578
- ) -> TimedeltaSeries : ...
2621
+ ) -> Never : ...
2579
2622
@overload
2580
2623
def sub (
2581
2624
self : Series [Never ],
2582
- other : complex | _ListLike | Series ,
2625
+ other : complex | _NumListLike | Series ,
2583
2626
level : Level | None = None ,
2584
2627
fill_value : float | None = None ,
2585
2628
axis : int = 0 ,
@@ -2705,13 +2748,10 @@ class Series(IndexOpsMixin[S1], NDFrame):
2705
2748
axis : int = 0 ,
2706
2749
) -> TimedeltaSeries : ...
2707
2750
@overload
2708
- def __rsub__ ( # type: ignore[misc]
2709
- self : Series [Never ],
2710
- other : datetime | np .datetime64 | np_ndarray_dt | TimestampSeries ,
2711
- ) -> TimedeltaSeries : ...
2751
+ def __rsub__ (self : Series [Never ], other : TimestampSeries ) -> Never : ... # type: ignore[misc]
2712
2752
@overload
2713
2753
def __rsub__ (
2714
- self : Series [Never ], other : complex | _ListLike | Series
2754
+ self : Series [Never ], other : complex | _NumListLike | Series
2715
2755
) -> Series : ...
2716
2756
@overload
2717
2757
def __rsub__ (self , other : Series [Never ]) -> Series : ...
@@ -2781,15 +2821,15 @@ class Series(IndexOpsMixin[S1], NDFrame):
2781
2821
@overload
2782
2822
def rsub (
2783
2823
self : Series [Never ],
2784
- other : datetime | np . datetime64 | np_ndarray_dt | TimestampSeries ,
2824
+ other : TimestampSeries ,
2785
2825
level : Level | None = None ,
2786
2826
fill_value : float | None = None ,
2787
2827
axis : int = 0 ,
2788
- ) -> TimedeltaSeries : ...
2828
+ ) -> Never : ...
2789
2829
@overload
2790
2830
def rsub (
2791
2831
self : Series [Never ],
2792
- other : complex | _ListLike | Series ,
2832
+ other : complex | _NumListLike | Series ,
2793
2833
level : Level | None = None ,
2794
2834
fill_value : float | None = None ,
2795
2835
axis : int = 0 ,
@@ -2887,8 +2927,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
2887
2927
axis : int = 0 ,
2888
2928
) -> Series [complex ]: ...
2889
2929
@overload
2890
- def __truediv__ (
2891
- self : Series [Never ], other : complex | _ListLike | Series
2930
+ def __truediv__ ( # type:ignore[overload-overlap]
2931
+ self : Series [Never ], other : complex | _NumListLike | Series
2892
2932
) -> Series : ...
2893
2933
@overload
2894
2934
def __truediv__ (self , other : Series [Never ]) -> Series : ...
@@ -3083,8 +3123,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
3083
3123
) -> Series : ...
3084
3124
div = truediv
3085
3125
@overload
3086
- def __rtruediv__ (
3087
- self : Series [Never ], other : complex | _ListLike | Series
3126
+ def __rtruediv__ ( # type:ignore[overload-overlap]
3127
+ self : Series [Never ], other : complex | _NumListLike | Series
3088
3128
) -> Series : ...
3089
3129
@overload
3090
3130
def __rtruediv__ (self , other : Series [Never ]) -> Series : ...
0 commit comments