Replace Poll runtime assertions
This commit is contained in:
@@ -483,7 +483,8 @@ def transition_poll(
|
|||||||
elif action == "close":
|
elif action == "close":
|
||||||
poll.closed_at = now
|
poll.closed_at = now
|
||||||
elif action == "decide":
|
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_option_id = decision_option.id
|
||||||
poll.decided_at = now
|
poll.decided_at = now
|
||||||
if poll.closed_at is None:
|
if poll.closed_at is None:
|
||||||
|
|||||||
@@ -137,7 +137,8 @@ class PollTransitionEngine:
|
|||||||
raise ValueError("Archived poll has no valid status to restore")
|
raise ValueError("Archived poll has no valid status to restore")
|
||||||
else:
|
else:
|
||||||
target_status = archived_from_status
|
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)
|
return PollTransitionPlan(action=action, from_status=current_status, to_status=target_status)
|
||||||
|
|
||||||
def available_actions(
|
def available_actions(
|
||||||
|
|||||||
Reference in New Issue
Block a user