@@ -3,7 +3,6 @@ from collections.abc import (
3
3
Callable ,
4
4
Hashable ,
5
5
Iterable ,
6
- Iterator ,
7
6
Sequence ,
8
7
)
9
8
from datetime import (
@@ -20,6 +19,10 @@ from typing import (
20
19
type_check_only ,
21
20
)
22
21
22
+ from _typeshed import (
23
+ SupportsAdd ,
24
+ SupportsRAdd ,
25
+ )
23
26
import numpy as np
24
27
from pandas import (
25
28
DataFrame ,
@@ -49,8 +52,9 @@ from pandas._libs.interval import _OrderableT
49
52
from pandas ._typing import (
50
53
C2 ,
51
54
S1 ,
55
+ S1_CO ,
56
+ S1_CT ,
52
57
T_COMPLEX ,
53
- T_INT ,
54
58
AnyAll ,
55
59
ArrayLike ,
56
60
AxesData ,
@@ -471,7 +475,6 @@ class Index(IndexOpsMixin[S1]):
471
475
def shape (self ) -> tuple [int , ...]: ...
472
476
# Extra methods from old stubs
473
477
def __eq__ (self , other : object ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
474
- def __iter__ (self ) -> Iterator [S1 ]: ...
475
478
def __ne__ (self , other : object ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
476
479
def __le__ (self , other : Self | S1 ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
477
480
def __ge__ (self , other : Self | S1 ) -> np_1darray [np .bool ]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@@ -484,65 +487,43 @@ class Index(IndexOpsMixin[S1]):
484
487
@overload
485
488
def __add__ (self , other : Index [Never ]) -> Index : ...
486
489
@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 ]: ...
493
491
@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 ]: ...
495
493
@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 ]: ...
497
495
@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 ]: ...
499
499
@overload
500
500
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 ]: ...
506
504
@overload
507
505
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 ]
510
507
) -> Index [T_COMPLEX ]: ...
511
508
@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 ]: ...
513
512
@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 ]: ...
515
516
@overload
516
517
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 ]
526
519
) -> Index [float ]: ...
527
520
@overload
528
521
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 ]
531
523
) -> Index [T_COMPLEX ]: ...
532
524
@overload
533
- def __add__ (self : Index [float ], other : np_ndarray_complex ) -> Index [complex ]: ...
534
- @overload
535
525
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 ]
546
527
) -> Index [complex ]: ...
547
528
@overload
548
529
def __add__ (
@@ -560,60 +541,43 @@ class Index(IndexOpsMixin[S1]):
560
541
@overload
561
542
def __radd__ (self : Index [Never ], other : complex | _ListLike | Index ) -> Index : ...
562
543
@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 ]: ...
567
545
@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 ]: ...
569
547
@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 ]: ...
571
549
@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 ]: ...
573
553
@overload
574
554
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 ]: ...
580
558
@overload
581
559
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 ]
583
561
) -> Index [T_COMPLEX ]: ...
584
562
@overload
585
- def __radd__ (self : Index [int ], other : np_ndarray_float ) -> Index [float ]: ...
586
- @overload
587
563
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 ]: ...
598
566
@overload
599
567
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 ]
601
569
) -> Index [T_COMPLEX ]: ...
602
570
@overload
603
571
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 ]: ...
614
578
@overload
615
579
def __radd__ (
616
- self : Index [T_COMPLEX ], other : np_ndarray_complex
580
+ self : Index [T_COMPLEX ], other : np_ndarray_complex | Index [ complex ]
617
581
) -> Index [complex ]: ...
618
582
@overload
619
583
def __radd__ (
0 commit comments