style: apply Ruff formatting
This commit is contained in:
@@ -114,14 +114,11 @@ class EitaaClient:
|
||||
try:
|
||||
body = response.json()
|
||||
except requests.JSONDecodeError as error:
|
||||
raise ExternalServiceError(
|
||||
f"Eitaa returned invalid JSON for chat {chat_id}"
|
||||
) from error
|
||||
raise ExternalServiceError(f"Eitaa returned invalid JSON for chat {chat_id}") from error
|
||||
if not isinstance(body, dict) or body.get("ok") is not True:
|
||||
description = body.get("description") if isinstance(body, dict) else None
|
||||
raise ExternalServiceError(
|
||||
f"Eitaa rejected the message for chat {chat_id}: "
|
||||
f"{description or 'unknown error'}"
|
||||
f"Eitaa rejected the message for chat {chat_id}: {description or 'unknown error'}"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -88,16 +88,13 @@ def _bill_chat_map(raw_routes: str) -> dict[str, tuple[str, ...]]:
|
||||
malformed.append(route)
|
||||
continue
|
||||
if not bill_id.isdecimal():
|
||||
raise ConfigurationError(
|
||||
f"BILL_CHAT_MAP bill IDs must be decimal: {bill_id}"
|
||||
)
|
||||
raise ConfigurationError(f"BILL_CHAT_MAP bill IDs must be decimal: {bill_id}")
|
||||
chat_ids = routes.setdefault(bill_id, [])
|
||||
if chat_id not in chat_ids:
|
||||
chat_ids.append(chat_id)
|
||||
if malformed:
|
||||
raise ConfigurationError(
|
||||
"BILL_CHAT_MAP entries must use BILL_ID:CHAT_ID format: "
|
||||
+ ", ".join(malformed)
|
||||
"BILL_CHAT_MAP entries must use BILL_ID:CHAT_ID format: " + ", ".join(malformed)
|
||||
)
|
||||
if not routes:
|
||||
raise ConfigurationError("BILL_CHAT_MAP must contain at least one route")
|
||||
|
||||
@@ -91,9 +91,7 @@ class OutageService:
|
||||
|
||||
previous = Outage.from_dict(record["snapshot"])
|
||||
if record["status"] == "cancelled":
|
||||
if self._notify(
|
||||
chat_ids, reactivated_outage_message(bill_id, outage, now), result
|
||||
):
|
||||
if self._notify(chat_ids, reactivated_outage_message(bill_id, outage, now), result):
|
||||
records[event_id] = _record(outage, now)
|
||||
result.state_changed = True
|
||||
continue
|
||||
@@ -126,9 +124,7 @@ class OutageService:
|
||||
if record["missing_checks"] == 0:
|
||||
record["missing_checks"] = 1
|
||||
result.state_changed = True
|
||||
elif self._notify(
|
||||
chat_ids, cancelled_outage_message(bill_id, previous, now), result
|
||||
):
|
||||
elif self._notify(chat_ids, cancelled_outage_message(bill_id, previous, now), result):
|
||||
record["status"] = "cancelled"
|
||||
record["missing_checks"] = 2
|
||||
record["notified_at"] = now.isoformat()
|
||||
|
||||
@@ -59,6 +59,7 @@ def test_config_rejects_malformed_routes(
|
||||
with pytest.raises(ConfigurationError, match="BILL_ID:CHAT_ID"):
|
||||
Config.from_env()
|
||||
|
||||
|
||||
def test_legacy_single_chat_configuration_is_still_supported(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user