29
29
if TYPE_CHECKING :
30
30
from git .remote import Remote
31
31
from git .repo .base import Repo
32
- from .types import PathLike , TBD , Literal
32
+ from .types import PathLike , TBD , Literal , SupportsIndex
33
33
34
34
# ---------------------------------------------------------------------
35
35
@@ -971,7 +971,10 @@ def __getattr__(self, attr: str) -> Any:
971
971
# END for each item
972
972
return list .__getattribute__ (self , attr )
973
973
974
- def __getitem__ (self , index : Union [int , slice , str ]) -> Any : # type: ignore
974
+ def __getitem__ (self , index : Union [SupportsIndex , int , slice , str ]) -> Any :
975
+
976
+ assert isinstance (index , (int , str , slice )), "Index of IterableList should be an int or str"
977
+
975
978
if isinstance (index , int ):
976
979
return list .__getitem__ (self , index )
977
980
elif isinstance (index , slice ):
@@ -983,12 +986,13 @@ def __getitem__(self, index: Union[int, slice, str]) -> Any: # type: ignore
983
986
raise IndexError ("No item found with id %r" % (self ._prefix + index )) from e
984
987
# END handle getattr
985
988
986
- def __delitem__ (self , index : Union [int , str , slice ]) -> None : # type: ignore
989
+ def __delitem__ (self , index : Union [SupportsIndex , int , slice , str ]) -> Any :
990
+
991
+ assert isinstance (index , (int , str )), "Index of IterableList should be an int or str"
987
992
988
993
delindex = cast (int , index )
989
994
if not isinstance (index , int ):
990
995
delindex = - 1
991
- assert not isinstance (index , slice )
992
996
name = self ._prefix + index
993
997
for i , item in enumerate (self ):
994
998
if getattr (item , self ._id_attr ) == name :
0 commit comments