Skip to content

Commit 4613a31

Browse files
committed
fix:LintErrors
1 parent 7529642 commit 4613a31

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

examples/alarm/alarm.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
id = client.create_or_update_alarm(create_request)
3939

4040
# Get the alarm by its instance ID (the unique occurrence identifier)
41-
alarm = client.get_alarm(id)
41+
if id:
42+
alarm = client.get_alarm(id)
4243
print(f"Retrieved alarm: {alarm.alarm_id}, Condition: {alarm.condition}")
4344

4445
# Update the alarm with a higher severity (same alarm_id, updates the same instance)
@@ -70,10 +71,11 @@
7071
for alarm in query_response.alarms:
7172
print(f" Alarm ID: {alarm.alarm_id}, Transitions: {len(alarm.transitions)}")
7273
for transition in alarm.transitions:
73-
print(f" - {transition.transition_type}: {transition.condition}")
74+
print(f"- {transition.transition_type}: {transition.condition}")
7475

75-
# Acknowledge the alarm
76-
client.acknowledge_alarms(ids=[id])
76+
if id:
77+
# Acknowledge the alarm
78+
client.acknowledge_alarms(ids=[id])
7779

7880
# Clear the alarm with 409 conflict handling - Method 1: Manual exception handling
7981
# A 409 Conflict response indicates that the requested transition would not change the alarm's state.
@@ -105,5 +107,6 @@
105107
else:
106108
print(f"Alarm cleared successfully: {result}")
107109

108-
# Delete the alarm by its instance ID
109-
client.delete_alarm(id)
110+
if id:
111+
# Delete the alarm by its instance ID
112+
client.delete_alarm(id)

nisystemlink/clients/alarm/_alarm_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def acknowledge_alarms(
6060
...
6161

6262
def create_or_update_alarm(
63-
self, request: models.CreateOrUpdateAlarmRequest, *, ignore_conflict: bool = False
63+
self,
64+
request: models.CreateOrUpdateAlarmRequest,
65+
*,
66+
ignore_conflict: bool = False,
6467
) -> str | None:
6568
"""Creates or updates an instance, or occurrence, of an alarm.
6669

tests/integration/alarm/test_alarm_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _unique_identifier() -> str:
4040
@pytest.fixture
4141
def create_alarms(
4242
client: AlarmClient,
43-
) -> Generator[Callable[[str, int, str], str], None, None]:
43+
) -> Generator[Callable[[str, int, str], str | None], None, None]:
4444
"""Fixture to return a factory that creates alarms.
4545
4646
Returns instance_id (referred to as 'id' in tests) for each created alarm.
@@ -51,7 +51,7 @@ def _create_alarms(
5151
alarm_id: str,
5252
severity_level: int = 3,
5353
condition: str = "Test Condition",
54-
) -> str:
54+
) -> str | None:
5555
"""Create an alarm and return its instance_id."""
5656
request = CreateOrUpdateAlarmRequest(
5757
alarm_id=alarm_id,
@@ -62,7 +62,8 @@ def _create_alarms(
6262
),
6363
)
6464
id = client.create_or_update_alarm(request)
65-
created_ids.append(id)
65+
if id:
66+
created_ids.append(id)
6667
return id
6768

6869
yield _create_alarms
@@ -320,6 +321,7 @@ def test__delete_alarm__returns_none(
320321
)
321322
id = client.create_or_update_alarm(request)
322323

324+
assert id is not None
323325
# Delete returns None on success
324326
result = client.delete_alarm(id)
325327
assert result is None

0 commit comments

Comments
 (0)