4141 # This is what type checkers should actually use
4242 CommonArgs = ty .TypedDict ("CommonArgs" , {
4343 "offline" : bool ,
44- "return_result" : bool ,
4544 "auth" : http .auth_t ,
4645 "cookies" : http .cookies_t ,
4746 "data" : http .reqdata_sync_t ,
@@ -167,25 +166,18 @@ def close(self) -> None:
167166
168167class _inner_func_t (ty_ext .Protocol , ty .Generic [T ]):
169168 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 ]]:
171170 ...
172171
173172
174173class _returns_multiple_wrapper2_t (ty_ext .Protocol , ty .Generic [T , R ]):
175174 @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 ]:
178176 ...
179177
180178 @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 ]:
189181 ...
190182
191183
@@ -199,14 +191,10 @@ def returns_multiple_items(item_wrap_cb: wrap_cb_t[T, R] = ident, *, stream: boo
199191 def wrapper1 (func : _inner_func_t [T ]) -> _returns_multiple_wrapper2_t [T , R ]:
200192 @functools .wraps (func )
201193 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 ]]:
203195 result = func (* args , ** kwargs )
204196 if isinstance (result , list ):
205197 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
210198 assert kwargs .get ("stream" , False ) or stream , (
211199 "Called IPFS HTTP-Client function should only ever return a list, "
212200 "when not streaming a response"
@@ -218,19 +206,12 @@ def wrapper2(*args: ty.Any, **kwargs: ty.Any) \
218206
219207class _returns_single_wrapper2_t (ty_ext .Protocol , ty .Generic [T , R ]):
220208 @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 :
223210 ...
224211
225212 @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 ]:
234215 ...
235216
236217
@@ -243,16 +224,12 @@ def returns_single_item(item_wrap_cb: wrap_cb_t[T, R] = ident, *, stream: bool =
243224 -> _returns_single_wrapper1_t [T , R ]:
244225 def wrapper1 (func : _inner_func_t [T ]) -> _returns_single_wrapper2_t [T , R ]:
245226 @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 ]]:
248228 result = func (* args , ** kwargs )
249229 if isinstance (result , list ):
250230 assert len (result ) == 1 , ("Called IPFS HTTP-Client function should "
251231 "only ever return one item" )
252232 return item_wrap_cb (result [0 ])
253- if result is None :
254- assert not kwargs .get ("return_result" , True )
255- return None
256233
257234 assert kwargs .get ("stream" , False ) or stream , (
258235 "Called IPFS HTTP-Client function should only ever return a list "
0 commit comments