Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make it an error to call CollectStatusEvent.add_status with error or unknown #1386

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document exceptions using Raises
  • Loading branch information
james-garner-canonical committed Sep 25, 2024
commit e3edf3f0e6eb4adb957c023e3dd88d27b77ffe22
7 changes: 4 additions & 3 deletions ops/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,9 +1110,6 @@ class CollectStatusEvent(LifecycleEvent):
* waiting
* active

It is an error to call :meth:`add_status` with an instance of
:class:`ErrorStatus` or :class:`UnknownStatus`.

If there are multiple statuses with the same priority, the first one added
wins (and if an event is observed multiple times, the handlers are called
in the order they were observed).
Expand Down Expand Up @@ -1148,6 +1145,10 @@ def _on_collect_status(self, event: ops.CollectStatusEvent):
def add_status(self, status: model.StatusBase):
"""Add a status for evaluation.

Raises:
InvalidStatusError: when called with an instance of :class:`ErrorStatus`
or :class:`UnknownStatus`

See :class:`CollectStatusEvent` for a description of how to use this.
"""
if not isinstance(status, model.StatusBase):
Expand Down
Loading