Skip to content

Commit be888f8

Browse files
committed
Globally drop support for the since go-IPFS 0.5 useless return_result parameter
1 parent 807d0a5 commit be888f8

File tree

3 files changed

+13
-70
lines changed

3 files changed

+13
-70
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ py-ipfs-http-client 0.8.0 (XX.XX.20XX)
1414
**Breaking changes in this release**:
1515

1616
* Dropped support for the (previously deprecated) `return_result` parameter of `.repo.gc(…)`
17+
* Dropped support for the previously deprecated and always undocumented `return_result` parameter everywhere else
1718

1819
py-ipfs-http-client 0.7.0 (15.03.2021)
1920
--------------------------------------

ipfshttpclient/client/base.py

+9-32
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
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

168167
class _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

174173
class _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

219207
class _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 "

ipfshttpclient/http_common.py

+3-38
Original file line numberDiff line numberDiff line change
@@ -449,23 +449,6 @@ def _request(
449449
...
450450

451451
#XXX: There must be some way to make the following shorter…
452-
@ty.overload
453-
def request(
454-
self, path: str,
455-
args: ty.Sequence[str] = [], *,
456-
opts: ty.Mapping[str, str] = {},
457-
decoder: str = "none",
458-
stream: bool = False,
459-
offline: bool = False,
460-
return_result: utils.Literal_False,
461-
auth: auth_t = None,
462-
cookies: cookies_t = None,
463-
data: reqdata_sync_t = None,
464-
headers: headers_t = None,
465-
timeout: timeout_t = None
466-
) -> None:
467-
...
468-
469452
@ty.overload
470453
def request(
471454
self, path: str,
@@ -474,7 +457,6 @@ def request(
474457
decoder: ty_Literal_none = "none",
475458
stream: utils.Literal_False = False,
476459
offline: bool = False,
477-
return_result: utils.Literal_True = True,
478460
auth: auth_t = None,
479461
cookies: cookies_t = None,
480462
data: reqdata_sync_t = None,
@@ -491,7 +473,6 @@ def request(
491473
decoder: ty_Literal_none = "none",
492474
stream: utils.Literal_True,
493475
offline: bool = False,
494-
return_result: utils.Literal_True = True,
495476
auth: auth_t = None,
496477
cookies: cookies_t = None,
497478
data: reqdata_sync_t = None,
@@ -508,7 +489,6 @@ def request(
508489
decoder: ty_Literal_json,
509490
stream: utils.Literal_False = False,
510491
offline: bool = False,
511-
return_result: utils.Literal_True = True,
512492
auth: auth_t = None,
513493
cookies: cookies_t = None,
514494
data: reqdata_sync_t = None,
@@ -525,7 +505,6 @@ def request(
525505
decoder: ty_Literal_json,
526506
stream: utils.Literal_True,
527507
offline: bool = False,
528-
return_result: utils.Literal_True = True,
529508
auth: auth_t = None,
530509
cookies: cookies_t = None,
531510
data: reqdata_sync_t = None,
@@ -535,20 +514,19 @@ def request(
535514
...
536515

537516

538-
def request( # type: ignore[misc]
517+
def request(
539518
self, path: str,
540519
args: ty.Sequence[str] = [], *,
541520
opts: ty.Mapping[str, str] = {},
542521
decoder: ty.Union[ty_Literal_json, ty_Literal_none] = "none",
543522
stream: bool = False,
544523
offline: bool = False,
545-
return_result: bool = True,
546524
auth: auth_t = None,
547525
cookies: cookies_t = None,
548526
data: reqdata_sync_t = None,
549527
headers: headers_t = None,
550528
timeout: timeout_t = None
551-
) -> ty.Optional[ty.Union[ # noqa: ET122 (checker bug)
529+
) -> ty.Optional[ty.Union[
552530
StreamDecodeIteratorSync[bytes],
553531
StreamDecodeIteratorSync[utils.json_dict_t],
554532
bytes,
@@ -583,8 +561,6 @@ def request( # type: ignore[misc]
583561
Query string parameters to be sent along with the HTTP request
584562
offline
585563
Whether to request to daemon to handle this request in “offline-mode”
586-
return_result
587-
Whether to decode the values received from the daemon
588564
auth
589565
Authentication data to send along with this request as
590566
``(username, password)`` tuple
@@ -600,11 +576,6 @@ def request( # type: ignore[misc]
600576
601577
Set this to :py:`math.inf` to disable timeouts entirely.
602578
"""
603-
# Don't attempt to decode response or stream
604-
# (which would keep an iterator open that will then never be waited for)
605-
if not return_result:
606-
decoder = "none"
607-
608579
method = "POST"
609580
parser = encoding.get_encoding(decoder)
610581

@@ -614,11 +585,7 @@ def request( # type: ignore[misc]
614585
chunk_size=None,
615586
) # type: ty.Tuple[ty.List[Closable], ty.Generator[bytes, ty.Any, ty.Any]]
616587
try:
617-
if not return_result:
618-
for closable in closables:
619-
closable.close()
620-
return None
621-
elif stream:
588+
if stream:
622589
# Decode each item as it is read
623590
return StreamDecodeIteratorSync(closables, res, parser) # type: ignore[misc]
624591
else:
@@ -682,8 +649,6 @@ def download(
682649
daemon on ``localhost``.
683650
offline
684651
Whether to request to daemon to handle this request in “offline-mode”
685-
return_result
686-
Whether to decode the values received from the daemon
687652
auth
688653
Authentication data to send along with this request as
689654
``(username, password)`` tuple

0 commit comments

Comments
 (0)