@@ -401,8 +401,8 @@ class Reversible(Iterable[_T_co], Protocol[_T_co]):
401
401
def __reversed__ (self ) -> Iterator [_T_co ]: ...
402
402
403
403
_YieldT_co = TypeVar ("_YieldT_co" , covariant = True )
404
- _SendT_contra = TypeVar ("_SendT_contra" , contravariant = True )
405
- _ReturnT_co = TypeVar ("_ReturnT_co" , covariant = True )
404
+ _SendT_contra = TypeVar ("_SendT_contra" , contravariant = True , default = None )
405
+ _ReturnT_co = TypeVar ("_ReturnT_co" , covariant = True , default = None )
406
406
407
407
class Generator (Iterator [_YieldT_co ], Generic [_YieldT_co , _SendT_contra , _ReturnT_co ]):
408
408
def __next__ (self ) -> _YieldT_co : ...
@@ -444,7 +444,11 @@ class Awaitable(Protocol[_T_co]):
444
444
@abstractmethod
445
445
def __await__ (self ) -> Generator [Any , Any , _T_co ]: ...
446
446
447
- class Coroutine (Awaitable [_ReturnT_co ], Generic [_YieldT_co , _SendT_contra , _ReturnT_co ]):
447
+ # Non-default variations to accommodate couroutines, and `AwaitableGenerator` having a 4th type parameter.
448
+ _SendT_contra_nd = TypeVar ("_SendT_contra_nd" , contravariant = True )
449
+ _ReturnT_co_nd = TypeVar ("_ReturnT_co_nd" , covariant = True )
450
+
451
+ class Coroutine (Awaitable [_ReturnT_co_nd ], Generic [_YieldT_co , _SendT_contra_nd , _ReturnT_co_nd ]):
448
452
__name__ : str
449
453
__qualname__ : str
450
454
@property
@@ -456,7 +460,7 @@ class Coroutine(Awaitable[_ReturnT_co], Generic[_YieldT_co, _SendT_contra, _Retu
456
460
@property
457
461
def cr_running (self ) -> bool : ...
458
462
@abstractmethod
459
- def send (self , value : _SendT_contra , / ) -> _YieldT_co : ...
463
+ def send (self , value : _SendT_contra_nd , / ) -> _YieldT_co : ...
460
464
@overload
461
465
@abstractmethod
462
466
def throw (
@@ -472,9 +476,9 @@ class Coroutine(Awaitable[_ReturnT_co], Generic[_YieldT_co, _SendT_contra, _Retu
472
476
# The parameters correspond to Generator, but the 4th is the original type.
473
477
@type_check_only
474
478
class AwaitableGenerator (
475
- Awaitable [_ReturnT_co ],
476
- Generator [_YieldT_co , _SendT_contra , _ReturnT_co ],
477
- Generic [_YieldT_co , _SendT_contra , _ReturnT_co , _S ],
479
+ Awaitable [_ReturnT_co_nd ],
480
+ Generator [_YieldT_co , _SendT_contra_nd , _ReturnT_co_nd ],
481
+ Generic [_YieldT_co , _SendT_contra_nd , _ReturnT_co_nd , _S ],
478
482
metaclass = ABCMeta ,
479
483
): ...
480
484
0 commit comments