2929if TYPE_CHECKING :
3030 from git .remote import Remote
3131 from git .repo .base import Repo
32- from .types import PathLike , TBD , Literal
32+ from .types import PathLike , TBD , Literal , SupportsIndex
3333
3434# ---------------------------------------------------------------------
3535
@@ -971,7 +971,10 @@ def __getattr__(self, attr: str) -> Any:
971971 # END for each item
972972 return list .__getattribute__ (self , attr )
973973
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+
975978 if isinstance (index , int ):
976979 return list .__getitem__ (self , index )
977980 elif isinstance (index , slice ):
@@ -983,12 +986,13 @@ def __getitem__(self, index: Union[int, slice, str]) -> Any: # type: ignore
983986 raise IndexError ("No item found with id %r" % (self ._prefix + index )) from e
984987 # END handle getattr
985988
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"
987992
988993 delindex = cast (int , index )
989994 if not isinstance (index , int ):
990995 delindex = - 1
991- assert not isinstance (index , slice )
992996 name = self ._prefix + index
993997 for i , item in enumerate (self ):
994998 if getattr (item , self ._id_attr ) == name :
0 commit comments