Skip to content

Move deprecation notices to the top of docstrings #2637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 5, 2025
Merged
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
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ ignore = [
checks = [
"GL06",
"GL07",
"GL09",
# Currently broken; see https://github.com/numpy/numpydoc/issues/573
# "GL09",
"GL10",
"SS02",
"SS04",
Expand Down
8 changes: 4 additions & 4 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ async def save_group(
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.

.. deprecated:: 3.0.0
`zarr.tree()` is deprecated and will be removed in a future release.
Use `group.tree()` instead.

Parameters
----------
grp : Group
Expand All @@ -521,10 +525,6 @@ async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None =
-------
TreeRepr
A pretty-printable object displaying the hierarchy.

.. deprecated:: 3.0.0
`zarr.tree()` is deprecated and will be removed in a future release.
Use `group.tree()` instead.
"""
return await grp.tree(expand=expand, level=level)

Expand Down
8 changes: 4 additions & 4 deletions src/zarr/api/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ def save_group(
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
"""Provide a rich display of the hierarchy.

.. deprecated:: 3.0.0
`zarr.tree()` is deprecated and will be removed in a future release.
Use `group.tree()` instead.

Parameters
----------
grp : Group
Expand All @@ -347,10 +351,6 @@ def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> An
-------
TreeRepr
A pretty-printable object displaying the hierarchy.

.. deprecated:: 3.0.0
`zarr.tree()` is deprecated and will be removed in a future release.
Use `group.tree()` instead.
"""
return sync(async_api.tree(grp._async_group, expand=expand, level=level))

Expand Down
12 changes: 6 additions & 6 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ async def create(
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
"""Method to create a new asynchronous array instance.

.. deprecated:: 3.0.0
Deprecated in favor of :func:`zarr.api.asynchronous.create_array`.

Parameters
----------
store : StoreLike
Expand Down Expand Up @@ -509,9 +512,6 @@ async def create(
-------
AsyncArray
The created asynchronous array instance.

.. deprecated:: 3.0.0
Deprecated in favor of :func:`zarr.api.asynchronous.create_array`.
"""
return await cls._create(
store,
Expand Down Expand Up @@ -1631,6 +1631,9 @@ def create(
) -> Array:
"""Creates a new Array instance from an initialized store.

.. deprecated:: 3.0.0
Deprecated in favor of :func:`zarr.create_array`.

Parameters
----------
store : StoreLike
Expand Down Expand Up @@ -1698,9 +1701,6 @@ def create(
-------
Array
Array created from the store.

.. deprecated:: 3.0.0
Deprecated in favor of :func:`zarr.create_array`.
"""
return cls._create(
store,
Expand Down
28 changes: 16 additions & 12 deletions src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,9 @@ async def create_dataset(
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
"""Create an array.

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.create_array` instead.

Arrays are known as "datasets" in HDF5 terminology. For compatibility
with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup.require_dataset` method.

Expand All @@ -1161,9 +1164,6 @@ async def create_dataset(
Returns
-------
a : AsyncArray

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.create_array` instead.
"""
data = kwargs.pop("data", None)
# create_dataset in zarr 2.x requires shape but not dtype if data is
Expand All @@ -1188,6 +1188,9 @@ async def require_dataset(
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
"""Obtain an array, creating if it doesn't exist.

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.require_dataset` instead.

Arrays are known as "datasets" in HDF5 terminology. For compatibility
with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup.create_dataset` method.

Expand All @@ -1208,9 +1211,6 @@ async def require_dataset(
Returns
-------
a : AsyncArray

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.require_dataset` instead.
"""
return await self.require_array(name, shape=shape, dtype=dtype, exact=exact, **kwargs)

Expand Down Expand Up @@ -2402,6 +2402,10 @@ def create_array(
def create_dataset(self, name: str, **kwargs: Any) -> Array:
"""Create an array.

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.


Arrays are known as "datasets" in HDF5 terminology. For compatibility
with h5py, Zarr groups also implement the :func:`zarr.Group.require_dataset` method.

Expand All @@ -2415,16 +2419,16 @@ def create_dataset(self, name: str, **kwargs: Any) -> Array:
Returns
-------
a : Array

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.
"""
return Array(self._sync(self._async_group.create_dataset(name, **kwargs)))

@deprecated("Use Group.require_array instead.")
def require_dataset(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Array:
"""Obtain an array, creating if it doesn't exist.

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array` instead.

Arrays are known as "datasets" in HDF5 terminology. For compatibility
with h5py, Zarr groups also implement the :func:`zarr.Group.create_dataset` method.

Expand All @@ -2440,9 +2444,6 @@ def require_dataset(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Arra
Returns
-------
a : Array

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array` instead.
"""
return Array(self._sync(self._async_group.require_array(name, shape=shape, **kwargs)))

Expand Down Expand Up @@ -2669,6 +2670,9 @@ def array(
) -> Array:
"""Create an array within this group.

.. deprecated:: 3.0.0
Use `Group.create_array` instead.

This method lightly wraps :func:`zarr.core.array.create_array`.

Parameters
Expand Down
Loading