Skip to content
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

The unused parameter dag in DAGNode constructor is deprecated #13862

Merged
merged 7 commits into from
Feb 20, 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
16 changes: 14 additions & 2 deletions crates/circuit/src/dag_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl DAGOpNode {
op: Bound<PyAny>,
qargs: Option<TupleLikeArg>,
cargs: Option<TupleLikeArg>,
#[allow(unused_variables)] dag: Option<Bound<PyAny>>,
dag: Option<Bound<PyAny>>,
) -> PyResult<Py<Self>> {
let py_op = op.extract::<OperationFromPython>()?;
let qargs = qargs.map_or_else(|| PyTuple::empty_bound(py), |q| q.value);
Expand All @@ -138,7 +138,19 @@ impl DAGOpNode {
#[cfg(feature = "cache_pygates")]
py_op: op.unbind().into(),
};

if dag.is_some() {
WARNINGS_WARN.get_bound(py).call1((
intern!(
py,
concat!(
"The ``dag`` parameter in DAGNode subclass constructors ",
"is unused and it will be removed in Qiskit 2.0.",
)
),
py.get_type_bound::<PyDeprecationWarning>(),
2,
))?;
}
Py::new(
py,
(
Expand Down
1 change: 0 additions & 1 deletion qiskit/dagcircuit/dagdependency_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ def apply_operation_back(self, operation, qargs=(), cargs=()):
op=operation,
qargs=qargs,
cargs=cargs,
dag=self,
)
new_node._node_id = self._multi_graph.add_node(new_node)
self._update_edges()
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/deprecation_13022-9cf84f6c5ff13b29.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
deprecations_circuits:
- |
The ``DAGNode`` subclasses take a ``dag`` optional parameter when constructed that is currently unused and ignored. Now it is deprecated and will be removed in Qiskit 2.0