push
github
Do not emit warnings from `opflow` initialisation (#10830) (#10832) 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. (cherry picked from commit e5997133d) Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
17 of 17 new or added lines in 1 file covered. (100.0%)
74131 of 84970 relevant lines covered (87.24%)
61241.65 hits per line