Skip to content
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

Allow @deprecate_arg predicate to also normalize the argument's value #9902

Closed
Eric-Arellano opened this issue Apr 3, 2023 · 1 comment
Closed
Assignees

Comments

@Eric-Arellano
Copy link
Collaborator

There are a few cases where deprecated argument data types get normalized. Currently, we end up duplicating the code to detect if it's a bad data type so that we can a) issue the warning via @deprecate_arg and b) normalize the data inside the body of the function. See #9897 (comment) for an example.

It would be useful if we could have predicate also normalize the data. I'm thinking we have it update the *args and **kwargs passed to the original function, which we already have precedent of doing with new_alias:

https://github.com/Qiskit/qiskit-terra/blob/751fa46947aa1cc581b0fc25673236e396397b0f/qiskit/utils/deprecation.py#L294-L295

We probably want predicate to have the return type of bool | tuple[bool, Any]. That is, you can still simply return a bool if it's normalized or not. Or, you can return the bool + the normalized value.

@Eric-Arellano
Copy link
Collaborator Author

Imo this is low priority. It would still be neat, but seems unlikely we'll get to this. Feel free to reopen if others disagree.

@Eric-Arellano Eric-Arellano closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant