Skip to content

Commit

Permalink
Remove deprecated top-level classicalfunction imports (#11486)
Browse files Browse the repository at this point in the history
* Remove deprecated top-level classicalfunction imports

* add reno

* new editor does not automatically run black yet... sorry

* Update releasenotes/notes/remove-cfun-toplevel-5d0d58bed83d57ed.yaml

Co-authored-by: Jake Lishman <[email protected]>

---------

Co-authored-by: Jake Lishman <[email protected]>
  • Loading branch information
Cryoris and jakelishman authored Jan 5, 2024
1 parent 33d5afe commit 654a530
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
25 changes: 0 additions & 25 deletions qiskit/circuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,28 +398,3 @@
BreakLoopOp,
ContinueLoopOp,
)


_DEPRECATED_NAMES = {
"Int1": "qiskit.circuit.classicalfunction.types",
"Int2": "qiskit.circuit.classicalfunction.types",
"classical_function": "qiskit.circuit.classicalfunction",
"BooleanExpression": "qiskit.circuit.classicalfunction",
}


def __getattr__(name):
if name in _DEPRECATED_NAMES:
import importlib
import warnings

module_name = _DEPRECATED_NAMES[name]
warnings.warn(
f"Accessing '{name}' from '{__name__}' is deprecated since Qiskit Terra 0.22 "
f"and will be removed in 0.23. Import from '{module_name}' instead. "
"This will require installing 'tweedledum' as an optional dependency from Terra 0.23.",
DeprecationWarning,
stacklevel=2,
)
return getattr(importlib.import_module(module_name), name)
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
6 changes: 6 additions & 0 deletions releasenotes/notes/remove-cfun-toplevel-5d0d58bed83d57ed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
upgrade:
- |
Importing :class:`.Int1`, :class:`.Int2`, :class:`.BooleanFunction`, :func:`.classical_function`
from :mod:`qiskit.circuit` is now disabled. Instead, import the objects from the
:mod:`qiskit.circuit.classicalfunction` submodule, which requires the ``tweedledum`` package.

0 comments on commit 654a530

Please sign in to comment.