@@ -39,12 +39,15 @@ from pandas.core.strings.accessor import StringMethods
3939from typing_extensions import (
4040 Never ,
4141 Self ,
42+ TypeAlias ,
4243)
4344
4445from pandas ._libs .interval import _OrderableT
4546from 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
7883class InvalidIndexError (Exception ): ...
7984
85+ _ListLike : TypeAlias = ArrayLike | dict [_str , np .ndarray ] | SequenceNotStr [S1 ]
86+
8087class 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