@@ -5,6 +5,8 @@ import types
5
5
from _collections_abc import dict_items , dict_keys , dict_values
6
6
from _typeshed import (
7
7
AnyStr_co ,
8
+ ConvertibleToFloat ,
9
+ ConvertibleToInt ,
8
10
FileDescriptorOrPath ,
9
11
OpenBinaryMode ,
10
12
OpenBinaryModeReading ,
@@ -24,7 +26,6 @@ from _typeshed import (
24
26
SupportsRDivMod ,
25
27
SupportsRichComparison ,
26
28
SupportsRichComparisonT ,
27
- SupportsTrunc ,
28
29
SupportsWrite ,
29
30
)
30
31
from collections .abc import Awaitable , Callable , Iterable , Iterator , MutableSet , Reversible , Set as AbstractSet , Sized
@@ -48,7 +49,6 @@ from typing import ( # noqa: Y022
48
49
SupportsBytes ,
49
50
SupportsComplex ,
50
51
SupportsFloat ,
51
- SupportsInt ,
52
52
TypeVar ,
53
53
overload ,
54
54
type_check_only ,
@@ -220,7 +220,7 @@ _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026
220
220
221
221
class int :
222
222
@overload
223
- def __new__ (cls , __x : str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> Self : ...
223
+ def __new__ (cls , __x : ConvertibleToInt = ...) -> Self : ...
224
224
@overload
225
225
def __new__ (cls , __x : str | bytes | bytearray , base : SupportsIndex ) -> Self : ...
226
226
if sys .version_info >= (3 , 8 ):
@@ -326,7 +326,7 @@ class int:
326
326
def __index__ (self ) -> int : ...
327
327
328
328
class float :
329
- def __new__ (cls , __x : SupportsFloat | SupportsIndex | str | ReadableBuffer = ...) -> Self : ...
329
+ def __new__ (cls , __x : ConvertibleToFloat = ...) -> Self : ...
330
330
def as_integer_ratio (self ) -> tuple [int , int ]: ...
331
331
def hex (self ) -> str : ...
332
332
def is_integer (self ) -> bool : ...
@@ -774,7 +774,7 @@ class memoryview(Sequence[int]):
774
774
def contiguous (self ) -> bool : ...
775
775
@property
776
776
def nbytes (self ) -> int : ...
777
- def __init__ ( self , obj : ReadableBuffer ) -> None : ...
777
+ def __new__ ( cls , obj : ReadableBuffer ) -> Self : ...
778
778
def __enter__ (self ) -> Self : ...
779
779
def __exit__ (
780
780
self , __exc_type : type [BaseException ] | None , __exc_val : BaseException | None , __exc_tb : TracebackType | None
@@ -853,9 +853,9 @@ class slice:
853
853
@property
854
854
def stop (self ) -> Any : ...
855
855
@overload
856
- def __init__ ( self , __stop : Any ) -> None : ...
856
+ def __new__ ( cls , __stop : Any ) -> Self : ...
857
857
@overload
858
- def __init__ ( self , __start : Any , __stop : Any , __step : Any = ...) -> None : ...
858
+ def __new__ ( cls , __start : Any , __stop : Any , __step : Any = ...) -> Self : ...
859
859
def __eq__ (self , __value : object ) -> bool : ...
860
860
__hash__ : ClassVar [None ] # type: ignore[assignment]
861
861
def indices (self , __len : SupportsIndex ) -> tuple [int , int , int ]: ...
@@ -1110,7 +1110,7 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]):
1110
1110
def __class_getitem__ (cls , __item : Any ) -> GenericAlias : ...
1111
1111
1112
1112
class enumerate (Iterator [tuple [int , _T ]], Generic [_T ]):
1113
- def __init__ ( self , iterable : Iterable [_T ], start : int = ...) -> None : ...
1113
+ def __new__ ( cls , iterable : Iterable [_T ], start : int = ...) -> Self : ...
1114
1114
def __iter__ (self ) -> Self : ...
1115
1115
def __next__ (self ) -> tuple [int , _T ]: ...
1116
1116
if sys .version_info >= (3 , 9 ):
@@ -1125,9 +1125,9 @@ class range(Sequence[int]):
1125
1125
@property
1126
1126
def step (self ) -> int : ...
1127
1127
@overload
1128
- def __init__ ( self , __stop : SupportsIndex ) -> None : ...
1128
+ def __new__ ( cls , __stop : SupportsIndex ) -> Self : ...
1129
1129
@overload
1130
- def __init__ ( self , __start : SupportsIndex , __stop : SupportsIndex , __step : SupportsIndex = ...) -> None : ...
1130
+ def __new__ ( cls , __start : SupportsIndex , __stop : SupportsIndex , __step : SupportsIndex = ...) -> Self : ...
1131
1131
def count (self , __value : int ) -> int : ...
1132
1132
def index (self , __value : int ) -> int : ... # type: ignore[override]
1133
1133
def __len__ (self ) -> int : ...
@@ -1320,11 +1320,11 @@ def exit(code: sys._ExitCode = None) -> NoReturn: ...
1320
1320
1321
1321
class filter (Iterator [_T ], Generic [_T ]):
1322
1322
@overload
1323
- def __init__ ( self , __function : None , __iterable : Iterable [_T | None ]) -> None : ...
1323
+ def __new__ ( cls , __function : None , __iterable : Iterable [_T | None ]) -> Self : ...
1324
1324
@overload
1325
- def __init__ ( self , __function : Callable [[_S ], TypeGuard [_T ]], __iterable : Iterable [_S ]) -> None : ...
1325
+ def __new__ ( cls , __function : Callable [[_S ], TypeGuard [_T ]], __iterable : Iterable [_S ]) -> Self : ...
1326
1326
@overload
1327
- def __init__ ( self , __function : Callable [[_T ], Any ], __iterable : Iterable [_T ]) -> None : ...
1327
+ def __new__ ( cls , __function : Callable [[_T ], Any ], __iterable : Iterable [_T ]) -> Self : ...
1328
1328
def __iter__ (self ) -> Self : ...
1329
1329
def __next__ (self ) -> _T : ...
1330
1330
@@ -1379,35 +1379,35 @@ def locals() -> dict[str, Any]: ...
1379
1379
1380
1380
class map (Iterator [_S ], Generic [_S ]):
1381
1381
@overload
1382
- def __init__ ( self , __func : Callable [[_T1 ], _S ], __iter1 : Iterable [_T1 ]) -> None : ...
1382
+ def __new__ ( cls , __func : Callable [[_T1 ], _S ], __iter1 : Iterable [_T1 ]) -> Self : ...
1383
1383
@overload
1384
- def __init__ ( self , __func : Callable [[_T1 , _T2 ], _S ], __iter1 : Iterable [_T1 ], __iter2 : Iterable [_T2 ]) -> None : ...
1384
+ def __new__ ( cls , __func : Callable [[_T1 , _T2 ], _S ], __iter1 : Iterable [_T1 ], __iter2 : Iterable [_T2 ]) -> Self : ...
1385
1385
@overload
1386
- def __init__ (
1387
- self , __func : Callable [[_T1 , _T2 , _T3 ], _S ], __iter1 : Iterable [_T1 ], __iter2 : Iterable [_T2 ], __iter3 : Iterable [_T3 ]
1388
- ) -> None : ...
1386
+ def __new__ (
1387
+ cls , __func : Callable [[_T1 , _T2 , _T3 ], _S ], __iter1 : Iterable [_T1 ], __iter2 : Iterable [_T2 ], __iter3 : Iterable [_T3 ]
1388
+ ) -> Self : ...
1389
1389
@overload
1390
- def __init__ (
1391
- self ,
1390
+ def __new__ (
1391
+ cls ,
1392
1392
__func : Callable [[_T1 , _T2 , _T3 , _T4 ], _S ],
1393
1393
__iter1 : Iterable [_T1 ],
1394
1394
__iter2 : Iterable [_T2 ],
1395
1395
__iter3 : Iterable [_T3 ],
1396
1396
__iter4 : Iterable [_T4 ],
1397
- ) -> None : ...
1397
+ ) -> Self : ...
1398
1398
@overload
1399
- def __init__ (
1400
- self ,
1399
+ def __new__ (
1400
+ cls ,
1401
1401
__func : Callable [[_T1 , _T2 , _T3 , _T4 , _T5 ], _S ],
1402
1402
__iter1 : Iterable [_T1 ],
1403
1403
__iter2 : Iterable [_T2 ],
1404
1404
__iter3 : Iterable [_T3 ],
1405
1405
__iter4 : Iterable [_T4 ],
1406
1406
__iter5 : Iterable [_T5 ],
1407
- ) -> None : ...
1407
+ ) -> Self : ...
1408
1408
@overload
1409
- def __init__ (
1410
- self ,
1409
+ def __new__ (
1410
+ cls ,
1411
1411
__func : Callable [..., _S ],
1412
1412
__iter1 : Iterable [Any ],
1413
1413
__iter2 : Iterable [Any ],
@@ -1416,7 +1416,7 @@ class map(Iterator[_S], Generic[_S]):
1416
1416
__iter5 : Iterable [Any ],
1417
1417
__iter6 : Iterable [Any ],
1418
1418
* iterables : Iterable [Any ],
1419
- ) -> None : ...
1419
+ ) -> Self : ...
1420
1420
def __iter__ (self ) -> Self : ...
1421
1421
def __next__ (self ) -> _S : ...
1422
1422
@@ -1725,6 +1725,8 @@ def vars(__object: Any = ...) -> dict[str, Any]: ...
1725
1725
1726
1726
class zip (Iterator [_T_co ], Generic [_T_co ]):
1727
1727
if sys .version_info >= (3 , 10 ):
1728
+ @overload
1729
+ def __new__ (cls , * , strict : bool = ...) -> zip [Any ]: ...
1728
1730
@overload
1729
1731
def __new__ (cls , __iter1 : Iterable [_T1 ], * , strict : bool = ...) -> zip [tuple [_T1 ]]: ...
1730
1732
@overload
@@ -1767,6 +1769,8 @@ class zip(Iterator[_T_co], Generic[_T_co]):
1767
1769
strict : bool = ...,
1768
1770
) -> zip [tuple [Any , ...]]: ...
1769
1771
else :
1772
+ @overload
1773
+ def __new__ (cls ) -> zip [Any ]: ...
1770
1774
@overload
1771
1775
def __new__ (cls , __iter1 : Iterable [_T1 ]) -> zip [tuple [_T1 ]]: ...
1772
1776
@overload
@@ -1812,11 +1816,17 @@ def __import__(
1812
1816
) -> types .ModuleType : ...
1813
1817
def __build_class__ (__func : Callable [[], _Cell | Any ], __name : str , * bases : Any , metaclass : Any = ..., ** kwds : Any ) -> Any : ...
1814
1818
1815
- # Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
1816
- # not exposed anywhere under that name, we make it private here.
1817
- @final
1818
- @type_check_only
1819
- class ellipsis : ...
1819
+ if sys .version_info >= (3 , 10 ):
1820
+ # In Python 3.10, EllipsisType is exposed publicly in the types module.
1821
+ @final
1822
+ class ellipsis : ...
1823
+
1824
+ else :
1825
+ # Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
1826
+ # not exposed anywhere under that name, we make it private here.
1827
+ @final
1828
+ @type_check_only
1829
+ class ellipsis : ...
1820
1830
1821
1831
Ellipsis : ellipsis
1822
1832
0 commit comments