diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index 200c17cbb1a..8b24103812c 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -56,6 +56,7 @@
* `Observable.return_type` is deprecated. Instead, you should inspect the type
of the surrounding measurement process.
[(#4762)](https://github.com/PennyLaneAI/pennylane/pull/4762)
+ [(#4798)](https://github.com/PennyLaneAI/pennylane/pull/4798)
Documentation 📝
diff --git a/pennylane/operation.py b/pennylane/operation.py
index 6cc951f5bd5..846f153108d 100644
--- a/pennylane/operation.py
+++ b/pennylane/operation.py
@@ -1887,6 +1887,16 @@ def return_type(self):
)
return self._return_type
+ @return_type.setter
+ def return_type(self, value):
+ """Change the return type of an Observable. Note that this property is deprecated."""
+ warnings.warn(
+ "`Observable.return_type` is deprecated. Instead, you should "
+ "create a measurement process containing this Observable.",
+ UserWarning,
+ )
+ self._return_type = value
+
def __matmul__(self, other):
if active_new_opmath():
return super().__matmul__(other=other)
diff --git a/tests/test_operation.py b/tests/test_operation.py
index bc352406c7e..383e9c47a13 100644
--- a/tests/test_operation.py
+++ b/tests/test_operation.py
@@ -886,6 +886,11 @@ class DummyObserv(qml.operation.Observable):
with pytest.warns(UserWarning, match="`Observable.return_type` is deprecated. Instead"):
assert DummyObserv(0, wires=[1]).return_type is None
+ obs = DummyObserv(0, wires=[1])
+ with pytest.warns(UserWarning, match="`Observable.return_type` is deprecated. Instead"):
+ # pylint:disable=attribute-defined-outside-init
+ obs.return_type = qml.measurements.Sample
+
def test_construction_with_wires_pos_arg(self):
"""Test that the wires can be given as a positional argument"""