From 0f2ea505aa8ca298c1726d57fa565187d3032d8c Mon Sep 17 00:00:00 2001 From: Jochem Smit Date: Tue, 2 Jan 2024 14:04:28 +0100 Subject: [PATCH] typing fixes --- hdxms_datasets/datavault.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hdxms_datasets/datavault.py b/hdxms_datasets/datavault.py index 22cb983..5e79ef6 100644 --- a/hdxms_datasets/datavault.py +++ b/hdxms_datasets/datavault.py @@ -94,6 +94,7 @@ def fetch_dataset(self, data_id: str) -> bool: files = ["hdx_spec.yaml", "metadata.yaml"] optional_files = ["CITATION.cff"] + hdx_spec = None for f in files + optional_files: url = urllib.parse.urljoin(dataset_url, f) response = requests.get(url) @@ -103,12 +104,19 @@ def fetch_dataset(self, data_id: str) -> bool: elif f in files: raise urllib.error.HTTPError( - url, response.status_code, f"Error for file {f!r}", response.headers, None + url, + response.status_code, + f"Error for file {f!r}", + response.headers, # type: ignore + None, ) if f == "hdx_spec.yaml": hdx_spec = yaml.safe_load(response.text) + if hdx_spec is None: + raise ValueError(f"Could not find HDX spec for data_id {data_id!r}") + data_pth = output_pth / "data" data_pth.mkdir() @@ -124,7 +132,7 @@ def fetch_dataset(self, data_id: str) -> bool: f_url, response.status_code, f"Error for data file {filename!r}", - response.headers, + response.headers, # type: ignore None, )