Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not emit warnings from
opflow
initialisation
Opflow is completely deprecated, and `import qiskit.opflow` should and does raise a warning blaming the importer. However, during the import, several opflow objects are initialised, which also trigger deprecation warnings. These will correctly be blamed on internal Qiskit library code, and so will not be shown to users by default. However, test suites running with all warnings treated as errors will also see these warnings, which will mask the one true warning that should be handled by the downstream code. It would be valid for downstream code to filter out these internal warnings, but in order to make it easier for downstream code to do the correct thing immediately, this opts to silence the internal warnings during initialisation. Downstream code running with all warnings enabled will now _only_ see the warning from `import qiskit.opflow` which is the only actionable warning they should have to deal with anyway. These warnings are only filtered during the initialisation and are targetted specifically at opflow-internal deprecation warnings. In general, deprecated code will call other deprecated code and it is not necessary to filter every single usage. This particular commit is a slight compromise to make it slightly easier for downstream libraries to do the right thing.
- Loading branch information