From 839b6f2178967694fd367ec27500386cb18ce81a Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Wed, 22 Nov 2023 15:55:37 +0100 Subject: [PATCH 1/8] update the deprecation policy in the semver --- qiskit/utils/deprecation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qiskit/utils/deprecation.py b/qiskit/utils/deprecation.py index b37cb1d63dbb..127d1f9357c6 100644 --- a/qiskit/utils/deprecation.py +++ b/qiskit/utils/deprecation.py @@ -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 = "in the next major release", is_property: bool = False, ): """Decorator to indicate a function has been deprecated. @@ -46,7 +46,7 @@ def deprecate_func( pending: Set to ``True`` if the deprecation is still pending. package_name: The PyPI package name, e.g. "qiskit-nature". 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". 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.) @@ -111,7 +111,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 = "in the next major release", ): """Decorator to indicate an argument has been deprecated in some way. @@ -138,7 +138,7 @@ 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". Returns: Callable: The decorated callable. From cd47576b8d328c6f8cfb9679efafb0a76f36cd6a Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 23 Nov 2023 09:59:48 +0100 Subject: [PATCH 2/8] Addressing https://github.com/Qiskit/qiskit/pull/11296#discussion_r1402284119 --------- Co-authored-by: Matthew Treinish --- qiskit/utils/deprecation.py | 16 +++++++++++----- test/python/utils/test_deprecation.py | 13 ++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/qiskit/utils/deprecation.py b/qiskit/utils/deprecation.py index 127d1f9357c6..a6f6f05b4cb5 100644 --- a/qiskit/utils/deprecation.py +++ b/qiskit/utils/deprecation.py @@ -27,7 +27,7 @@ def deprecate_func( additional_msg: str | None = None, pending: bool = False, package_name: str = "qiskit", - removal_timeline: str = "in the next major release", + removal_timeline: str | None = None, is_property: bool = False, ): """Decorator to indicate a function has been deprecated. @@ -46,7 +46,8 @@ def deprecate_func( pending: Set to ``True`` if the deprecation is still pending. package_name: The PyPI package name, e.g. "qiskit-nature". removal_timeline: How soon can this deprecation be removed? Expects a value - like "in two major releases" 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.) @@ -111,7 +112,7 @@ def deprecate_arg( package_name: str = "qiskit", new_alias: str | None = None, predicate: Callable[[Any], bool] | None = None, - removal_timeline: str = "in the next major release", + removal_timeline: str | None = None, ): """Decorator to indicate an argument has been deprecated in some way. @@ -138,7 +139,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 "in two major releases" 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. @@ -353,8 +355,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(since.split(".")[0]) + 1 + removal_timeline = f"in the next major release {removal_major}.0" + if pending: category: Type[DeprecationWarning] | Type[ PendingDeprecationWarning diff --git a/test/python/utils/test_deprecation.py b/test/python/utils/test_deprecation.py index 56024d2e2e3a..9c17a0776a6c 100644 --- a/test/python/utils/test_deprecation.py +++ b/test/python/utils/test_deprecation.py @@ -84,8 +84,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. """ ), ) @@ -97,7 +96,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! """ ), ) @@ -109,7 +108,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. """ ), ) @@ -143,18 +142,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 \ From 901f254e8b500ea885beaacfdae56ed8bf23b6af Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 23 Nov 2023 10:57:22 +0100 Subject: [PATCH 3/8] QuantumCircuit.i --- qiskit/test/base.py | 4 ++-- qiskit/utils/mitigation/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qiskit/test/base.py b/qiskit/test/base.py index 839e15b0191f..e6aaf3575449 100644 --- a/qiskit/test/base.py +++ b/qiskit/test/base.py @@ -245,8 +245,8 @@ def setUpClass(cls): "Setting metadata to None.*", # and this one once Qiskit/qiskit-aer#1945 is merged and released. r"The method ``qiskit\.circuit\.quantumcircuit\.QuantumCircuit\.i\(\)`` is " - r"deprecated as of qiskit 0\.45\.0\. It will be removed no earlier than 3 " - r"months after the release date\. Use QuantumCircuit\.id as direct replacement\.", + r"deprecated as of qiskit 0\.45\.0\. It will be removed in the next major release 1\.0\. " + r"Use QuantumCircuit\.id as direct replacement\.", ] for msg in allow_aer_DeprecationWarning_message: diff --git a/qiskit/utils/mitigation/__init__.py b/qiskit/utils/mitigation/__init__.py index 54251715424d..d03b38e665f1 100644 --- a/qiskit/utils/mitigation/__init__.py +++ b/qiskit/utils/mitigation/__init__.py @@ -10,7 +10,7 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -# This code was originally copied from the qiskit-ignis repsoitory see: +# This code was originally copied from the qiskit-ignis repository see: # https://github.com/Qiskit/qiskit-ignis/blob/b91066c72171bcd55a70e6e8993b813ec763cf41/qiskit/ignis/mitigation/measurement/__init__.py # it was migrated as qiskit-ignis is being deprecated From 6e74d1db19d288465c7464cc21f76b2579a10902 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Fri, 24 Nov 2023 19:32:53 +0100 Subject: [PATCH 4/8] https://github.com/Qiskit/qiskit-aer/pull/2006 --- qiskit/utils/deprecation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qiskit/utils/deprecation.py b/qiskit/utils/deprecation.py index a6f6f05b4cb5..d72fb7b6dd0e 100644 --- a/qiskit/utils/deprecation.py +++ b/qiskit/utils/deprecation.py @@ -358,7 +358,8 @@ def _write_deprecation_msg( removal_timeline: str | None, ) -> tuple[str, Type[DeprecationWarning] | Type[PendingDeprecationWarning]]: if not removal_timeline: - removal_major = int(since.split(".")[0]) + 1 + # TODO: remove the cast `str()` once https://github.com/Qiskit/qiskit-aer/pull/2006 is released + removal_major = int(str(since).split(".")[0]) + 1 removal_timeline = f"in the next major release {removal_major}.0" if pending: From 11dcdea8a6ee1b2f1dc9e769bb58f3b9052cb7f6 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 30 Jan 2024 14:22:11 -0500 Subject: [PATCH 5/8] Update qiskit/utils/deprecation.py --- qiskit/utils/deprecation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qiskit/utils/deprecation.py b/qiskit/utils/deprecation.py index d72fb7b6dd0e..a6f6f05b4cb5 100644 --- a/qiskit/utils/deprecation.py +++ b/qiskit/utils/deprecation.py @@ -358,8 +358,7 @@ def _write_deprecation_msg( removal_timeline: str | None, ) -> tuple[str, Type[DeprecationWarning] | Type[PendingDeprecationWarning]]: if not removal_timeline: - # TODO: remove the cast `str()` once https://github.com/Qiskit/qiskit-aer/pull/2006 is released - removal_major = int(str(since).split(".")[0]) + 1 + removal_major = int(since.split(".")[0]) + 1 removal_timeline = f"in the next major release {removal_major}.0" if pending: From 4ee56eb0790f5eb928dce84ba13971ae9263a22d Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 13 Feb 2025 14:16:59 +0100 Subject: [PATCH 6/8] no floats, strings for "since" --- qiskit/providers/provider.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/providers/provider.py b/qiskit/providers/provider.py index dc836e7f25ee..3aef833460ee 100644 --- a/qiskit/providers/provider.py +++ b/qiskit/providers/provider.py @@ -30,7 +30,7 @@ class Provider: version = 0 @deprecate_func( - since=1.1, + since="1.1", additional_msg="The abstract Provider and ProviderV1 classes are deprecated and will be " "removed in 2.0. You can just remove it as the parent class and a `get_backend` " "method that returns the backends from `self.backend`.", @@ -45,7 +45,7 @@ class ProviderV1(Provider, ABC): version = 1 @deprecate_func( - since=1.1, + since="1.1", additional_msg="The abstract Provider and ProviderV1 classes are deprecated and will be " "removed in 2.0. You can just remove it as the parent class and a `get_backend` " "method that returns the backends from `self.backend`.", From 97a27409d281fd9adddb944505e78c348cdd65f9 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Fri, 14 Feb 2025 00:18:13 +0100 Subject: [PATCH 7/8] reno --- .../notes/semver_deprecation-6b0f07db27dfc638.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml diff --git a/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml b/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml new file mode 100644 index 000000000000..144083113fed --- /dev/null +++ b/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml @@ -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` `__). 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}". From 1dc0827406db8d5353d463435188c0cf4388825c Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Fri, 14 Feb 2025 00:22:44 +0100 Subject: [PATCH 8/8] alternative --- releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml b/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml index 144083113fed..881d700fc635 100644 --- a/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml +++ b/releasenotes/notes/semver_deprecation-6b0f07db27dfc638.yaml @@ -3,5 +3,5 @@ upgrade_misc: - | The decorators :func:`deprecate_func` and :func:`deprecate_arg` changed their default behaivor to adapt to the Qiskit SemVer versioning (`RFC0020` `__). 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}". + 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.