Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
839b6f2
update the deprecation policy in the semver
1ucian0 Nov 22, 2023
6bf8f7f
Merge branch 'main' of github.com:Qiskit/qiskit-terra into docs/depre…
1ucian0 Nov 23, 2023
cd47576
Addressing https://github.com/Qiskit/qiskit/pull/11296#discussion_r14…
1ucian0 Nov 23, 2023
901f254
QuantumCircuit.i
1ucian0 Nov 23, 2023
fb71bcc
merge
1ucian0 Nov 24, 2023
6c7e224
Merge branch 'main' of github.com:Qiskit/qiskit-terra into docs/depre…
1ucian0 Nov 24, 2023
cd5784b
Merge branch 'main' of github.com:Qiskit/qiskit-terra into docs/depre…
1ucian0 Nov 24, 2023
6e74d1d
https://github.com/Qiskit/qiskit-aer/pull/2006
1ucian0 Nov 24, 2023
2862783
conflict
1ucian0 Jan 15, 2024
aa7b88b
Merge branch 'main' of github.com:Qiskit/qiskit-terra into docs/depre…
1ucian0 Jan 17, 2024
11dcdea
Update qiskit/utils/deprecation.py
mtreinish Jan 30, 2024
8f56e0e
Merge branch 'docs/deprecation/1' of github.com:1ucian0/qiskit-terra …
1ucian0 Feb 13, 2025
313ee8b
conflict solving
1ucian0 Feb 13, 2025
4ee56eb
no floats, strings for "since"
1ucian0 Feb 13, 2025
6c2dfdb
Merge branch 'main' of github.com:Qiskit/qiskit-terra into docs/depre…
1ucian0 Feb 13, 2025
97a2740
reno
1ucian0 Feb 13, 2025
deed64b
Merge branch 'main' of github.com:Qiskit/qiskit-terra into docs/depre…
1ucian0 Feb 13, 2025
1dc0827
alternative
1ucian0 Feb 13, 2025
a941e89
Update qiskit/utils/deprecation.py
1ucian0 Feb 25, 2025
ce834d5
conflict
1ucian0 Mar 6, 2025
882da9d
lint
1ucian0 Mar 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions qiskit/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def deprecate_func(
additional_msg: str | None = None,
pending: bool = False,
package_name: str = "Qiskit",
removal_timeline: str = "no earlier than 3 months after the release date",
removal_timeline: str | None = None,
is_property: bool = False,
stacklevel: int = 2,
):
Expand All @@ -47,7 +47,8 @@ def deprecate_func(
pending: Set to ``True`` if the deprecation is still pending.
package_name: The package name shown in the deprecation message (e.g. the PyPI package name).
removal_timeline: 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".
like "in two major releases" or "in release 9.99". Default:
"in the next major release {since_major + 1}".
is_property: If the deprecated function is a `@property`, set this to True so that the
generated message correctly describes it as such. (This isn't necessary for
property setters, as their docstring is ignored by Python.)
Expand Down Expand Up @@ -112,7 +113,7 @@ def deprecate_arg(
package_name: str = "Qiskit",
new_alias: str | None = None,
predicate: Callable[[Any], bool] | None = None,
removal_timeline: str = "no earlier than 3 months after the release date",
removal_timeline: str | None = None,
):
"""Decorator to indicate an argument has been deprecated in some way.

Expand All @@ -139,7 +140,8 @@ def deprecate_arg(
`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: 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".
like "in two major releases" or "in release 9.99". Default:
"in the next major release {since_major + 1}".

Returns:
Callable: The decorated callable.
Expand Down Expand Up @@ -246,8 +248,12 @@ def _write_deprecation_msg(
since: str,
pending: bool,
additional_msg: str,
removal_timeline: str,
removal_timeline: str | None,
) -> tuple[str, Type[DeprecationWarning] | Type[PendingDeprecationWarning]]:
if not removal_timeline:
removal_major = int(str(since).split(".", maxsplit=1)[0]) + 1
removal_timeline = f"in the next major release {removal_major}.0"

if pending:
category: Type[DeprecationWarning] | Type[PendingDeprecationWarning] = (
PendingDeprecationWarning
Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
upgrade_misc:
- |
The decorators :func:`deprecate_func` and :func:`deprecate_arg` changed their default behaivor to adapt to the
Qiskit SemVer versioning (`RFC0020` <https://github.com/Qiskit/qiskit/issues/8729>`__). As a consequence,
the parameter ``removal_timeline`` default changed: from "no earlier than 3 months after the release date" to "in the next major
release {``since`` major + 1}". If you would like to preserve the previous messaging, you should set ``removal_timeline`` explicitly.
13 changes: 6 additions & 7 deletions test/python/utils/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def test_deprecate_func_docstring(self) -> None:

.. deprecated:: 9.99_pending
The class ``{__name__}._Foo`` is pending deprecation as of Qiskit 9.99. It \
will be marked deprecated in a future release, and then removed no earlier than 3 months after \
the release date.
will be marked deprecated in a future release, and then removed in the next major release 10.0.
"""
),
)
Expand All @@ -96,7 +95,7 @@ def test_deprecate_func_docstring(self) -> None:

.. deprecated:: 9.99
The method ``{__name__}._Foo.my_method()`` is deprecated as of Qiskit \
9.99. It will be removed no earlier than 3 months after the release date. Stop using this!
9.99. It will be removed in the next major release 10.0. Stop using this!
"""
),
)
Expand All @@ -108,7 +107,7 @@ def test_deprecate_func_docstring(self) -> None:

.. deprecated:: 9.99
The property ``{__name__}._Foo.my_property`` is deprecated as of Qiskit \
9.99. It will be removed no earlier than 3 months after the release date.
9.99. It will be removed in the next major release 10.0.
"""
),
)
Expand Down Expand Up @@ -152,18 +151,18 @@ def my_func() -> None:

.. deprecated:: 9.99
``{__name__}.{my_func.__qualname__}()``'s argument ``arg4`` is deprecated as of \
Qiskit 9.99. It will be removed no earlier than 3 months after the release date. Instead, \
Qiskit 9.99. It will be removed in the next major release 10.0. Instead, \
use foo.

.. deprecated:: 9.99
Using the argument arg3 is deprecated as of Qiskit 9.99. It will be \
removed no earlier than 3 months after the release date. Instead, use the argument ``new_arg3``, \
removed in the next major release 10.0. Instead, use the argument ``new_arg3``, \
which behaves identically.

.. deprecated:: 9.99_pending
``{__name__}.{my_func.__qualname__}()``'s argument ``arg2`` is pending \
deprecation as of Qiskit 9.99. It will be marked deprecated in a future release, and then \
removed no earlier than 3 months after the release date.
removed in the next major release 10.0.

.. deprecated:: 9.99
``{__name__}.{my_func.__qualname__}()``'s argument ``arg1`` is deprecated as of \
Expand Down