From 317162d644bf46d9bd72e4b127fde787c18c8236 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20H=C3=B6ffner?= <info@sebastian-hoeffner.de>
Date: Wed, 17 Jul 2024 01:08:10 +0200
Subject: [PATCH] Replace `response.ok` with `response.status_code < 400`

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.
---
 datalad_dataverse/dataset.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/datalad_dataverse/dataset.py b/datalad_dataverse/dataset.py
index 7fb8f52..323a01b 100644
--- a/datalad_dataverse/dataset.py
+++ b/datalad_dataverse/dataset.py
@@ -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(