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