From fb20e513bad9c43ad6a87ffae32fafdca41d8c63 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 7 Sep 2025 10:39:08 -0700 Subject: [PATCH 1/2] Complete deprecation cycle for Dataset.update return value - Dataset.update() now returns None instead of self - Removes deprecation that was started in v0.17 and scheduled for removal in v0.21 - Updates documentation to remove return value information - Aligns behavior with standard dict.update() which returns None Closes #10167 --- doc/whats-new.rst | 4 ++++ xarray/core/dataset.py | 12 ++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 7d2b466dd48..3d11f6dd859 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -17,6 +17,10 @@ New Features Breaking changes ~~~~~~~~~~~~~~~~ +- :py:meth:`Dataset.update` now returns ``None``, instead of the updated dataset. This + completes the deprecation cycle started in version 0.17. The method still updates the + dataset in-place. (:issue:`10167`) + By `Maximilian Roos `_ and `Claude `_. Deprecations ~~~~~~~~~~~~ diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index fffe78fa759..a4cf899e687 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -5592,7 +5592,7 @@ def unstack( result = result._unstack_once(d, stacked_indexes[d], fill_value, sparse) return result - def update(self, other: CoercibleMapping) -> Self: + def update(self, other: CoercibleMapping) -> None: """Update this dataset's variables with those from another dataset. Just like :py:meth:`dict.update` this is a in-place operation. @@ -5609,14 +5609,6 @@ def update(self, other: CoercibleMapping) -> Self: - mapping {var name: (dimension name, array-like)} - mapping {var name: (tuple of dimension names, array-like)} - Returns - ------- - updated : Dataset - Updated dataset. Note that since the update is in-place this is the input - dataset. - - It is deprecated since version 0.17 and scheduled to be removed in 0.21. - Raises ------ ValueError @@ -5629,7 +5621,7 @@ def update(self, other: CoercibleMapping) -> Self: Dataset.merge """ merge_result = dataset_update_method(self, other) - return self._replace(inplace=True, **merge_result._asdict()) + self._replace(inplace=True, **merge_result._asdict()) def merge( self, From e9c5d018d13604be2012110d3cfb06f06cf346d5 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Sun, 7 Sep 2025 18:45:50 -0700 Subject: [PATCH 2/2] Update doc/whats-new.rst Co-authored-by: Stephan Hoyer --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 3d11f6dd859..72344df4658 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -20,7 +20,7 @@ Breaking changes - :py:meth:`Dataset.update` now returns ``None``, instead of the updated dataset. This completes the deprecation cycle started in version 0.17. The method still updates the dataset in-place. (:issue:`10167`) - By `Maximilian Roos `_ and `Claude `_. + By `Maximilian Roos `_. Deprecations ~~~~~~~~~~~~