Skip to content

Commit 06dcd22

Browse files
authored
fix: Warn when calling nonexistent properties (#1370)
1 parent fe9cb10 commit 06dcd22

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/braket/aws/aws_device.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ def properties(self) -> DeviceCapabilities:
497497
498498
.. _amazon-braket-schemas-python: https://github.com/aws/amazon-braket-schemas-python
499499
"""
500+
if not self._properties:
501+
warnings.warn(
502+
"No device capabilities found;"
503+
" please make sure you are using the latest version of amazon-braket-schemas.",
504+
stacklevel=1,
505+
)
500506
return self._properties
501507

502508
@property

‎test/unit_tests/braket/aws/test_aws_device.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,8 @@ def test_get_device_invalid_capabilities(arn):
693693
mock_session.region = RIGETTI_REGION
694694
device = AwsDevice(arn, mock_session)
695695
assert device is not None
696-
assert device.properties is None
696+
with pytest.warns(UserWarning):
697+
assert device.properties is None
697698

698699

699700
MOCK_PULSE_MODEL_QPU_PULSE_CAPABILITIES_JSON_1 = {

0 commit comments

Comments
 (0)