@@ -11,8 +11,11 @@ from _typeshed import (
11
11
ReadableBuffer ,
12
12
Self ,
13
13
StrOrBytesPath ,
14
+ SupportsAdd ,
15
+ SupportsAiter ,
14
16
SupportsAnext ,
15
17
SupportsDivMod ,
18
+ SupportsIter ,
16
19
SupportsKeysAndGetItem ,
17
20
SupportsLenAndGetItem ,
18
21
SupportsNext ,
@@ -71,12 +74,6 @@ _SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant
71
74
_AwaitableT = TypeVar ("_AwaitableT" , bound = Awaitable [Any ])
72
75
_AwaitableT_co = TypeVar ("_AwaitableT_co" , bound = Awaitable [Any ], covariant = True )
73
76
74
- class _SupportsIter (Protocol [_T_co ]):
75
- def __iter__ (self ) -> _T_co : ...
76
-
77
- class _SupportsAiter (Protocol [_T_co ]):
78
- def __aiter__ (self ) -> _T_co : ...
79
-
80
77
class object :
81
78
__doc__ : str | None
82
79
__dict__ : dict [str , Any ]
@@ -122,7 +119,8 @@ class staticmethod(Generic[_R_co]):
122
119
if sys .version_info >= (3 , 10 ):
123
120
__name__ : str
124
121
__qualname__ : str
125
- __wrapped__ : Callable [..., _R_co ]
122
+ @property
123
+ def __wrapped__ (self ) -> Callable [..., _R_co ]: ...
126
124
def __call__ (self , * args : Any , ** kwargs : Any ) -> _R_co : ...
127
125
128
126
class classmethod (Generic [_R_co ]):
@@ -135,7 +133,8 @@ class classmethod(Generic[_R_co]):
135
133
if sys .version_info >= (3 , 10 ):
136
134
__name__ : str
137
135
__qualname__ : str
138
- __wrapped__ : Callable [..., _R_co ]
136
+ @property
137
+ def __wrapped__ (self ) -> Callable [..., _R_co ]: ...
139
138
140
139
class type :
141
140
@property
@@ -251,11 +250,9 @@ class int:
251
250
def __rmod__ (self , __x : int ) -> int : ...
252
251
def __rdivmod__ (self , __x : int ) -> tuple [int , int ]: ...
253
252
@overload
254
- def __pow__ (self , __x : int , __modulo : Literal [0 ]) -> NoReturn : ...
255
- @overload
256
- def __pow__ (self , __x : int , __modulo : int ) -> int : ...
253
+ def __pow__ (self , __x : Literal [0 ]) -> Literal [1 ]: ...
257
254
@overload
258
- def __pow__ (self , __x : Literal [0 ], __modulo : None = ... ) -> Literal [1 ]: ...
255
+ def __pow__ (self , __x : Literal [0 ], __modulo : None ) -> Literal [1 ]: ...
259
256
@overload
260
257
def __pow__ (self , __x : _PositiveInteger , __modulo : None = ...) -> int : ...
261
258
@overload
@@ -264,6 +261,10 @@ class int:
264
261
# return type must be Any as `int | float` causes too many false-positive errors
265
262
@overload
266
263
def __pow__ (self , __x : int , __modulo : None = ...) -> Any : ...
264
+ @overload
265
+ def __pow__ (self , __x : int , __modulo : Literal [0 ]) -> NoReturn : ...
266
+ @overload
267
+ def __pow__ (self , __x : int , __modulo : int ) -> int : ...
267
268
def __rpow__ (self , __x : int , __mod : int | None = ...) -> Any : ...
268
269
def __and__ (self , __n : int ) -> int : ...
269
270
def __or__ (self , __n : int ) -> int : ...
@@ -328,7 +329,12 @@ class float:
328
329
def __rtruediv__ (self , __x : float ) -> float : ...
329
330
def __rmod__ (self , __x : float ) -> float : ...
330
331
def __rdivmod__ (self , __x : float ) -> tuple [float , float ]: ...
331
- # Returns complex if the argument is negative.
332
+ @overload
333
+ def __rpow__ (self , __x : _PositiveInteger , __modulo : None = ...) -> float : ...
334
+ @overload
335
+ def __rpow__ (self , __x : _NegativeInteger , __mod : None = ...) -> complex : ...
336
+ # Returning `complex` for the general case gives too many false-positive errors.
337
+ @overload
332
338
def __rpow__ (self , __x : float , __mod : None = ...) -> Any : ...
333
339
def __getnewargs__ (self ) -> tuple [float ]: ...
334
340
def __trunc__ (self ) -> int : ...
@@ -1092,7 +1098,7 @@ class _PathLike(Protocol[_AnyStr_co]):
1092
1098
def __fspath__ (self ) -> _AnyStr_co : ...
1093
1099
1094
1100
if sys .version_info >= (3 , 10 ):
1095
- def aiter (__async_iterable : _SupportsAiter [_SupportsAnextT ]) -> _SupportsAnextT : ...
1101
+ def aiter (__async_iterable : SupportsAiter [_SupportsAnextT ]) -> _SupportsAnextT : ...
1096
1102
1097
1103
class _SupportsSynchronousAnext (Protocol [_AwaitableT_co ]):
1098
1104
def __anext__ (self ) -> _AwaitableT_co : ...
@@ -1144,9 +1150,22 @@ def eval(
1144
1150
) -> Any : ...
1145
1151
1146
1152
# Comment above regarding `eval` applies to `exec` as well
1147
- def exec (
1148
- __source : str | ReadableBuffer | CodeType , __globals : dict [str , Any ] | None = ..., __locals : Mapping [str , object ] | None = ...
1149
- ) -> None : ...
1153
+ if sys .version_info >= (3 , 11 ):
1154
+ def exec (
1155
+ __source : str | ReadableBuffer | CodeType ,
1156
+ __globals : dict [str , Any ] | None = ...,
1157
+ __locals : Mapping [str , object ] | None = ...,
1158
+ * ,
1159
+ closure : tuple [_Cell , ...] | None = ...,
1160
+ ) -> None : ...
1161
+
1162
+ else :
1163
+ def exec (
1164
+ __source : str | ReadableBuffer | CodeType ,
1165
+ __globals : dict [str , Any ] | None = ...,
1166
+ __locals : Mapping [str , object ] | None = ...,
1167
+ ) -> None : ...
1168
+
1150
1169
def exit (code : object = ...) -> NoReturn : ...
1151
1170
1152
1171
class filter (Iterator [_T ], Generic [_T ]):
@@ -1183,8 +1202,14 @@ def help(request: object = ...) -> None: ...
1183
1202
def hex (__number : int | SupportsIndex ) -> str : ...
1184
1203
def id (__obj : object ) -> int : ...
1185
1204
def input (__prompt : object = ...) -> str : ...
1205
+
1206
+ class _GetItemIterable (Protocol [_T_co ]):
1207
+ def __getitem__ (self , __i : int ) -> _T_co : ...
1208
+
1209
+ @overload
1210
+ def iter (__iterable : SupportsIter [_SupportsNextT ]) -> _SupportsNextT : ...
1186
1211
@overload
1187
- def iter (__iterable : _SupportsIter [ _SupportsNextT ]) -> _SupportsNextT : ...
1212
+ def iter (__iterable : _GetItemIterable [ _T ]) -> Iterator [ _T ] : ...
1188
1213
@overload
1189
1214
def iter (__function : Callable [[], _T | None ], __sentinel : None ) -> Iterator [_T ]: ...
1190
1215
@overload
@@ -1423,6 +1448,10 @@ if sys.version_info >= (3, 8):
1423
1448
@overload
1424
1449
def pow (base : int , exp : int , mod : None = ...) -> Any : ...
1425
1450
@overload
1451
+ def pow (base : _PositiveInteger , exp : float , mod : None = ...) -> float : ...
1452
+ @overload
1453
+ def pow (base : _NegativeInteger , exp : float , mod : None = ...) -> complex : ...
1454
+ @overload
1426
1455
def pow (base : float , exp : int , mod : None = ...) -> float : ...
1427
1456
# float base & float exp could return float or complex
1428
1457
# return type must be Any (same as complex base, complex exp),
@@ -1456,6 +1485,10 @@ else:
1456
1485
@overload
1457
1486
def pow (__base : int , __exp : int , __mod : None = ...) -> Any : ...
1458
1487
@overload
1488
+ def pow (__base : _PositiveInteger , __exp : float , __mod : None = ...) -> float : ...
1489
+ @overload
1490
+ def pow (__base : _NegativeInteger , __exp : float , __mod : None = ...) -> complex : ...
1491
+ @overload
1459
1492
def pow (__base : float , __exp : int , __mod : None = ...) -> float : ...
1460
1493
@overload
1461
1494
def pow (__base : float , __exp : complex | _SupportsSomeKindOfPow , __mod : None = ...) -> Any : ...
@@ -1501,11 +1534,8 @@ def sorted(
1501
1534
@overload
1502
1535
def sorted (__iterable : Iterable [_T ], * , key : Callable [[_T ], SupportsRichComparison ], reverse : bool = ...) -> list [_T ]: ...
1503
1536
1504
- class _SupportsSum (Protocol ):
1505
- def __add__ (self , __x : Any ) -> Any : ...
1506
-
1507
- _SumT = TypeVar ("_SumT" , bound = _SupportsSum )
1508
- _SumS = TypeVar ("_SumS" , bound = _SupportsSum )
1537
+ _SumT = TypeVar ("_SumT" , bound = SupportsAdd )
1538
+ _SumS = TypeVar ("_SumS" , bound = SupportsAdd )
1509
1539
1510
1540
@overload
1511
1541
def sum (__iterable : Iterable [_SumT ]) -> _SumT | Literal [0 ]: ...
0 commit comments