diff --git a/pulser-core/pulser/register/base_register.py b/pulser-core/pulser/register/base_register.py index f23552bb7..9b30c33bd 100644 --- a/pulser-core/pulser/register/base_register.py +++ b/pulser-core/pulser/register/base_register.py @@ -78,14 +78,13 @@ def __init__( [pm.AbstractArray(v, dtype=float) for v in qubits.values()] ) self._ids: tuple[QubitId, ...] = tuple(qubits.keys()) - not_str = [id for id in self._ids if not isinstance(id, str)] - if not_str: + if any(not isinstance(id, str) for id in self._ids): warnings.simplefilter("always") warnings.warn( - "Usage of `int`s as `QubitId`s will be deprecated. Define " - "your `QubitId`s as `str`s, prefer setting `prefix='q'` " - "when using classmethods, as that will become the new " - "default once `int` qubit IDs become invalid.", + "Usage of `int`s or any non-`str`types as `QubitId`s will be " + "deprecated. Define your `QubitId`s as `str`s, prefer setting " + "`prefix='q'` when using classmethods, as that will become the" + " new default once `int` qubit IDs become invalid.", DeprecationWarning, stacklevel=2, ) diff --git a/pyproject.toml b/pyproject.toml index 65e6872bc..b71074177 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ filterwarnings = [ "error", # Except these particular warnings, which are ignored 'ignore:A duration of \d+ ns is not a multiple of:UserWarning', - 'ignore:Usage of `int`s as `QubitId`s will be deprecated:DeprecationWarning', + 'ignore:Usage of `int`s or any non-`str`types as `QubitId`s:DeprecationWarning', ] [build-system] diff --git a/tests/test_abstract_repr.py b/tests/test_abstract_repr.py index 4570060b3..f218fe77a 100644 --- a/tests/test_abstract_repr.py +++ b/tests/test_abstract_repr.py @@ -822,7 +822,7 @@ def test_exceptions(self, sequence): AbstractReprError, match="Name collisions encountered" ), pytest.warns( DeprecationWarning, - match="Usage of `int`s as `QubitId`s will be deprecated.", + match="Usage of `int`s or any non-`str`types as `QubitId`s", ): Register({"0": (0, 0), 0: (20, 20)})._to_abstract_repr() diff --git a/tests/test_json.py b/tests/test_json.py index 30997156c..4ee83a8c8 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -128,13 +128,13 @@ def test_detuning_map(): def test_register_numbered_keys(reg_dict): with pytest.warns( DeprecationWarning, - match="Usage of `int`s as `QubitId`s will be deprecated.", + match="Usage of `int`s or any non-`str`types as `QubitId`s", ): reg = (Register if len(reg_dict[2]) == 2 else Register3D)(reg_dict) j = json.dumps(reg, cls=PulserEncoder) with pytest.warns( DeprecationWarning, - match="Usage of `int`s as `QubitId`s will be deprecated.", + match="Usage of `int`s or any non-`str`types as `QubitId`s", ): decoded_reg = json.loads(j, cls=PulserDecoder) assert reg == decoded_reg diff --git a/tests/test_sequence.py b/tests/test_sequence.py index 6c95e60fb..d13d5bc3d 100644 --- a/tests/test_sequence.py +++ b/tests/test_sequence.py @@ -1616,7 +1616,7 @@ def test_str(reg, device, mod_device, det_map): assert seq.__str__() == msg_ch0 + msg_ch1 + msg_det_map + measure_msg with pytest.warns( DeprecationWarning, - match="Usage of `int`s as `QubitId`s will be deprecated.", + match="Usage of `int`s or any non-`str`types as `QubitId`s", ): seq2 = Sequence(Register({"q0": (0, 0), 1: (5, 5)}), device) seq2.declare_channel("ch1", "rydberg_global")