Skip to content

Commit be8c3c1

Browse files
authored
Fix Jupyter return error instead of raise (#1936)
1 parent 43e60fa commit be8c3c1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

fsspec/implementations/jupyter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def ls(self, path, detail=True, **kwargs):
4242
path = self._strip_protocol(path)
4343
r = self.session.get(f"{self.url}/{path}")
4444
if r.status_code == 404:
45-
return FileNotFoundError(path)
45+
raise FileNotFoundError(path)
4646
r.raise_for_status()
4747
out = r.json()
4848

@@ -63,7 +63,7 @@ def cat_file(self, path, start=None, end=None, **kwargs):
6363
path = self._strip_protocol(path)
6464
r = self.session.get(f"{self.url}/{path}")
6565
if r.status_code == 404:
66-
return FileNotFoundError(path)
66+
raise FileNotFoundError(path)
6767
r.raise_for_status()
6868
out = r.json()
6969
if out["format"] == "text":

fsspec/implementations/tests/test_jupyter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def test_simple(jupyter):
4242
fs = fsspec.filesystem("jupyter", url=url)
4343
assert fs.ls("") == []
4444

45+
with pytest.raises(FileNotFoundError):
46+
fs.ls("not-exist")
47+
with pytest.raises(FileNotFoundError):
48+
fs.cat("not-exist")
49+
4550
fs.pipe("afile", b"data")
4651
assert fs.cat("afile") == b"data"
4752
assert "afile" in os.listdir(d)

0 commit comments

Comments
 (0)