Skip to content

Commit

Permalink
Omit qobj_id deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ElePT committed Feb 18, 2025
1 parent ea3c5ff commit 2b271b7
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 165 deletions.
12 changes: 2 additions & 10 deletions qiskit/providers/basic_provider/basic_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,16 +596,8 @@ def _run_job(self, job_id: str, qobj: QasmQobj) -> Result:
"time_taken": (end - start),
"header": qobj.header.to_dict(),
}
# We should not return the deprecation warning to the user,
# as it is not actionable for them.
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=".*``qobj_id`` is deprecated as of Qiskit 1.4",
module="qiskit",
)
return Result.from_dict(result)

return Result.from_dict(result)

@deprecate_func(
since="1.4.0",
Expand Down
9 changes: 0 additions & 9 deletions qiskit/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ class Result:

_metadata = {}

@deprecate_arg(
name="qobj_id",
since="1.4",
package_name="Qiskit",
removal_timeline="in Qiskit 2.0",
additional_msg="The Qobj class has been deprecated and will be "
"removed in Qiskit 2.0. This input argument cannot exist without Qobj.",
stacklevel=2,
)
def __init__(
self,
backend_name,
Expand Down
7 changes: 1 addition & 6 deletions qiskit/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def deprecate_arg(
new_alias: str | None = None,
predicate: Callable[[Any], bool] | None = None,
removal_timeline: str = "no earlier than 3 months after the release date",
stacklevel: int = 2,
):
"""Decorator to indicate an argument has been deprecated in some way.
Expand Down Expand Up @@ -141,7 +140,6 @@ def deprecate_arg(
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".
stacklevel: Stack level passed to :func:`warnings.warn`.
Returns:
Callable: The decorated callable.
Expand Down Expand Up @@ -182,7 +180,6 @@ def wrapper(*args, **kwargs):
warning_msg=msg,
category=category,
predicate=predicate,
stacklevel=stacklevel,
)
return func(*args, **kwargs)

Expand Down Expand Up @@ -252,7 +249,6 @@ def wrapper(*args, **kwargs):
warning_msg=old_kwarg_to_msg[old],
category=category,
predicate=None,
stacklevel=3,
)
return func(*args, **kwargs)

Expand Down Expand Up @@ -328,7 +324,6 @@ def _maybe_warn_and_rename_kwarg(
warning_msg: str,
category: Type[Warning],
predicate: Callable[[Any], bool] | None,
stacklevel: int = 2,
) -> None:
# In Python 3.10+, we should set `zip(strict=False)` (the default). That is, we want to
# stop iterating once `args` is done, since some args may have not been explicitly passed as
Expand All @@ -344,7 +339,7 @@ def _maybe_warn_and_rename_kwarg(
val = arg_names_to_values[old_arg_name]
if predicate and not predicate(val):
return
warnings.warn(warning_msg, category=category, stacklevel=stacklevel)
warnings.warn(warning_msg, category=category, stacklevel=3)

# Finally, if there's a new_alias, add its value dynamically to kwargs so that the code author
# only has to deal with the new_alias in their logic.
Expand Down
1 change: 0 additions & 1 deletion qiskit/visualization/gate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from qiskit.providers import BackendV2
from qiskit.providers.exceptions import BackendPropertyError
from qiskit.transpiler.coupling import CouplingMap
from qiskit.utils.deprecation import deprecate_arg
from .exceptions import VisualizationError


Expand Down
12 changes: 2 additions & 10 deletions test/python/primitives/test_backend_sampler_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,12 +1104,7 @@ def test_run_level1(self):
},
}
sampler = BackendSamplerV2(backend=backend, options=options)
# sampler.run will call the custom backend.run implementation
# that returns a deprecation warning
with self.assertWarnsRegex(
DeprecationWarning, expected_regex="``qobj_id`` is deprecated as of Qiskit 1.4"
):
result_single = sampler.run([qc]).result()
result_single = sampler.run([qc]).result()

options = {
"default_shots": shots,
Expand All @@ -1122,10 +1117,7 @@ def test_run_level1(self):
sampler = BackendSamplerV2(backend=backend, options=options)
# sampler.run will call the custom backend.run implementation
# that returns a deprecation warning
with self.assertWarnsRegex(
DeprecationWarning, expected_regex="``qobj_id`` is deprecated as of Qiskit 1.4"
):
result_avg = sampler.run([qc]).result()
result_avg = sampler.run([qc]).result()

# Check that averaging the meas_return="single" data matches the
# meas_return="avg" data.
Expand Down
4 changes: 0 additions & 4 deletions test/python/providers/test_backendstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
class TestBackendConfiguration(QiskitTestCase):
"""Test the BackendStatus class."""

def setUp(self):
"""Test backend status for one of the fake backends"""
super().setUp()

def test_repr(self):
"""Test representation methods of BackendStatus"""
with self.assertWarnsRegex(
Expand Down
Loading

0 comments on commit 2b271b7

Please sign in to comment.