Skip to content

Commit

Permalink
The unused parameter dag in DAGNode constructor is deprecated (#1…
Browse files Browse the repository at this point in the history
…3862)

* wrap the rust implementation constructor with the deprecation warning

* eeno

* trying another wrap

* remove internal usage

* conflict

* warning from rust-land

* fmt
  • Loading branch information
1ucian0 authored Feb 20, 2025
1 parent 87a00b3 commit d31c6aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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

0 comments on commit d31c6aa

Please sign in to comment.