-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[blocked by 9611] Add @deprecate_arg
decorator
#9659
Conversation
…ore-deprecation-metadata
…ore-deprecation-metadata
…ore-deprecation-metadata
…ore-deprecation-metadata
…ore-deprecation-metadata
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
@deprecate_argument
decorator@deprecate_arg
decorator
@deprecate_arg
decorator@deprecate_arg
decorator
b12adc0
to
da959d3
Compare
This PR is too big to review. Going to split it out into a PR that adds (All still blocked by #9611 though.) |
Summary
There were many instances where we deprecated arguments, but used
warnings.warn()
directly rather than a utility fromdeprecation.py
. That is an issue because it means we won't be setting__qiskit_deprecations__
on the function (#9611), which means that the deprecation won't show up in our docs.This adds the new
@deprecate_arg
decorator, which allows us to migrate all current argument deprecations.A benefit of this new decorator is it standardizes how we word the deprecation. Some examples:
Details and comments
Why not instead improve
@deprecate_arguments
(plural)? It's too brittle trying to fit all the metadata about multiple arguments' deprecations into a single decorator, as it requires us to use dictionaries to map the argument to the metadata. For example, we might want to deprecate different arguments at different times (since
argument), but that wasn't possible before.The deprecation will always show up in our documentation. But at runtime, a warning will only happen if the argument was used and the optional
predicate
function returns True.For pending deprecations, rather than having a
category: Type[DeprecationWarning]
argument, we have the more confinedpending: bool
. As explained in #9601, this is a simpler interface for developers. The downside is we can't support arbitrary types of deprecation warnings, likeCustomDeprecationWarning
. But I don't see the need for that.A follow up will tackle
@deprecate_function
.