Skip to content

Commit

Permalink
Bump version of black in pre-commit (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Dec 7, 2023
1 parent 25dbeed commit 8579e21
Show file tree
Hide file tree
Showing 27 changed files with 11 additions and 258 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
# Respect `exclude` and `extend-exclude` settings.
args: ["--force-exclude"]
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
Expand Down
1 change: 0 additions & 1 deletion bench/compress_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from zarr import blosc

if __name__ == "__main__":

sys.path.insert(0, "..")

# setup
Expand Down
3 changes: 1 addition & 2 deletions zarr/_storage/absstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(
"https://{}.blob.core.windows.net/".format(account_name),
container,
credential=account_key,
**blob_service_kwargs
**blob_service_kwargs,
)

self.client = client
Expand Down Expand Up @@ -240,7 +240,6 @@ def __setitem__(self, key, value):
super().__setitem__(key, value)

def rmdir(self, path=None):

if not path:
# Currently allowing clear to delete everything as in v2

Expand Down
1 change: 0 additions & 1 deletion zarr/_storage/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ def _rmdir_from_keys(store: StoreLike, path: Optional[str] = None) -> None:


def _rmdir_from_keys_v3(store: StoreV3, path: str = "") -> None:

meta_dir = meta_root + path
meta_dir = meta_dir.rstrip("/")
_rmdir_from_keys(store, meta_dir)
Expand Down
1 change: 0 additions & 1 deletion zarr/_storage/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def _get_files_and_dirs_from_path(store, path):


class FSStoreV3(FSStore, StoreV3):

# FSStoreV3 doesn't use this (FSStore uses it within _normalize_key)
_META_KEYS = ()

Expand Down
6 changes: 0 additions & 6 deletions zarr/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Attributes(MutableMapping):
"""

def __init__(self, store, key=".zattrs", read_only=False, cache=True, synchronizer=None):

self._version = getattr(store, "_store_version", 2)
_Store = Store if self._version == 2 else StoreV3
self.store = _Store._ensure_store(store)
Expand Down Expand Up @@ -73,7 +72,6 @@ def __getitem__(self, item):
return self.asdict()[item]

def _write_op(self, f, *args, **kwargs):

# guard condition
if self.read_only:
raise PermissionError("attributes are read-only")
Expand All @@ -89,7 +87,6 @@ def __setitem__(self, item, value):
self._write_op(self._setitem_nosync, item, value)

def _setitem_nosync(self, item, value):

# load existing data
d = self._get_nosync()

Expand All @@ -106,7 +103,6 @@ def __delitem__(self, item):
self._write_op(self._delitem_nosync, item)

def _delitem_nosync(self, key):

# load existing data
d = self._get_nosync()

Expand All @@ -128,7 +124,6 @@ def put(self, d):
self._write_op(self._put_nosync, dict(attributes=d))

def _put_nosync(self, d):

d_to_check = d if self._version == 2 else d["attributes"]
if not all(isinstance(item, str) for item in d_to_check):
# TODO: Raise an error for non-string keys
Expand Down Expand Up @@ -178,7 +173,6 @@ def update(self, *args, **kwargs):
self._write_op(self._update_nosync, *args, **kwargs)

def _update_nosync(self, *args, **kwargs):

# load existing data
d = self._get_nosync()

Expand Down
20 changes: 5 additions & 15 deletions zarr/convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,8 @@ def copy_store(

# setup logging
with _LogWriter(log) as log:

# iterate over source keys
for source_key in sorted(source.keys()):

# filter to keys under source path
if source_store_version == 2:
if not source_key.startswith(source_path):
Expand Down Expand Up @@ -757,7 +755,7 @@ def copy(
log=None,
if_exists="raise",
dry_run=False,
**create_kws
**create_kws,
):
"""Copy the `source` array or group into the `dest` group.
Expand Down Expand Up @@ -878,7 +876,6 @@ def copy(

# setup logging
with _LogWriter(log) as log:

# do the copying
n_copied, n_skipped, n_bytes_copied = _copy(
log,
Expand All @@ -890,7 +887,7 @@ def copy(
without_attrs=without_attrs,
if_exists=if_exists,
dry_run=dry_run,
**create_kws
**create_kws,
)

# log a final message with a summary of what happened
Expand Down Expand Up @@ -948,12 +945,10 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_

# take action
if do_copy:

# log a message about what we're going to do
log("copy {} {} {}".format(source.name, source.shape, source.dtype))

if not dry_run:

# clear the way
if exists:
del dest[name]
Expand Down Expand Up @@ -1038,12 +1033,10 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_

# take action
if do_copy:

# log action
log("copy {}".format(source.name))

if not dry_run:

# clear the way
if exists_array:
del dest[name]
Expand All @@ -1056,7 +1049,6 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_
grp.attrs.update(source.attrs)

else:

# setup for dry run without creating any groups in the
# destination
if dest is not None:
Expand All @@ -1076,7 +1068,7 @@ def _copy(log, source, dest, name, root, shallow, without_attrs, if_exists, dry_
without_attrs=without_attrs,
if_exists=if_exists,
dry_run=dry_run,
**create_kws
**create_kws,
)
n_copied += c
n_skipped += s
Expand All @@ -1099,7 +1091,7 @@ def copy_all(
log=None,
if_exists="raise",
dry_run=False,
**create_kws
**create_kws,
):
"""Copy all children of the `source` group into the `dest` group.
Expand Down Expand Up @@ -1189,7 +1181,6 @@ def copy_all(

# setup logging
with _LogWriter(log) as log:

for k in source.keys():
c, s, b = _copy(
log,
Expand All @@ -1201,7 +1192,7 @@ def copy_all(
without_attrs=without_attrs,
if_exists=if_exists,
dry_run=dry_run,
**create_kws
**create_kws,
)
n_copied += c
n_skipped += s
Expand Down Expand Up @@ -1262,7 +1253,6 @@ def is_zarr_key(key):
return key.endswith(".zarray") or key.endswith(".zgroup") or key.endswith(".zattrs")

else:

assert_zarr_v3_api_available()

sfx = _get_metadata_suffix(store) # type: ignore
Expand Down
2 changes: 0 additions & 2 deletions zarr/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def create(


def _kwargs_compat(compressor, fill_value, kwargs):

# to be compatible with h5py, as well as backwards-compatible with Zarr
# 1.x, accept 'compression' and 'compression_opts' keyword arguments

Expand Down Expand Up @@ -697,7 +696,6 @@ def open_array(


def _like_args(a, kwargs):

shape, chunks = _get_shape_chunks(a)
if shape is not None:
kwargs.setdefault("shape", shape)
Expand Down
12 changes: 4 additions & 8 deletions zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(
synchronizer=None,
zarr_version=None,
*,
meta_array=None
meta_array=None,
):
store: BaseStore = _normalize_store_arg(store, zarr_version=zarr_version)
if zarr_version is None:
Expand Down Expand Up @@ -919,7 +919,6 @@ def tree(self, expand=False, level=None):
return TreeViewer(self, expand=expand, level=level)

def _write_op(self, f, *args, **kwargs):

# guard condition
if self._read_only:
raise ReadOnlyError()
Expand Down Expand Up @@ -1094,7 +1093,6 @@ def create_dataset(self, name, **kwargs):
return self._write_op(self._create_dataset_nosync, name, **kwargs)

def _create_dataset_nosync(self, name, data=None, **kwargs):

assert "mode" not in kwargs
path = self._item_path(name)

Expand Down Expand Up @@ -1138,11 +1136,9 @@ def require_dataset(self, name, shape, dtype=None, exact=False, **kwargs):
)

def _require_dataset_nosync(self, name, shape, dtype=None, exact=False, **kwargs):

path = self._item_path(name)

if contains_array(self._store, path):

# array already exists at path, validate that it is the right shape and type

synchronizer = kwargs.get("synchronizer", self._synchronizer)
Expand Down Expand Up @@ -1235,7 +1231,7 @@ def _full_nosync(self, name, fill_value, **kwargs):
path=path,
chunk_store=self._chunk_store,
fill_value=fill_value,
**kwargs
**kwargs,
)

def array(self, name, data, **kwargs):
Expand Down Expand Up @@ -1361,7 +1357,7 @@ def group(
path=None,
*,
zarr_version=None,
meta_array=None
meta_array=None,
):
"""Create a group.
Expand Down Expand Up @@ -1452,7 +1448,7 @@ def open_group(
storage_options=None,
*,
zarr_version=None,
meta_array=None
meta_array=None,
):
"""Open a group using file-mode-like semantics.
Expand Down

0 comments on commit 8579e21

Please sign in to comment.