-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deprecation warnings emitted by
import qiskit.primitives
(#10287)
The primitives still need to support the legacy `qiskit.opflow.PauliSumOp` while that object is deprecated but not removed. However, we do not want the import of `qiskit.primitives` to need to import `opflow` to do that, since that will cause the deprecation warnings emitted by the import of `opflow` to be hidden (they'll be blamed on Qiskit library code, so hidden by default). All type-hint usage we can hide behind the `TYPE_CHECKING` static analysis gate. For cases where we were actively runtime type-checking an object, we can gate the `isinstance` check behind a check that `qiskit.opflow` is already imported; the object cannot be a `PauliSumOp` if the module isn't initialised. (cherry picked from commit 81964e6)
- Loading branch information
1 parent
9f18b91
commit 64d8d2c
Showing
5 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
releasenotes/notes/fix-primitives-import-warnings-439e3e237fdb9d7b.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
fixes: | ||
- | | ||
Importing :mod:`qiskit.primitives` will no longer cause deprecation warnings stemming from the | ||
deprecated :mod:`qiskit.opflow` module. These warnings would have been hidden to users by the | ||
default Python filters, but triggered the eager import of :mod:`.opflow`, which meant that a | ||
subsequent import by a user would not trigger the warnings. |