@@ -44,7 +44,8 @@ Literal: _SpecialForm
44
44
45
45
T = TypeVar ('T' )
46
46
T_co = TypeVar ('T_co' , covariant = True )
47
- T_contra = TypeVar ('T_contra' , contravariant = True )
47
+ R_co = TypeVar ('R_co' , covariant = True )
48
+ S_contra = TypeVar ('S_contra' , contravariant = True )
48
49
U = TypeVar ('U' )
49
50
V = TypeVar ('V' )
50
51
S = TypeVar ('S' )
@@ -82,9 +83,9 @@ class Iterator(Iterable[T_co], Protocol):
82
83
@abstractmethod
83
84
def __next__ (self ) -> T_co : pass
84
85
85
- class Generator (Iterator [T ], Generic [T , U , V ]):
86
+ class Generator (Iterator [T_co ], Generic [T_co , S_contra , R_co ]):
86
87
@abstractmethod
87
- def send (self , value : U ) -> T : pass
88
+ def send (self , value : S_contra ) -> T_co : pass
88
89
89
90
@abstractmethod
90
91
def throw (self , typ : Any , val : Any = None , tb : Any = None ) -> None : pass
@@ -93,35 +94,40 @@ class Generator(Iterator[T], Generic[T, U, V]):
93
94
def close (self ) -> None : pass
94
95
95
96
@abstractmethod
96
- def __iter__ (self ) -> 'Generator[T, U, V ]' : pass
97
+ def __iter__ (self ) -> 'Generator[T_co, S_contra, R_co ]' : pass
97
98
98
- class AsyncGenerator (AsyncIterator [T ], Generic [T , U ]):
99
+ class AsyncGenerator (AsyncIterator [T_co ], Generic [T_co , S_contra ]):
99
100
@abstractmethod
100
- def __anext__ (self ) -> Awaitable [T ]: pass
101
+ def __anext__ (self ) -> Awaitable [T_co ]: pass
101
102
102
103
@abstractmethod
103
- def asend (self , value : U ) -> Awaitable [T ]: pass
104
+ def asend (self , value : S_contra ) -> Awaitable [T_co ]: pass
104
105
105
106
@abstractmethod
106
- def athrow (self , typ : Any , val : Any = None , tb : Any = None ) -> Awaitable [T ]: pass
107
+ def athrow (self , typ : Any , val : Any = None , tb : Any = None ) -> Awaitable [T_co ]: pass
107
108
108
109
@abstractmethod
109
- def aclose (self ) -> Awaitable [T ]: pass
110
+ def aclose (self ) -> Awaitable [T_co ]: pass
110
111
111
112
@abstractmethod
112
- def __aiter__ (self ) -> 'AsyncGenerator[T, U ]' : pass
113
+ def __aiter__ (self ) -> 'AsyncGenerator[T_co, S_contra ]' : pass
113
114
114
115
@runtime_checkable
115
- class Awaitable (Protocol [T ]):
116
+ class Awaitable (Protocol [T_co ]):
116
117
@abstractmethod
117
- def __await__ (self ) -> Generator [Any , Any , T ]: pass
118
+ def __await__ (self ) -> Generator [Any , Any , T_co ]: pass
118
119
119
- class AwaitableGenerator (Generator [T , U , V ], Awaitable [V ], Generic [T , U , V , S ], metaclass = ABCMeta ):
120
+ class AwaitableGenerator (
121
+ Awaitable [R_co ],
122
+ Generator [T_co , S_contra , R_co ],
123
+ Generic [T_co , S_contra , R_co , S ],
124
+ metaclass = ABCMeta
125
+ ):
120
126
pass
121
127
122
- class Coroutine (Awaitable [V ], Generic [T , U , V ]):
128
+ class Coroutine (Awaitable [R_co ], Generic [T_co , S_contra , R_co ]):
123
129
@abstractmethod
124
- def send (self , value : U ) -> T : pass
130
+ def send (self , value : S_contra ) -> T_co : pass
125
131
126
132
@abstractmethod
127
133
def throw (self , typ : Any , val : Any = None , tb : Any = None ) -> None : pass
@@ -130,15 +136,15 @@ class Coroutine(Awaitable[V], Generic[T, U, V]):
130
136
def close (self ) -> None : pass
131
137
132
138
@runtime_checkable
133
- class AsyncIterable (Protocol [T ]):
139
+ class AsyncIterable (Protocol [T_co ]):
134
140
@abstractmethod
135
- def __aiter__ (self ) -> 'AsyncIterator[T ]' : pass
141
+ def __aiter__ (self ) -> 'AsyncIterator[T_co ]' : pass
136
142
137
143
@runtime_checkable
138
- class AsyncIterator (AsyncIterable [T ], Protocol ):
139
- def __aiter__ (self ) -> 'AsyncIterator[T ]' : return self
144
+ class AsyncIterator (AsyncIterable [T_co ], Protocol ):
145
+ def __aiter__ (self ) -> 'AsyncIterator[T_co ]' : return self
140
146
@abstractmethod
141
- def __anext__ (self ) -> Awaitable [T ]: pass
147
+ def __anext__ (self ) -> Awaitable [T_co ]: pass
142
148
143
149
class Sequence (Iterable [T_co ], Container [T_co ]):
144
150
@abstractmethod
0 commit comments