Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/zarr/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import sys
import warnings
from types import ModuleType
from typing import Any

from zarr.errors import ZarrDeprecationWarning
from zarr.storage._common import StoreLike, StorePath
from zarr.storage._fsspec import FsspecStore
from zarr.storage._local import LocalStore
Expand All @@ -27,18 +21,4 @@
]


class VerboseModule(ModuleType):
def __setattr__(self, attr: str, value: Any) -> None:
if attr == "default_compressor":
warnings.warn(
"setting zarr.storage.default_compressor is deprecated, use "
"zarr.config to configure array.v2_default_compressor "
"e.g. config.set({'codecs.zstd':'numcodecs.Zstd', 'array.v2_default_compressor.numeric': 'zstd'})",
ZarrDeprecationWarning,
stacklevel=1,
)
else:
super().__setattr__(attr, value)


sys.modules[__name__].__class__ = VerboseModule
13 changes: 11 additions & 2 deletions tests/test_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,18 @@ def test_v2_non_contiguous(numpy_order: Literal["C", "F"], zarr_order: Literal["
assert (sub_arr).flags.c_contiguous


def test_default_compressor_deprecation_warning() -> None:
with pytest.warns(ZarrDeprecationWarning, match="default_compressor is deprecated"):
def test_storage_module_is_picklable() -> None:
import pickle

# regression test for gh-4029
assert pickle.dumps(zarr.storage)


def test_default_compressor_no_longer_warns() -> None:
# VerboseModule removed in gh-4029 to make zarr.storage picklable
with pytest.warns() as record:
zarr.storage.default_compressor = "zarr.codecs.zstd.ZstdCodec()" # type: ignore[attr-defined]
assert not any("default_compressor is deprecated" in str(w.message) for w in record)


@pytest.mark.parametrize("fill_value", [None, (b"", 0, 0.0)], ids=["no_fill", "fill"])
Expand Down
Loading