@@ -13,8 +13,10 @@ from typing import (
13
13
Any ,
14
14
Literal ,
15
15
Protocol ,
16
+ SupportsIndex ,
16
17
TypedDict ,
17
18
TypeVar ,
19
+ overload ,
18
20
)
19
21
20
22
import numpy as np
@@ -421,6 +423,20 @@ class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
421
423
422
424
FilePath : TypeAlias = str | PathLike [str ]
423
425
426
+ _T_co = TypeVar ("_T_co" , covariant = True )
427
+
428
+ class SequenceNotStr (Protocol [_T_co ]):
429
+ @overload
430
+ def __getitem__ (self , index : SupportsIndex , / ) -> _T_co : ...
431
+ @overload
432
+ def __getitem__ (self , index : slice , / ) -> Sequence [_T_co ]: ...
433
+ def __contains__ (self , value : object , / ) -> bool : ...
434
+ def __len__ (self ) -> int : ...
435
+ def __iter__ (self ) -> Iterator [_T_co ]: ...
436
+ def index (self , value : Any , / , start : int = 0 , stop : int = ...) -> int : ...
437
+ def count (self , value : Any , / ) -> int : ...
438
+ def __reversed__ (self ) -> Iterator [_T_co ]: ...
439
+
424
440
IndexLabel : TypeAlias = Hashable | Sequence [Hashable ]
425
441
Label : TypeAlias = Hashable | None
426
442
Level : TypeAlias = Hashable | int
@@ -492,14 +508,7 @@ np_ndarray_str: TypeAlias = npt.NDArray[np.str_]
492
508
IndexType : TypeAlias = slice | np_ndarray_anyint | Index | list [int ] | Series [int ]
493
509
MaskType : TypeAlias = Series [bool ] | np_ndarray_bool | list [bool ]
494
510
UsecolsArgType : TypeAlias = (
495
- MutableSequence [str ]
496
- | tuple [str , ...]
497
- | Sequence [int ]
498
- | Series
499
- | Index
500
- | np .ndarray
501
- | Callable [[HashableT ], bool ]
502
- | None
511
+ SequenceNotStr [Hashable ] | range | AnyArrayLike | Callable [[HashableT ], bool ] | None
503
512
)
504
513
# Scratch types for generics
505
514
0 commit comments