@@ -34,12 +34,15 @@ from pandas import (
3434 TimedeltaIndex ,
3535)
3636from pandas .core .arrays import ExtensionArray
37- from pandas .core .base import IndexOpsMixin
37+ from pandas .core .base import (
38+ IndexOpsMixin ,
39+ NumListLike ,
40+ _ListLike ,
41+ )
3842from pandas .core .strings .accessor import StringMethods
3943from typing_extensions import (
4044 Never ,
4145 Self ,
42- TypeAlias ,
4346)
4447
4548from pandas ._libs .interval import _OrderableT
@@ -60,6 +63,7 @@ from pandas._typing import (
6063 GenericT_co ,
6164 HashableT ,
6265 IgnoreRaise ,
66+ Just ,
6367 Label ,
6468 Level ,
6569 MaskType ,
@@ -82,8 +86,6 @@ from pandas._typing import (
8286
8387class InvalidIndexError (Exception ): ...
8488
85- _ListLike : TypeAlias = ArrayLike | dict [_str , np .ndarray ] | SequenceNotStr [S1 ]
86-
8789class Index (IndexOpsMixin [S1 ]):
8890 __hash__ : ClassVar [None ] # type: ignore[assignment]
8991 # overloads with additional dtypes
@@ -626,6 +628,144 @@ class Index(IndexOpsMixin[S1]):
626628 self : Index [_str ], other : _str | Sequence [_str ] | np_ndarray_str | Index [_str ]
627629 ) -> Index [_str ]: ...
628630 @overload
631+ def __sub__ (self : Index [Never ], other : DatetimeIndex ) -> Never : ...
632+ @overload
633+ def __sub__ (self : Index [Never ], other : complex | NumListLike | Index ) -> Index : ...
634+ @overload
635+ def __sub__ (self , other : Index [Never ]) -> Index : ...
636+ @overload
637+ def __sub__ (
638+ self : Index [bool ],
639+ other : Just [int ] | Sequence [Just [int ]] | np_ndarray_anyint | Index [int ],
640+ ) -> Index [int ]: ...
641+ @overload
642+ def __sub__ (
643+ self : Index [bool ],
644+ other : Just [float ] | Sequence [Just [float ]] | np_ndarray_float | Index [float ],
645+ ) -> Index [float ]: ...
646+ @overload
647+ def __sub__ (
648+ self : Index [int ],
649+ other : (
650+ int
651+ | Sequence [int ]
652+ | np_ndarray_bool
653+ | np_ndarray_anyint
654+ | Index [bool ]
655+ | Index [int ]
656+ ),
657+ ) -> Index [int ]: ...
658+ @overload
659+ def __sub__ (
660+ self : Index [int ],
661+ other : Just [float ] | Sequence [Just [float ]] | np_ndarray_float | Index [float ],
662+ ) -> Index [float ]: ...
663+ @overload
664+ def __sub__ (
665+ self : Index [float ],
666+ other : (
667+ float
668+ | Sequence [float ]
669+ | np_ndarray_bool
670+ | np_ndarray_anyint
671+ | np_ndarray_float
672+ | Index [bool ]
673+ | Index [int ]
674+ | Index [float ]
675+ ),
676+ ) -> Index [float ]: ...
677+ @overload
678+ def __sub__ (
679+ self : Index [complex ],
680+ other : (
681+ T_COMPLEX
682+ | Sequence [T_COMPLEX ]
683+ | np_ndarray_bool
684+ | np_ndarray_anyint
685+ | np_ndarray_float
686+ | Index [T_COMPLEX ]
687+ ),
688+ ) -> Index [complex ]: ...
689+ @overload
690+ def __sub__ (
691+ self : Index [T_COMPLEX ],
692+ other : (
693+ Just [complex ]
694+ | Sequence [Just [complex ]]
695+ | np_ndarray_complex
696+ | Index [complex ]
697+ ),
698+ ) -> Index [complex ]: ...
699+ @overload
700+ def __rsub__ (self : Index [Never ], other : DatetimeIndex ) -> Never : ... # type: ignore[misc]
701+ @overload
702+ def __rsub__ (self : Index [Never ], other : complex | NumListLike | Index ) -> Index : ...
703+ @overload
704+ def __rsub__ (self , other : Index [Never ]) -> Index : ...
705+ @overload
706+ def __rsub__ (
707+ self : Index [bool ],
708+ other : Just [int ] | Sequence [Just [int ]] | np_ndarray_anyint | Index [int ],
709+ ) -> Index [int ]: ...
710+ @overload
711+ def __rsub__ (
712+ self : Index [bool ],
713+ other : Just [float ] | Sequence [Just [float ]] | np_ndarray_float | Index [float ],
714+ ) -> Index [float ]: ...
715+ @overload
716+ def __rsub__ (
717+ self : Index [int ],
718+ other : (
719+ int
720+ | Sequence [int ]
721+ | np_ndarray_bool
722+ | np_ndarray_anyint
723+ | Index [bool ]
724+ | Index [int ]
725+ ),
726+ ) -> Index [int ]: ...
727+ @overload
728+ def __rsub__ (
729+ self : Index [int ],
730+ other : Just [float ] | Sequence [Just [float ]] | np_ndarray_float | Index [float ],
731+ ) -> Index [float ]: ...
732+ @overload
733+ def __rsub__ (
734+ self : Index [float ],
735+ other : (
736+ float
737+ | Sequence [float ]
738+ | np_ndarray_bool
739+ | np_ndarray_anyint
740+ | np_ndarray_float
741+ | Index [bool ]
742+ | Index [int ]
743+ | Index [float ]
744+ ),
745+ ) -> Index [float ]: ...
746+ @overload
747+ def __rsub__ (
748+ self : Index [complex ],
749+ other : (
750+ T_COMPLEX
751+ | Sequence [T_COMPLEX ]
752+ | np_ndarray_bool
753+ | np_ndarray_anyint
754+ | np_ndarray_float
755+ | Index [T_COMPLEX ]
756+ ),
757+ ) -> Index [complex ]: ...
758+ @overload
759+ def __rsub__ (
760+ self : Index [T_COMPLEX ],
761+ other : (
762+ Just [complex ]
763+ | Sequence [Just [complex ]]
764+ | np_ndarray_complex
765+ | Index [complex ]
766+ ),
767+ ) -> Index [complex ]: ...
768+ @overload
629769 def __mul__ (
630770 self : Index [int ] | Index [float ], other : timedelta
631771 ) -> TimedeltaIndex : ...
0 commit comments