diff --git a/src/zarr/storage/__init__.py b/src/zarr/storage/__init__.py index f1bd1724af..fdabc1c75a 100644 --- a/src/zarr/storage/__init__.py +++ b/src/zarr/storage/__init__.py @@ -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 @@ -28,18 +22,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 diff --git a/tests/test_v2.py b/tests/test_v2.py index 3a063ac509..557c657ad3 100644 --- a/tests/test_v2.py +++ b/tests/test_v2.py @@ -225,9 +225,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"])