diff --git a/docs/release.rst b/docs/release.rst index 0b9a208b2..b729f20ee 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -19,10 +19,12 @@ Documentation Maintenance ~~~~~~~~~~~ +* Fix a few DeepSource.io alerts + By :user:`Dimitri Papadopoulos Orfanos ` :issue:`1080`. + * Fix spelling. By :user:`Dimitri Papadopoulos Orfanos `, :issue:`1073`. - .. _release_2.12.0: 2.12.0 diff --git a/zarr/convenience.py b/zarr/convenience.py index 93dc86047..be8b609a4 100644 --- a/zarr/convenience.py +++ b/zarr/convenience.py @@ -1279,7 +1279,7 @@ def open_consolidated(store: StoreLike, metadata_key=".zmetadata", mode="r+", ** """ # normalize parameters - zarr_version = kwargs.get('zarr_version', None) + zarr_version = kwargs.get('zarr_version') store = normalize_store_arg(store, storage_options=kwargs.get("storage_options"), mode=mode, zarr_version=zarr_version) if mode not in {'r', 'r+'}: diff --git a/zarr/hierarchy.py b/zarr/hierarchy.py index b9052408b..80da3ddbc 100644 --- a/zarr/hierarchy.py +++ b/zarr/hierarchy.py @@ -1327,7 +1327,7 @@ def open_group(store=None, mode='a', cache_attrs=True, synchronizer=None, path=N storage_options=storage_options, mode=mode, zarr_version=zarr_version) - if not getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION) == zarr_version: + if getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION) != zarr_version: raise ValueError( "zarr_version of store and chunk_store must match" ) diff --git a/zarr/storage.py b/zarr/storage.py index 48b6f049d..440b41ea0 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -1413,7 +1413,7 @@ def __contains__(self, key): return key in self.map def __eq__(self, other): - return (type(self) == type(other) and self.map == other.map + return (type(self) is type(other) and self.map == other.map and self.mode == other.mode) def keys(self): diff --git a/zarr/tests/test_convenience.py b/zarr/tests/test_convenience.py index d0d293a69..59bb3aa7d 100644 --- a/zarr/tests/test_convenience.py +++ b/zarr/tests/test_convenience.py @@ -45,7 +45,7 @@ ) from zarr.tests.util import have_fsspec -_VERSIONS = v3_api_available and (2, 3) or (2,) +_VERSIONS = ((2, 3) if v3_api_available else (2, )) def _init_creation_kwargs(zarr_version): diff --git a/zarr/tests/test_creation.py b/zarr/tests/test_creation.py index 48d6aee4f..b8ab11832 100644 --- a/zarr/tests/test_creation.py +++ b/zarr/tests/test_creation.py @@ -21,8 +21,8 @@ from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3 from zarr.sync import ThreadSynchronizer -_VERSIONS = v3_api_available and (None, 2, 3) or (None, 2) -_VERSIONS2 = v3_api_available and (2, 3) or (2,) +_VERSIONS = ((None, 2, 3) if v3_api_available else (None, 2)) +_VERSIONS2 = ((2, 3) if v3_api_available else (2, )) # something bcolz-like @@ -430,7 +430,7 @@ def test_empty_like(zarr_version): z = empty(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F', **kwargs) # zarr_version will be inferred from z, but have to specify a path in v3 - z2 = empty_like(z, path=kwargs.get('path', None)) + z2 = empty_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype @@ -479,7 +479,7 @@ def test_zeros_like(zarr_version): # zarr array z = zeros(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F', **kwargs) - z2 = zeros_like(z, path=kwargs.get('path', None)) + z2 = zeros_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype @@ -506,7 +506,7 @@ def test_ones_like(zarr_version): # zarr array z = ones(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F', **kwargs) - z2 = ones_like(z, path=kwargs.get('path', None)) + z2 = ones_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype @@ -533,7 +533,7 @@ def test_full_like(zarr_version): z = full(100, chunks=10, dtype='f4', compressor=Zlib(5), fill_value=42, order='F', **kwargs) - z2 = full_like(z, path=kwargs.get('path', None)) + z2 = full_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype diff --git a/zarr/tests/test_hierarchy.py b/zarr/tests/test_hierarchy.py index 7c2eaa3f7..61c40e9f7 100644 --- a/zarr/tests/test_hierarchy.py +++ b/zarr/tests/test_hierarchy.py @@ -35,7 +35,7 @@ from zarr.tests.util import skip_test_env_var, have_fsspec, abs_container -_VERSIONS = v3_api_available and (2, 3) or (2,) +_VERSIONS = ((2, 3) if v3_api_available else (2, )) # noinspection PyStatementEffect diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index a3e227ec8..b938115e3 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -2400,7 +2400,7 @@ def test_iterators_with_prefix(self): assert 4 == len(store) keys = [prefix + 'a', prefix + 'b', prefix + 'c/d', prefix + 'c/e/f'] values = [b'aaa', b'bbb', b'ddd', b'fff'] - items = [(k, v) for k, v in zip(keys, values)] + items = list(zip(keys, values)) assert set(keys) == set(store) assert set(keys) == set(store.keys()) assert set(values) == set(store.values())