qiskit-documentation/docs/api/qiskit/0.43/qiskit.utils.deprecate_arg.mdx

39 lines
2.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: deprecate_arg
description: API reference for qiskit.utils.deprecate_arg
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.utils.deprecate_arg
---
<span id="qiskit-utils-deprecate-arg" />
# qiskit.utils.deprecate\_arg
<Function id="qiskit.utils.deprecate_arg" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.24/qiskit/utils/deprecation.py" signature="deprecate_arg(name, *, since, additional_msg=None, deprecation_description=None, pending=False, package_name='qiskit-terra', new_alias=None, predicate=None, removal_timeline='no earlier than 3 months after the release date')">
Decorator to indicate an argument has been deprecated in some way.
This decorator may be used multiple times on the same function, once per deprecated argument. It should be placed beneath other decorators like `@staticmethod` and property decorators.
**Parameters**
* **name** (*str*) The name of the deprecated argument.
* **since** (*str*) The version the deprecation started at. If the deprecation is pending, set the version to when that started; but later, when switching from pending to deprecated, update since to the new version.
* **deprecation\_description** (*str | None*) What is being deprecated? E.g. “Setting my\_func()s my\_arg argument to None.” If not set, will default to “\{func\_name}s argument \{name}”.
* **additional\_msg** (*str | None*) Put here any additional information, such as what to use instead (if new\_alias is not set). For example, “Instead, use the argument new\_arg, which is similar but does not impact the circuits setup.”
* **pending** (*bool*) Set to True if the deprecation is still pending.
* **package\_name** (*str*) The PyPI package name, e.g. “qiskit-nature”.
* **new\_alias** (*str | None*) If the arg has simply been renamed, set this to the new name. The decorator will dynamically update the kwargs so that when the user sets the old arg, it will be passed in as the new\_alias arg.
* **predicate** (*Callable\[\[Any], bool] | None*) Only log the runtime warning if the predicate returns True. This is useful to deprecate certain values or types for an argument, e.g. lambda my\_arg: isinstance(my\_arg, dict). Regardless of if a predicate is set, the runtime warning will only log when the user specifies the argument.
* **removal\_timeline** (*str*) How soon can this deprecation be removed? Expects a value like “no sooner than 6 months after the latest release” or “in release 9.99”.
**Returns**
The decorated callable.
**Return type**
Callable
</Function>