Skip to content

Commit

Permalink
Replace response.ok with response.status_code < 400
Browse files Browse the repository at this point in the history
The .ok is part of the requests API [1], but not part of the httpx API.
An equivalent check, according to the requests docs, is to use
response.status_code < 400 (In fact, requests' implementation is a try/except
around raise_for_status, but this should be the same, although we could use the
same pattern instead.)

Note that response.status_code < 400 should work with both, requests and httpx,
and thus remain backwards compatible.

  [1]: https://requests.readthedocs.io/en/latest/api/#requests.Response.ok

Closes #308.
  • Loading branch information
shoeffner committed Jul 16, 2024
1 parent 7d7d514 commit 317162d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion datalad_dataverse/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, api, dsid: str, root_path: str | None = None):
# check if project with specified doi exists
# TODO ask for ':latest' and cache?
dv_ds = api.get_dataset(identifier=dsid)
if not dv_ds.ok:
if not dv_ds.status_code < 400:
raise RuntimeError("Cannot find dataset")

def get_fileid_from_path(
Expand Down

0 comments on commit 317162d

Please sign in to comment.