@@ -2,7 +2,23 @@ import sys
2
2
import typing
3
3
from importlib .abc import _LoaderProtocol
4
4
from importlib .machinery import ModuleSpec
5
- from typing import Any , Awaitable , Callable , Dict , Generic , Iterable , Iterator , Mapping , Optional , Tuple , Type , TypeVar , overload
5
+ from typing import (
6
+ Any ,
7
+ AsyncGenerator ,
8
+ Awaitable ,
9
+ Callable ,
10
+ Dict ,
11
+ Generator ,
12
+ Generic ,
13
+ Iterable ,
14
+ Iterator ,
15
+ Mapping ,
16
+ Optional ,
17
+ Tuple ,
18
+ Type ,
19
+ TypeVar ,
20
+ overload ,
21
+ )
6
22
from typing_extensions import Literal , final
7
23
8
24
# Note, all classes "defined" here require special handling.
@@ -12,6 +28,7 @@ _T_co = TypeVar("_T_co", covariant=True)
12
28
_T_contra = TypeVar ("_T_contra" , contravariant = True )
13
29
_KT = TypeVar ("_KT" )
14
30
_VT = TypeVar ("_VT" )
31
+ _V_co = TypeVar ("_V_co" , covariant = True )
15
32
16
33
class _Cell :
17
34
cell_contents : Any
@@ -142,28 +159,28 @@ class ModuleType:
142
159
__spec__ : Optional [ModuleSpec ]
143
160
def __init__ (self , name : str , doc : Optional [str ] = ...) -> None : ...
144
161
145
- class GeneratorType :
162
+ class GeneratorType ( Generator [ _T_co , _T_contra , _V_co ]) :
146
163
gi_code : CodeType
147
164
gi_frame : FrameType
148
165
gi_running : bool
149
- gi_yieldfrom : Optional [GeneratorType ]
150
- def __iter__ (self ) -> GeneratorType : ...
151
- def __next__ (self ) -> Any : ...
166
+ gi_yieldfrom : Optional [GeneratorType [ _T_co , _T_contra , Any ] ]
167
+ def __iter__ (self ) -> GeneratorType [ _T_co , _T_contra , _V_co ] : ...
168
+ def __next__ (self ) -> _T_co : ...
152
169
def close (self ) -> None : ...
153
- def send (self , __arg : Any ) -> Any : ...
170
+ def send (self , __arg : _T_contra ) -> _T_co : ...
154
171
@overload
155
172
def throw (
156
173
self , __typ : Type [BaseException ], __val : typing .Union [BaseException , object ] = ..., __tb : Optional [TracebackType ] = ...
157
- ) -> Any : ...
174
+ ) -> _T_co : ...
158
175
@overload
159
- def throw (self , __typ : BaseException , __val : None = ..., __tb : Optional [TracebackType ] = ...) -> Any : ...
176
+ def throw (self , __typ : BaseException , __val : None = ..., __tb : Optional [TracebackType ] = ...) -> _T_co : ...
160
177
161
- class AsyncGeneratorType (Generic [_T_co , _T_contra ]):
178
+ class AsyncGeneratorType (AsyncGenerator [_T_co , _T_contra ]):
162
179
ag_await : Optional [Awaitable [Any ]]
163
180
ag_frame : FrameType
164
181
ag_running : bool
165
182
ag_code : CodeType
166
- def __aiter__ (self ) -> Awaitable [ AsyncGeneratorType [_T_co , _T_contra ] ]: ...
183
+ def __aiter__ (self ) -> AsyncGeneratorType [_T_co , _T_contra ]: ...
167
184
def __anext__ (self ) -> Awaitable [_T_co ]: ...
168
185
def asend (self , __val : _T_contra ) -> Awaitable [_T_co ]: ...
169
186
@overload
0 commit comments