Skip to content

Commit 14110a0

Browse files
committed
Revert "Rename Path newtype to PathType"
This reverts commit 515951c.
1 parent 1862b7d commit 14110a0

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

zarr/storage.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import multiprocessing
2121
import operator
2222
import os
23+
from pathlib import Path
2324
import re
2425
import shutil
2526
import sys
@@ -77,7 +78,7 @@
7778
default_compressor = Zlib()
7879

7980

80-
PathType = Union[str, bytes, None]
81+
Path = Union[str, bytes, None]
8182

8283

8384
def _path_to_prefix(path: Optional[str]) -> str:
@@ -89,15 +90,15 @@ def _path_to_prefix(path: Optional[str]) -> str:
8990
return prefix
9091

9192

92-
def contains_array(store: MutableMapping, path: PathType = None) -> bool:
93+
def contains_array(store: MutableMapping, path: Path = None) -> bool:
9394
"""Return True if the store contains an array at the given logical path."""
9495
path = normalize_storage_path(path)
9596
prefix = _path_to_prefix(path)
9697
key = prefix + array_meta_key
9798
return key in store
9899

99100

100-
def contains_group(store: MutableMapping, path: PathType = None) -> bool:
101+
def contains_group(store: MutableMapping, path: Path = None) -> bool:
101102
"""Return True if the store contains a group at the given logical path."""
102103
path = normalize_storage_path(path)
103104
prefix = _path_to_prefix(path)
@@ -113,7 +114,7 @@ def _rmdir_from_keys(store: MutableMapping, path: Optional[str] = None) -> None:
113114
del store[key]
114115

115116

116-
def rmdir(store, path: PathType = None):
117+
def rmdir(store, path: Path = None):
117118
"""Remove all items under the given path. If `store` provides a `rmdir` method,
118119
this will be called, otherwise will fall back to implementation via the
119120
`MutableMapping` interface."""
@@ -136,7 +137,7 @@ def _rename_from_keys(store: MutableMapping, src_path: str, dst_path: str) -> No
136137
store[new_key] = store.pop(key)
137138

138139

139-
def rename(store, src_path: PathType, dst_path: PathType):
140+
def rename(store, src_path: Path, dst_path: Path):
140141
"""Rename all items under the given path. If `store` provides a `rename` method,
141142
this will be called, otherwise will fall back to implementation via the
142143
`MutableMapping` interface."""
@@ -162,7 +163,7 @@ def _listdir_from_keys(store: MutableMapping, path: Optional[str] = None) -> Lis
162163
return sorted(children)
163164

164165

165-
def listdir(store, path: PathType = None):
166+
def listdir(store, path: Path = None):
166167
"""Obtain a directory listing for the given path. If `store` provides a `listdir`
167168
method, this will be called, otherwise will fall back to implementation via the
168169
`MutableMapping` interface."""
@@ -175,7 +176,7 @@ def listdir(store, path: PathType = None):
175176
return _listdir_from_keys(store, path)
176177

177178

178-
def getsize(store, path: PathType = None) -> int:
179+
def getsize(store, path: Path = None) -> int:
179180
"""Compute size of stored items for a given path. If `store` provides a `getsize`
180181
method, this will be called, otherwise will return -1."""
181182
path = normalize_storage_path(path)
@@ -233,7 +234,7 @@ def init_array(
233234
fill_value=None,
234235
order: str = "C",
235236
overwrite: bool = False,
236-
path: PathType = None,
237+
path: Path = None,
237238
chunk_store: MutableMapping = None,
238239
filters=None,
239240
object_codec=None,
@@ -458,7 +459,7 @@ def _init_array_metadata(
458459
def init_group(
459460
store: MutableMapping,
460461
overwrite: bool = False,
461-
path: PathType = None,
462+
path: Path = None,
462463
chunk_store: MutableMapping = None,
463464
):
464465
"""Initialize a group store. Note that this is a low-level function and there should be no
@@ -647,7 +648,7 @@ def __iter__(self):
647648
def __len__(self) -> int:
648649
return sum(1 for _ in self.keys())
649650

650-
def listdir(self, path: PathType = None) -> List[str]:
651+
def listdir(self, path: Path = None) -> List[str]:
651652
path = normalize_storage_path(path)
652653
if path:
653654
try:
@@ -662,7 +663,7 @@ def listdir(self, path: PathType = None) -> List[str]:
662663
else:
663664
return []
664665

665-
def rename(self, src_path: PathType, dst_path: PathType):
666+
def rename(self, src_path: Path, dst_path: Path):
666667
src_path = normalize_storage_path(src_path)
667668
dst_path = normalize_storage_path(dst_path)
668669

@@ -671,7 +672,7 @@ def rename(self, src_path: PathType, dst_path: PathType):
671672

672673
dst_parent[dst_key] = src_parent.pop(src_key)
673674

674-
def rmdir(self, path: PathType = None):
675+
def rmdir(self, path: Path = None):
675676
path = normalize_storage_path(path)
676677
if path:
677678
try:
@@ -686,7 +687,7 @@ def rmdir(self, path: PathType = None):
686687
# clear out root
687688
self.root = self.cls()
688689

689-
def getsize(self, path: PathType = None):
690+
def getsize(self, path: Path = None):
690691
path = normalize_storage_path(path)
691692

692693
# obtain value to return size of

0 commit comments

Comments
 (0)