@@ -9,6 +9,7 @@ from _typeshed import (
9
9
ConvertibleToFloat ,
10
10
ConvertibleToInt ,
11
11
FileDescriptorOrPath ,
12
+ MaybeNone ,
12
13
OpenBinaryMode ,
13
14
OpenBinaryModeReading ,
14
15
OpenBinaryModeUpdating ,
@@ -93,6 +94,9 @@ _SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant
93
94
_AwaitableT = TypeVar ("_AwaitableT" , bound = Awaitable [Any ])
94
95
_AwaitableT_co = TypeVar ("_AwaitableT_co" , bound = Awaitable [Any ], covariant = True )
95
96
_P = ParamSpec ("_P" )
97
+ _StartT = TypeVar ("_StartT" , covariant = True , default = Any )
98
+ _StopT = TypeVar ("_StopT" , covariant = True , default = Any )
99
+ _StepT = TypeVar ("_StepT" , covariant = True , default = Any )
96
100
97
101
class object :
98
102
__doc__ : str | None
@@ -786,7 +790,7 @@ class memoryview(Sequence[_I]):
786
790
@overload
787
791
def __setitem__ (self , key : slice , value : ReadableBuffer , / ) -> None : ...
788
792
@overload
789
- def __setitem__ (self , key : SupportsIndex | tuple [SupportsIndex , ...], value : SupportsIndex , / ) -> None : ...
793
+ def __setitem__ (self , key : SupportsIndex | tuple [SupportsIndex , ...], value : _I , / ) -> None : ...
790
794
if sys .version_info >= (3 , 10 ):
791
795
def tobytes (self , order : Literal ["C" , "F" , "A" ] | None = "C" ) -> bytes : ...
792
796
else :
@@ -838,22 +842,31 @@ class bool(int):
838
842
def __invert__ (self ) -> int : ...
839
843
840
844
@final
841
- class slice :
845
+ class slice ( Generic [ _StartT , _StopT , _StepT ]) :
842
846
@property
843
- def start (self ) -> Any : ...
847
+ def start (self ) -> _StartT : ...
844
848
@property
845
- def step (self ) -> Any : ...
849
+ def step (self ) -> _StepT : ...
846
850
@property
847
- def stop (self ) -> Any : ...
851
+ def stop (self ) -> _StopT : ...
848
852
@overload
849
- def __new__ (cls , stop : Any , / ) -> Self : ...
853
+ def __new__ (cls , stop : int | None , / ) -> slice [ int | MaybeNone , int | MaybeNone , int | MaybeNone ] : ...
850
854
@overload
851
- def __new__ (cls , start : Any , stop : Any , step : Any = ..., / ) -> Self : ...
855
+ def __new__ (
856
+ cls , start : int | None , stop : int | None , step : int | None = None , /
857
+ ) -> slice [int | MaybeNone , int | MaybeNone , int | MaybeNone ]: ...
858
+ @overload
859
+ def __new__ (cls , stop : _T2 , / ) -> slice [Any , _T2 , Any ]: ...
860
+ @overload
861
+ def __new__ (cls , start : _T1 , stop : _T2 , / ) -> slice [_T1 , _T2 , Any ]: ...
862
+ @overload
863
+ def __new__ (cls , start : _T1 , stop : _T2 , step : _T3 , / ) -> slice [_T1 , _T2 , _T3 ]: ...
852
864
def __eq__ (self , value : object , / ) -> bool : ...
853
865
if sys .version_info >= (3 , 12 ):
854
866
def __hash__ (self ) -> int : ...
855
867
else :
856
868
__hash__ : ClassVar [None ] # type: ignore[assignment]
869
+
857
870
def indices (self , len : SupportsIndex , / ) -> tuple [int , int , int ]: ...
858
871
859
872
class tuple (Sequence [_T_co ]):
@@ -1117,7 +1130,7 @@ class frozenset(AbstractSet[_T_co]):
1117
1130
if sys .version_info >= (3 , 9 ):
1118
1131
def __class_getitem__ (cls , item : Any , / ) -> GenericAlias : ...
1119
1132
1120
- class enumerate (Iterator [ tuple [ int , _T ] ]):
1133
+ class enumerate (Generic [ _T ]):
1121
1134
def __new__ (cls , iterable : Iterable [_T ], start : int = 0 ) -> Self : ...
1122
1135
def __iter__ (self ) -> Self : ...
1123
1136
def __next__ (self ) -> tuple [int , _T ]: ...
@@ -1311,7 +1324,7 @@ else:
1311
1324
1312
1325
def exit (code : sys ._ExitCode = None ) -> NoReturn : ...
1313
1326
1314
- class filter (Iterator [_T ]):
1327
+ class filter (Generic [_T ]):
1315
1328
@overload
1316
1329
def __new__ (cls , function : None , iterable : Iterable [_T | None ], / ) -> Self : ...
1317
1330
@overload
@@ -1372,7 +1385,7 @@ def len(obj: Sized, /) -> int: ...
1372
1385
def license () -> None : ...
1373
1386
def locals () -> dict [str , Any ]: ...
1374
1387
1375
- class map (Iterator [_S ]):
1388
+ class map (Generic [_S ]):
1376
1389
@overload
1377
1390
def __new__ (cls , func : Callable [[_T1 ], _S ], iter1 : Iterable [_T1 ], / ) -> Self : ...
1378
1391
@overload
@@ -1614,7 +1627,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any: ...
1614
1627
def pow (base : _SupportsSomeKindOfPow , exp : complex , mod : None = None ) -> complex : ...
1615
1628
def quit (code : sys ._ExitCode = None ) -> NoReturn : ...
1616
1629
1617
- class reversed (Iterator [_T ]):
1630
+ class reversed (Generic [_T ]):
1618
1631
@overload
1619
1632
def __new__ (cls , sequence : Reversible [_T ], / ) -> Iterator [_T ]: ... # type: ignore[misc]
1620
1633
@overload
@@ -1675,7 +1688,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
1675
1688
@overload
1676
1689
def vars (object : Any = ..., / ) -> dict [str , Any ]: ...
1677
1690
1678
- class zip (Iterator [_T_co ]):
1691
+ class zip (Generic [_T_co ]):
1679
1692
if sys .version_info >= (3 , 10 ):
1680
1693
@overload
1681
1694
def __new__ (cls , * , strict : bool = ...) -> zip [Any ]: ...
0 commit comments