diff --git a/src/zarr/api/asynchronous.py b/src/zarr/api/asynchronous.py index c3810a6d0c..26822f725b 100644 --- a/src/zarr/api/asynchronous.py +++ b/src/zarr/api/asynchronous.py @@ -7,6 +7,7 @@ import numpy as np import numpy.typing as npt +from typing_extensions import deprecated from zarr.core.array import Array, AsyncArray, get_array_metadata from zarr.core.buffer import NDArrayLike @@ -493,6 +494,7 @@ async def save_group( await asyncio.gather(*aws) +@deprecated("Use AsyncGroup.tree instead.") async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any: """Provide a rich display of the hierarchy. @@ -514,11 +516,6 @@ async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = `zarr.tree()` is deprecated and will be removed in a future release. Use `group.tree()` instead. """ - warnings.warn( - "zarr.tree() is deprecated and will be removed in a future release. Use group.tree() instead.", - DeprecationWarning, - stacklevel=2, - ) return await grp.tree(expand=expand, level=level) diff --git a/src/zarr/api/synchronous.py b/src/zarr/api/synchronous.py index a9655993fe..8e8ecf40b8 100644 --- a/src/zarr/api/synchronous.py +++ b/src/zarr/api/synchronous.py @@ -2,6 +2,8 @@ from typing import TYPE_CHECKING, Any, Literal +from typing_extensions import deprecated + import zarr.api.asynchronous as async_api from zarr._compat import _deprecate_positional_args from zarr.core.array import Array, AsyncArray @@ -155,6 +157,7 @@ def save_group( ) +@deprecated("Use Group.tree instead.") def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any: return sync(async_api.tree(grp._async_group, expand=expand, level=level)) diff --git a/tests/test_api.py b/tests/test_api.py index 11977e8e32..a1b6572b5f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -300,9 +300,9 @@ def test_tree() -> None: g3.create_group("baz") g5 = g3.create_group("qux") g5.create_array("baz", shape=100, chunks=10) - # TODO: complete after tree has been reimplemented - # assert repr(zarr.tree(g1)) == repr(g1.tree()) - # assert str(zarr.tree(g1)) == str(g1.tree()) + with pytest.warns(DeprecationWarning): + assert repr(zarr.tree(g1)) == repr(g1.tree()) + assert str(zarr.tree(g1)) == str(g1.tree()) # @pytest.mark.parametrize("stores_from_path", [False, True])