From 83d04d2f3306feb71f31b8970e914e7afeb2cf61 Mon Sep 17 00:00:00 2001 From: Albrecht Degering Date: Tue, 21 Jul 2026 03:16:24 +0200 Subject: [PATCH] Replace Poll runtime assertions --- src/govoplan_poll/backend/service.py | 3 ++- src/govoplan_poll/backend/transitions.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/govoplan_poll/backend/service.py b/src/govoplan_poll/backend/service.py index fe12c66..1752e3f 100644 --- a/src/govoplan_poll/backend/service.py +++ b/src/govoplan_poll/backend/service.py @@ -483,7 +483,8 @@ def transition_poll( elif action == "close": poll.closed_at = now elif action == "decide": - assert decision_option is not None + if decision_option is None: + raise PollError("A decide transition requires a poll option") poll.decided_option_id = decision_option.id poll.decided_at = now if poll.closed_at is None: diff --git a/src/govoplan_poll/backend/transitions.py b/src/govoplan_poll/backend/transitions.py index f56c8f1..718f857 100644 --- a/src/govoplan_poll/backend/transitions.py +++ b/src/govoplan_poll/backend/transitions.py @@ -137,7 +137,8 @@ class PollTransitionEngine: raise ValueError("Archived poll has no valid status to restore") else: target_status = archived_from_status - assert target_status is not None + if target_status is None: + raise ValueError(f"Poll transition {action!r} did not resolve a target status") return PollTransitionPlan(action=action, from_status=current_status, to_status=target_status) def available_actions(