Skip to content

Commit 6b03c7f

Browse files
committed
test + dep decorator
1 parent 039c091 commit 6b03c7f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/zarr/api/asynchronous.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import numpy as np
99
import numpy.typing as npt
10+
from typing_extensions import deprecated
1011

1112
from zarr.core.array import Array, AsyncArray, get_array_metadata
1213
from zarr.core.buffer import NDArrayLike
@@ -493,6 +494,7 @@ async def save_group(
493494
await asyncio.gather(*aws)
494495

495496

497+
@deprecated("Use AsyncGroup.tree instead.")
496498
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
497499
"""Provide a rich display of the hierarchy.
498500
@@ -514,11 +516,6 @@ async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None =
514516
`zarr.tree()` is deprecated and will be removed in a future release.
515517
Use `group.tree()` instead.
516518
"""
517-
warnings.warn(
518-
"zarr.tree() is deprecated and will be removed in a future release. Use group.tree() instead.",
519-
DeprecationWarning,
520-
stacklevel=2,
521-
)
522519
return await grp.tree(expand=expand, level=level)
523520

524521

src/zarr/api/synchronous.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from typing import TYPE_CHECKING, Any, Literal
44

5+
from typing_extensions import deprecated
6+
57
import zarr.api.asynchronous as async_api
68
from zarr._compat import _deprecate_positional_args
79
from zarr.core.array import Array, AsyncArray
@@ -155,6 +157,7 @@ def save_group(
155157
)
156158

157159

160+
@deprecated("Use Group.tree instead.")
158161
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
159162
return sync(async_api.tree(grp._async_group, expand=expand, level=level))
160163

tests/test_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ def test_tree() -> None:
300300
g3.create_group("baz")
301301
g5 = g3.create_group("qux")
302302
g5.create_array("baz", shape=100, chunks=10)
303-
# TODO: complete after tree has been reimplemented
304-
# assert repr(zarr.tree(g1)) == repr(g1.tree())
305-
# assert str(zarr.tree(g1)) == str(g1.tree())
303+
with pytest.warns(DeprecationWarning):
304+
assert repr(zarr.tree(g1)) == repr(g1.tree())
305+
assert str(zarr.tree(g1)) == str(g1.tree())
306306

307307

308308
# @pytest.mark.parametrize("stores_from_path", [False, True])

0 commit comments

Comments
 (0)