41
41
from numcodecs .compat import ensure_bytes , ensure_text , ensure_contiguous_ndarray_like
42
42
from numcodecs .registry import codec_registry
43
43
from zarr .context import Context
44
- from zarr .types import PathLike as Path
44
+ from zarr .types import PathLike as Path , DIMENSION_SEPARATOR
45
+ from zarr .util import NoLock
45
46
46
47
from zarr .errors import (
47
48
MetadataError ,
@@ -327,7 +328,7 @@ def init_array(
327
328
chunk_store : Optional [StoreLike ] = None ,
328
329
filters = None ,
329
330
object_codec = None ,
330
- dimension_separator = None ,
331
+ dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None ,
331
332
storage_transformers = (),
332
333
):
333
334
"""Initialize an array store with the given configuration. Note that this is a low-level
@@ -481,7 +482,7 @@ def _init_array_metadata(
481
482
chunk_store : Optional [StoreLike ] = None ,
482
483
filters = None ,
483
484
object_codec = None ,
484
- dimension_separator = None ,
485
+ dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None ,
485
486
storage_transformers = (),
486
487
):
487
488
store_version = getattr (store , "_store_version" , 2 )
@@ -1054,7 +1055,9 @@ class DirectoryStore(Store):
1054
1055
1055
1056
"""
1056
1057
1057
- def __init__ (self , path , normalize_keys = False , dimension_separator = None ):
1058
+ def __init__ (
1059
+ self , path , normalize_keys = False , dimension_separator : Optional [DIMENSION_SEPARATOR ] = None
1060
+ ):
1058
1061
# guard conditions
1059
1062
path = os .path .abspath (path )
1060
1063
if os .path .exists (path ) and not os .path .isdir (path ):
@@ -1349,7 +1352,7 @@ def __init__(
1349
1352
key_separator = None ,
1350
1353
mode = "w" ,
1351
1354
exceptions = (KeyError , PermissionError , IOError ),
1352
- dimension_separator = None ,
1355
+ dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None ,
1353
1356
fs = None ,
1354
1357
check = False ,
1355
1358
create = False ,
@@ -1568,7 +1571,12 @@ class TempStore(DirectoryStore):
1568
1571
1569
1572
# noinspection PyShadowingBuiltins
1570
1573
def __init__ (
1571
- self , suffix = "" , prefix = "zarr" , dir = None , normalize_keys = False , dimension_separator = None
1574
+ self ,
1575
+ suffix = "" ,
1576
+ prefix = "zarr" ,
1577
+ dir = None ,
1578
+ normalize_keys = False ,
1579
+ dimension_separator : Optional [DIMENSION_SEPARATOR ] = None ,
1572
1580
):
1573
1581
path = tempfile .mkdtemp (suffix = suffix , prefix = prefix , dir = dir )
1574
1582
atexit .register (atexit_rmtree , path )
@@ -1652,7 +1660,9 @@ class NestedDirectoryStore(DirectoryStore):
1652
1660
1653
1661
"""
1654
1662
1655
- def __init__ (self , path , normalize_keys = False , dimension_separator = "/" ):
1663
+ def __init__ (
1664
+ self , path , normalize_keys = False , dimension_separator : Optional [DIMENSION_SEPARATOR ] = "/"
1665
+ ):
1656
1666
super ().__init__ (path , normalize_keys = normalize_keys )
1657
1667
if dimension_separator is None :
1658
1668
dimension_separator = "/"
@@ -1765,7 +1775,7 @@ def __init__(
1765
1775
compression = zipfile .ZIP_STORED ,
1766
1776
allowZip64 = True ,
1767
1777
mode = "a" ,
1768
- dimension_separator = None ,
1778
+ dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None ,
1769
1779
):
1770
1780
# store properties
1771
1781
path = os .path .abspath (path )
@@ -2058,7 +2068,7 @@ def __init__(
2058
2068
mode = 0o666 ,
2059
2069
open = None ,
2060
2070
write_lock = True ,
2061
- dimension_separator = None ,
2071
+ dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None ,
2062
2072
** open_kwargs ,
2063
2073
):
2064
2074
if open is None :
@@ -2073,6 +2083,7 @@ def __init__(
2073
2083
self .mode = mode
2074
2084
self .open = open
2075
2085
self .write_lock = write_lock
2086
+ self .write_mutex : Union [Lock , NoLock ]
2076
2087
if write_lock :
2077
2088
# This may not be required as some dbm implementations manage their own
2078
2089
# locks, but err on the side of caution.
@@ -2229,7 +2240,13 @@ class LMDBStore(Store):
2229
2240
2230
2241
"""
2231
2242
2232
- def __init__ (self , path , buffers = True , dimension_separator = None , ** kwargs ):
2243
+ def __init__ (
2244
+ self ,
2245
+ path ,
2246
+ buffers = True ,
2247
+ dimension_separator : Optional [DIMENSION_SEPARATOR ] = None ,
2248
+ ** kwargs ,
2249
+ ):
2233
2250
import lmdb
2234
2251
2235
2252
# set default memory map size to something larger than the lmdb default, which is
@@ -2580,7 +2597,7 @@ class SQLiteStore(Store):
2580
2597
>>> store.close() # don't forget to call this when you're done
2581
2598
"""
2582
2599
2583
- def __init__ (self , path , dimension_separator = None , ** kwargs ):
2600
+ def __init__ (self , path , dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None , ** kwargs ):
2584
2601
import sqlite3
2585
2602
2586
2603
self ._dimension_separator = dimension_separator
@@ -2776,7 +2793,7 @@ def __init__(
2776
2793
self ,
2777
2794
database = "mongodb_zarr" ,
2778
2795
collection = "zarr_collection" ,
2779
- dimension_separator = None ,
2796
+ dimension_separator : Optional [ DIMENSION_SEPARATOR ] = None ,
2780
2797
** kwargs ,
2781
2798
):
2782
2799
import pymongo
@@ -2851,7 +2868,9 @@ class RedisStore(Store):
2851
2868
2852
2869
"""
2853
2870
2854
- def __init__ (self , prefix = "zarr" , dimension_separator = None , ** kwargs ):
2871
+ def __init__ (
2872
+ self , prefix = "zarr" , dimension_separator : Optional [DIMENSION_SEPARATOR ] = None , ** kwargs
2873
+ ):
2855
2874
import redis
2856
2875
2857
2876
self ._prefix = prefix
0 commit comments