From ea03d84901492fc03923ec5590d56fdcf6a9c09f Mon Sep 17 00:00:00 2001 From: Meghdad <61308304+MeghdadFadaee@users.noreply.github.com> Date: Wed, 22 Jul 2026 03:20:01 +0330 Subject: [PATCH] style: apply Ruff formatting --- src/blackout_notifier/clients.py | 7 ++----- src/blackout_notifier/config.py | 7 ++----- src/blackout_notifier/service.py | 8 ++------ tests/test_config.py | 1 + 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/blackout_notifier/clients.py b/src/blackout_notifier/clients.py index be49896..f5b21f0 100644 --- a/src/blackout_notifier/clients.py +++ b/src/blackout_notifier/clients.py @@ -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'}" ) diff --git a/src/blackout_notifier/config.py b/src/blackout_notifier/config.py index 0b03e72..fb3248f 100644 --- a/src/blackout_notifier/config.py +++ b/src/blackout_notifier/config.py @@ -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") diff --git a/src/blackout_notifier/service.py b/src/blackout_notifier/service.py index 829e5bf..69b5651 100644 --- a/src/blackout_notifier/service.py +++ b/src/blackout_notifier/service.py @@ -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() diff --git a/tests/test_config.py b/tests/test_config.py index 5d70dd5..59f8aa5 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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: