Skip to content

Commit e738e2f

Browse files
dstansbyd-v-b
andauthored
Raise more helpful errors in _dereference_path (#3392)
* Raise more helpful errors in _dereference_path * Add some type ignore comments --------- Co-authored-by: Davis Bennett <[email protected]>
1 parent b483543 commit e738e2f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/zarr/storage/_common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@
3131

3232

3333
def _dereference_path(root: str, path: str) -> str:
34-
assert isinstance(root, str)
35-
assert isinstance(path, str)
34+
if not isinstance(root, str):
35+
msg = f"{root=} is not a string ({type(root)=})" # type: ignore[unreachable]
36+
raise TypeError(msg)
37+
if not isinstance(path, str):
38+
msg = f"{path=} is not a string ({type(path)=})" # type: ignore[unreachable]
39+
raise TypeError(msg)
3640
root = root.rstrip("/")
3741
path = f"{root}/{path}" if root else path
3842
return path.rstrip("/")

0 commit comments

Comments
 (0)