forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn on import failures within optional dependencies (Qiskit#11522)
* Warn on import failures within optional dependencies This distinguishes the case of "failed to find an optional dependency" from "found the optional dependency, but it failed to import" within the lazy testers. Now, a warning containing the import failures will be shown to users, rather than silently treating the dependency as missing. This occurred recently when a PR caused an import failure in Aer, which the CI suite failed to detect because the optional-dependency checkers allowed the test suite to pass regardless. Note that this commit alone won't reliably cause the test suite to fail on a failed import because: 1. this only emits a warning, not an exception (by design). 2. the `unittest` decorators are evaluated during test discovery, which happens before we activate our increased warning filters. This commit also unifies the now two Qiskit-specific warnings (the other being `QPYLoadingDeprecatedFeatureWarning`) with a common `QiskitWarning` subclass, much as we do for `QiskitError`. This gives us a convenient way to globally deny these errors during CI runs, without turning _all_ `UserWarning`s into errors, which we're not ready to do yet. * Suppress unnecessary lint warnings * Fix warning when failed import is parent package
- Loading branch information
1 parent
3c538f3
commit 4ce0049
Showing
6 changed files
with
189 additions
and
11 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
14 changes: 14 additions & 0 deletions
14
releasenotes/notes/lazy-testers-warn-on-import-errors-95a9bdaacc9c3d2b.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,14 @@ | ||
--- | ||
features: | ||
- | | ||
A new warning base class, :exc:`.QiskitWarning`, was added. While Qiskit will continue to use | ||
built-in Python warnings (such as :exc:`DeprecationWarning`) when those are most appropriate, | ||
for cases that are more specific to Qiskit, the warnings will be subclasses of :exc:`.QiskitWarning`. | ||
- | | ||
:exc:`.QPYLoadingDeprecatedFeatureWarning` is now a subclass of :exc:`.QiskitWarning`. | ||
- | | ||
The optional-functionality testers (:mod:`qiskit.utils.optionals`) will now distinguish an | ||
optional dependency that was completely not found (a normal situation) with one that was found, | ||
but triggered errors during its import. In the latter case, they will now issue an | ||
:exc:`.OptionalDependencyImportWarning` telling you what happened, since it might indicate a | ||
failed installation or an incompatible version. |
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