@@ -3,7 +3,6 @@ from collections.abc import (
33 Callable ,
44 Hashable ,
55 Iterable ,
6- Iterator ,
76 Sequence ,
87)
98from datetime import (
@@ -20,6 +19,10 @@ from typing import (
2019 type_check_only ,
2120)
2221
22+ from _typeshed import (
23+ SupportsAdd ,
24+ SupportsRAdd ,
25+ )
2326import numpy as np
2427from pandas import (
2528 DataFrame ,
@@ -49,8 +52,9 @@ from pandas._libs.interval import _OrderableT
4952from pandas ._typing import (
5053 C2 ,
5154 S1 ,
55+ S1_CO ,
56+ S1_CT ,
5257 T_COMPLEX ,
53- T_INT ,
5458 AnyAll ,
5559 ArrayLike ,
5660 AxesData ,
@@ -471,7 +475,6 @@ class Index(IndexOpsMixin[S1]):
471475 def shape (self ) -> tuple [int , ...]: ...
472476 # Extra methods from old stubs
473477 def __eq__ (self , other : object ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
474- def __iter__ (self ) -> Iterator [S1 ]: ...
475478 def __ne__ (self , other : object ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
476479 def __le__ (self , other : Self | S1 ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
477480 def __ge__ (self , other : Self | S1 ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@@ -484,65 +487,43 @@ class Index(IndexOpsMixin[S1]):
484487 @overload
485488 def __add__ (self , other : Index [Never ]) -> Index : ...
486489 @overload
487- def __add__ (
488- self : Index [bool ],
489- other : T_COMPLEX | Sequence [T_COMPLEX ] | Index [T_COMPLEX ],
490- ) -> Index [T_COMPLEX ]: ...
491- @overload
492- def __add__ (self : Index [bool ], other : np_ndarray_bool ) -> Index [bool ]: ...
490+ def __add__ (self : Index [bool ], other : bool | Sequence [bool ]) -> Index [bool ]: ...
493491 @overload
494- def __add__ (self : Index [bool ], other : np_ndarray_anyint ) -> Index [int ]: ...
492+ def __add__ (self : Index [int ], other : bool | Sequence [ bool ] ) -> Index [int ]: ...
495493 @overload
496- def __add__ (self : Index [bool ], other : np_ndarray_float ) -> Index [float ]: ...
494+ def __add__ (self : Index [float ], other : int | Sequence [ int ] ) -> Index [float ]: ...
497495 @overload
498- def __add__ (self : Index [bool ], other : np_ndarray_complex ) -> Index [complex ]: ...
496+ def __add__ (
497+ self : Index [complex ], other : float | Sequence [float ]
498+ ) -> Index [complex ]: ...
499499 @overload
500500 def __add__ (
501- self : Index [int ],
502- other : (
503- bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint | Index [bool ]
504- ),
505- ) -> Index [int ]: ...
501+ self : Index [S1_CT ],
502+ other : SupportsRAdd [S1_CT , S1_CO ] | Sequence [SupportsRAdd [S1_CT , S1_CO ]],
503+ ) -> Index [S1_CO ]: ...
506504 @overload
507505 def __add__ (
508- self : Index [int ],
509- other : T_COMPLEX | Sequence [T_COMPLEX ] | Index [T_COMPLEX ],
506+ self : Index [T_COMPLEX ], other : np_ndarray_bool | Index [bool ]
510507 ) -> Index [T_COMPLEX ]: ...
511508 @overload
512- def __add__ (self : Index [int ], other : np_ndarray_float ) -> Index [float ]: ...
509+ def __add__ (
510+ self : Index [bool ], other : np_ndarray_anyint | Index [int ]
511+ ) -> Index [int ]: ...
513512 @overload
514- def __add__ (self : Index [int ], other : np_ndarray_complex ) -> Index [complex ]: ...
513+ def __add__ (
514+ self : Index [T_COMPLEX ], other : np_ndarray_anyint | Index [int ]
515+ ) -> Index [T_COMPLEX ]: ...
515516 @overload
516517 def __add__ (
517- self : Index [float ],
518- other : (
519- int
520- | Sequence [int ]
521- | np_ndarray_bool
522- | np_ndarray_anyint
523- | np_ndarray_float
524- | Index [T_INT ]
525- ),
518+ self : Index [bool ] | Index [int ], other : np_ndarray_float | Index [float ]
526519 ) -> Index [float ]: ...
527520 @overload
528521 def __add__ (
529- self : Index [float ],
530- other : T_COMPLEX | Sequence [T_COMPLEX ] | Index [T_COMPLEX ],
522+ self : Index [T_COMPLEX ], other : np_ndarray_float | Index [float ]
531523 ) -> Index [T_COMPLEX ]: ...
532524 @overload
533- def __add__ (self : Index [float ], other : np_ndarray_complex ) -> Index [complex ]: ...
534- @overload
535525 def __add__ (
536- self : Index [complex ],
537- other : (
538- T_COMPLEX
539- | Sequence [T_COMPLEX ]
540- | np_ndarray_bool
541- | np_ndarray_anyint
542- | np_ndarray_float
543- | np_ndarray_complex
544- | Index [T_COMPLEX ]
545- ),
526+ self : Index [T_COMPLEX ], other : np_ndarray_complex | Index [complex ]
546527 ) -> Index [complex ]: ...
547528 @overload
548529 def __add__ (
@@ -560,60 +541,43 @@ class Index(IndexOpsMixin[S1]):
560541 @overload
561542 def __radd__ (self : Index [Never ], other : complex | _ListLike | Index ) -> Index : ...
562543 @overload
563- def __radd__ (
564- self : Index [bool ],
565- other : T_COMPLEX | Sequence [T_COMPLEX ] | Index [T_COMPLEX ],
566- ) -> Index [T_COMPLEX ]: ...
544+ def __radd__ (self : Index [bool ], other : bool | Sequence [bool ]) -> Index [bool ]: ...
567545 @overload
568- def __radd__ (self : Index [bool ], other : np_ndarray_bool ) -> Index [bool ]: ...
546+ def __radd__ (self : Index [int ], other : bool | Sequence [ bool ] ) -> Index [int ]: ...
569547 @overload
570- def __radd__ (self : Index [bool ], other : np_ndarray_anyint ) -> Index [int ]: ...
548+ def __radd__ (self : Index [float ], other : int | Sequence [ int ] ) -> Index [float ]: ...
571549 @overload
572- def __radd__ (self : Index [bool ], other : np_ndarray_float ) -> Index [float ]: ...
550+ def __radd__ (
551+ self : Index [complex ], other : float | Sequence [float ]
552+ ) -> Index [complex ]: ...
573553 @overload
574554 def __radd__ (
575- self : Index [int ],
576- other : (
577- bool | Sequence [bool ] | np_ndarray_bool | np_ndarray_anyint | Index [bool ]
578- ),
579- ) -> Index [int ]: ...
555+ self : Index [S1_CT ],
556+ other : SupportsAdd [S1_CT , S1_CO ] | Sequence [SupportsAdd [S1_CT , S1_CO ]],
557+ ) -> Index [S1_CO ]: ...
580558 @overload
581559 def __radd__ (
582- self : Index [int ], other : T_COMPLEX | Sequence [ T_COMPLEX ] | Index [T_COMPLEX ]
560+ self : Index [T_COMPLEX ], other : np_ndarray_bool | Index [bool ]
583561 ) -> Index [T_COMPLEX ]: ...
584562 @overload
585- def __radd__ (self : Index [int ], other : np_ndarray_float ) -> Index [float ]: ...
586- @overload
587563 def __radd__ (
588- self : Index [float ],
589- other : (
590- int
591- | Sequence [int ]
592- | np_ndarray_bool
593- | np_ndarray_anyint
594- | np_ndarray_float
595- | Index [T_INT ]
596- ),
597- ) -> Index [float ]: ...
564+ self : Index [bool ], other : np_ndarray_anyint | Index [int ]
565+ ) -> Index [int ]: ...
598566 @overload
599567 def __radd__ (
600- self : Index [float ], other : T_COMPLEX | Sequence [ T_COMPLEX ] | Index [T_COMPLEX ]
568+ self : Index [T_COMPLEX ], other : np_ndarray_anyint | Index [int ]
601569 ) -> Index [T_COMPLEX ]: ...
602570 @overload
603571 def __radd__ (
604- self : Index [complex ],
605- other : (
606- T_COMPLEX
607- | Sequence [T_COMPLEX ]
608- | np_ndarray_bool
609- | np_ndarray_anyint
610- | np_ndarray_float
611- | Index [T_COMPLEX ]
612- ),
613- ) -> Index [complex ]: ...
572+ self : Index [bool ] | Index [int ], other : np_ndarray_float | Index [float ]
573+ ) -> Index [float ]: ...
574+ @overload
575+ def __radd__ (
576+ self : Index [T_COMPLEX ], other : np_ndarray_float | Index [float ]
577+ ) -> Index [T_COMPLEX ]: ...
614578 @overload
615579 def __radd__ (
616- self : Index [T_COMPLEX ], other : np_ndarray_complex
580+ self : Index [T_COMPLEX ], other : np_ndarray_complex | Index [ complex ]
617581 ) -> Index [complex ]: ...
618582 @overload
619583 def __radd__ (
0 commit comments