@@ -484,9 +484,18 @@ async def send_eof(self):
484
484
"""
485
485
486
486
487
- T = TypeVar ("T" )
487
+ # The type of object produced by a ReceiveChannel (covariant because
488
+ # ReceiveChannel[Derived] can be passed to someone expecting
489
+ # ReceiveChannel[Base])
488
490
T_co = TypeVar ("T_co" , covariant = True )
491
+
492
+ # The type of object accepted by a SendChannel (contravariant because
493
+ # SendChannel[Base] can be passed to someone expecting
494
+ # SendChannel[Derived])
489
495
T_contra = TypeVar ("T_contra" , contravariant = True )
496
+
497
+ # The type of object produced by a Listener (covariant plus must be
498
+ # an AsyncResource)
490
499
T_resource = TypeVar ("T_resource" , bound = AsyncResource , covariant = True )
491
500
492
501
@@ -542,7 +551,7 @@ class SendChannel(AsyncResource, Generic[T_contra]):
542
551
__slots__ = ()
543
552
544
553
@abstractmethod
545
- def send_nowait (self , value : T_contra ) -> None :
554
+ def send_nowait (self , value ) :
546
555
"""Attempt to send an object through the channel, without blocking.
547
556
548
557
Args:
@@ -560,7 +569,7 @@ def send_nowait(self, value: T_contra) -> None:
560
569
"""
561
570
562
571
@abstractmethod
563
- async def send (self , value : T_contra ) -> None :
572
+ async def send (self , value ) :
564
573
"""Attempt to send an object through the channel, blocking if necessary.
565
574
566
575
Args:
@@ -577,7 +586,7 @@ async def send(self, value: T_contra) -> None:
577
586
"""
578
587
579
588
@abstractmethod
580
- def clone (self : T ) -> T :
589
+ def clone (self ) :
581
590
"""Clone this send channel object.
582
591
583
592
This returns a new :class:`SendChannel` object, which acts as a
@@ -625,7 +634,7 @@ class ReceiveChannel(AsyncResource, Generic[T_co]):
625
634
__slots__ = ()
626
635
627
636
@abstractmethod
628
- def receive_nowait (self ) -> T_co :
637
+ def receive_nowait (self ):
629
638
"""Attempt to receive an incoming object, without blocking.
630
639
631
640
Returns:
@@ -644,7 +653,7 @@ def receive_nowait(self) -> T_co:
644
653
"""
645
654
646
655
@abstractmethod
647
- async def receive (self ) -> T_co :
656
+ async def receive (self ):
648
657
"""Attempt to receive an incoming object, blocking if necessary.
649
658
650
659
It's legal for multiple tasks to call :meth:`receive` at the same
@@ -665,7 +674,7 @@ async def receive(self) -> T_co:
665
674
"""
666
675
667
676
@abstractmethod
668
- def clone (self : T ) -> T :
677
+ def clone (self ) :
669
678
"""Clone this receive channel object.
670
679
671
680
This returns a new :class:`ReceiveChannel` object, which acts as a
0 commit comments