Add qpy deprecation warning class#11260
Conversation
Pull Request Test Coverage Report for Build 7274445496
💛 - Coveralls |
jakelishman
left a comment
There was a problem hiding this comment.
Don't forget to add a documentation line for the new warning in the QPY API docs (you can use autoexception, because Python makes tons of sense).
|
Do you plan on having this limited to |
|
One or more of the the following people are requested to review this:
|
What other types of warnings are you thinking about @TsafrirA? This seemed to be an issue particularly for |
I am planning to replace the deprecation warning with a user warning once the process of #11257 is completed. That shouldn't be a problem? |
You can replace |
|
I didn't explain myself well. Once we remove the support which is deprecated in #11257, pulses loaded from old QPY files will be altered. I was planning of issuing a user warning at that point to alert the user to the change. Do we then need a similar mechanism for a user warning? |
jakelishman
left a comment
There was a problem hiding this comment.
This looks sensible to me (except for why Python calls warnings exceptions), thanks!
Summary
This PR proposes a new
QPYLoadingDeprecatedFeatureWarningclass inspired in numpy's VisibleDeprecationWarning with the purpose of ensuring that deprecation messages reach the user even if they are raised from variable points in the call stack. The intended use case are qpy loading functions that can be called recursively (hence the name).Details and comments
The original issue was found during the review of #11257
Note: I have tested that the warning is visible using the example from #11257. I dumped a schedule with a complex amplitude using
qpy v.5(qiskit-terra 0.21) and tried loading it with the latest qpy version. The warning wouldn't surface with the usualDeprecationWarningclass but it did withQPYLoadingDeprecatedFeatureWarning: