41
41
# This is what type checkers should actually use
42
42
CommonArgs = ty .TypedDict ("CommonArgs" , {
43
43
"offline" : bool ,
44
- "return_result" : bool ,
45
44
"auth" : http .auth_t ,
46
45
"cookies" : http .cookies_t ,
47
46
"data" : http .reqdata_sync_t ,
@@ -167,25 +166,18 @@ def close(self) -> None:
167
166
168
167
class _inner_func_t (ty_ext .Protocol , ty .Generic [T ]):
169
168
def __call__ (self , * args : ty .Any , ** kwargs : ty .Any ) \
170
- -> ty .Union [ty .List [T ], http .StreamDecodeIteratorSync [T ], None ]:
169
+ -> ty .Union [ty .List [T ], http .StreamDecodeIteratorSync [T ]]:
171
170
...
172
171
173
172
174
173
class _returns_multiple_wrapper2_t (ty_ext .Protocol , ty .Generic [T , R ]):
175
174
@ty .overload
176
- def __call__ (self , * args : ty .Any , stream : bool = ...,
177
- return_result : utils .Literal_False , ** kwargs : ty .Any ) -> None :
175
+ def __call__ (self , * args : ty .Any , stream : utils .Literal_True , ** kwargs : ty .Any ) -> ty .List [R ]:
178
176
...
179
177
180
178
@ty .overload
181
- def __call__ (self , * args : ty .Any , stream : utils .Literal_True ,
182
- return_result : utils .Literal_True = ..., ** kwargs : ty .Any ) -> ty .List [R ]:
183
- ...
184
-
185
- @ty .overload
186
- def __call__ (self , * args : ty .Any , stream : utils .Literal_False = ...,
187
- return_result : utils .Literal_True = ..., ** kwargs : ty .Any
188
- ) -> ResponseWrapIterator [T , R ]:
179
+ def __call__ (self , * args : ty .Any , stream : utils .Literal_False = ..., ** kwargs : ty .Any ) \
180
+ -> ResponseWrapIterator [T , R ]:
189
181
...
190
182
191
183
@@ -199,14 +191,10 @@ def returns_multiple_items(item_wrap_cb: wrap_cb_t[T, R] = ident, *, stream: boo
199
191
def wrapper1 (func : _inner_func_t [T ]) -> _returns_multiple_wrapper2_t [T , R ]:
200
192
@functools .wraps (func )
201
193
def wrapper2 (* args : ty .Any , ** kwargs : ty .Any ) \
202
- -> ty .Union [None , ty .List [R ], ResponseWrapIterator [T , R ]]:
194
+ -> ty .Union [ty .List [R ], ResponseWrapIterator [T , R ]]:
203
195
result = func (* args , ** kwargs )
204
196
if isinstance (result , list ):
205
197
return [item_wrap_cb (r ) for r in result ]
206
- if result is None :
207
- # WORKAROUND: Remove the `or …` part in 0.7.X
208
- assert not kwargs .get ("return_result" , True ) or kwargs .get ("quiet" , False )
209
- return None
210
198
assert kwargs .get ("stream" , False ) or stream , (
211
199
"Called IPFS HTTP-Client function should only ever return a list, "
212
200
"when not streaming a response"
@@ -218,19 +206,12 @@ def wrapper2(*args: ty.Any, **kwargs: ty.Any) \
218
206
219
207
class _returns_single_wrapper2_t (ty_ext .Protocol , ty .Generic [T , R ]):
220
208
@ty .overload
221
- def __call__ (self , * args : ty .Any , stream : bool = ...,
222
- return_result : utils .Literal_False , ** kwargs : ty .Any ) -> None :
209
+ def __call__ (self , * args : ty .Any , stream : utils .Literal_True , ** kwargs : ty .Any ) -> R :
223
210
...
224
211
225
212
@ty .overload
226
- def __call__ (self , * args : ty .Any , stream : utils .Literal_True ,
227
- return_result : utils .Literal_True = ..., ** kwargs : ty .Any ) -> R :
228
- ...
229
-
230
- @ty .overload
231
- def __call__ (self , * args : ty .Any , stream : utils .Literal_False = ...,
232
- return_result : utils .Literal_True = ..., ** kwargs : ty .Any
233
- ) -> ResponseWrapIterator [T , R ]:
213
+ def __call__ (self , * args : ty .Any , stream : utils .Literal_False = ..., ** kwargs : ty .Any ) \
214
+ -> ResponseWrapIterator [T , R ]:
234
215
...
235
216
236
217
@@ -243,16 +224,12 @@ def returns_single_item(item_wrap_cb: wrap_cb_t[T, R] = ident, *, stream: bool =
243
224
-> _returns_single_wrapper1_t [T , R ]:
244
225
def wrapper1 (func : _inner_func_t [T ]) -> _returns_single_wrapper2_t [T , R ]:
245
226
@functools .wraps (func )
246
- def wrapper2 (* args : ty .Any , ** kwargs : ty .Any ) \
247
- -> ty .Union [None , R , ResponseWrapIterator [T , R ]]:
227
+ def wrapper2 (* args : ty .Any , ** kwargs : ty .Any ) -> ty .Union [R , ResponseWrapIterator [T , R ]]:
248
228
result = func (* args , ** kwargs )
249
229
if isinstance (result , list ):
250
230
assert len (result ) == 1 , ("Called IPFS HTTP-Client function should "
251
231
"only ever return one item" )
252
232
return item_wrap_cb (result [0 ])
253
- if result is None :
254
- assert not kwargs .get ("return_result" , True )
255
- return None
256
233
257
234
assert kwargs .get ("stream" , False ) or stream , (
258
235
"Called IPFS HTTP-Client function should only ever return a list "
0 commit comments