Repository: PennyLaneAI/pennylane
Pull request #6910 (2025-01-31 15:34:33)

Fix return type call in noise conditionals
**Context:**
Even though the recent fix https://github.com/PennyLaneAI/pennylane/commit/5910ef7b6d5bb16676fb5a3a7f75a264200ebbca successfully removed the warnings in test suite of master checking, the CI from the PR that brings back the warning-as-errors [indicates](https://github.com/PennyLaneAI/pennylane/actions/runs/13074879268/job/36484511004?pr=6880) that there are still deprecation warnnigs raised.

**Description of the Change:**
Completely remove the use of any `return_type` usages in `noise` module.

**Benefits:**
Clean up deprecation remains

**Possible Drawbacks:**
~Hard to test right now. CI doesn't work due to lack of warning-as-error. One has to test locally to see the impact.~
Tested via merging the branch that was actively fixing CI no warning-as-error issue

**Related GitHub Issues:**


github-actions[bot]: Hello. You may have forgotten to update the changelog!
Please edit [`doc/releases/changelog-dev.md`](/PennyLaneAI/pennylane/blob/master/doc/releases/changelog-dev.md) with:
* A one-to-two sentence description of the change. You may include a small working example for new features.
* A link back to this PR.
* Your name (or GitHub username) in the contributors section.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/PennyLaneAI/pennylane/pull/6910?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 99.59%. Comparing base [(`5f813c2`)](https://app.codecov.io/gh/PennyLaneAI/pennylane/commit/5f813c2ceaaa1141c6f2d1f5111257791401f1b2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) to head [(`d1a8b45`)](https://app.codecov.io/gh/PennyLaneAI/pennylane/commit/d1a8b4547159b9f4d7f3d3433db7fb68270e7a7a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).
> Report is 2 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #6910      +/-   ##
==========================================
- Coverage   99.59%   99.59%   -0.01%     
==========================================
  Files         479      479              
  Lines       45316    45322       +6     
==========================================
+ Hits        45134    45138       +4     
- Misses        182      184       +2     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/PennyLaneAI/pennylane/pull/6910?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).

JerryChen97: All checks of https://github.com/PennyLaneAI/pennylane/pull/6910/commits/d1a8b4547159b9f4d7f3d3433db7fb68270e7a7a passed. We shall not come across any deprecation warnings within PL at least.
JerryChen97: @astralcai what do you think?

Patch:
diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index d5bde5112..7dbfdbc31 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -195,6 +195,7 @@
   If observable type checking is needed, please use direct `isinstance`; if other text information is needed, please use class name, or another internal temporary private member `_shortname`.
   [(#6841)](https://github.com/PennyLaneAI/pennylane/pull/6841)
   [(#6906)](https://github.com/PennyLaneAI/pennylane/pull/6906)
+  [(#6910)](https://github.com/PennyLaneAI/pennylane/pull/6910)
 
 <h3>Internal changes ⚙️</h3>
 
diff --git a/pennylane/noise/conditionals.py b/pennylane/noise/conditionals.py
index 7fe04f7a3..2faa642b4 100644
--- a/pennylane/noise/conditionals.py
+++ b/pennylane/noise/conditionals.py
@@ -16,7 +16,6 @@
 Developer note: Conditionals inherit from BooleanFn and store the condition they
 utilize in the ``condition`` attribute.
 """
-
 from inspect import isclass, signature
 
 import pennylane as qml
@@ -489,9 +488,8 @@ class MeasEq(qml.BooleanFn):
             self.condition.append(mp)
             self._cmps.append(mp if isclass(mp) else mp.__class__)
 
-        # Temporrary fix from PR6906, Should be refactored in 0.42
         mp_ops = list(
-            getattr(op, "_shortname", op.__class__.__name__) for op in self.condition
+            op.__class__.__name__ for op in self.condition
         )  # pylint: disable=protected_access
         mp_names = [
             repr(op) if not isinstance(op, property) else repr(self.condition[idx].__name__)


Test patch:
diff --git a/tests/noise/test_conditionals.py b/tests/noise/test_conditionals.py
index c27c57d5b..985791e52 100644
--- a/tests/noise/test_conditionals.py
+++ b/tests/noise/test_conditionals.py
@@ -286,7 +286,7 @@ class TestNoiseFunctions:
 
         assert isinstance(func, qml.BooleanFn)
 
-        op_mps = list(getattr(op, "return_type", op.__class__.__name__) for op in func.condition)
+        op_mps = list(op.__class__.__name__ for op in func.condition)
         op_repr = [
             repr(op) if not isinstance(op, property) else repr(func.condition[idx].__name__)
             for idx, op in enumerate(op_mps)