Skip to content

Commit

Permalink
Add comment explaining the 'assert x is not None' code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyandrewmeyer committed Aug 20, 2024
1 parent 56ded26 commit 52220aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scenario/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,7 @@ def deferred(self, handler: Callable, event_id: int = 1) -> DeferredEvent:
# not, then the coming checks are meaningless: the custom event could be named like a
# relation event but not *be* one.
if self._is_workload_event:
# Enforced by the consistency checker, but for type checkers:
assert self.container is not None
snapshot_data["container_name"] = self.container.name
if self.notice:
Expand All @@ -1810,6 +1811,7 @@ def deferred(self, handler: Callable, event_id: int = 1) -> DeferredEvent:
snapshot_data["check_name"] = self.check_info.name

elif self._is_relation_event:
# Enforced by the consistency checker, but for type checkers:
assert self.relation is not None
relation = self.relation
if isinstance(relation, PeerRelation):
Expand All @@ -1836,6 +1838,7 @@ def deferred(self, handler: Callable, event_id: int = 1) -> DeferredEvent:
] = f"{remote_app}/{self.relation_departed_unit_id}"

elif self._is_storage_event:
# Enforced by the consistency checker, but for type checkers:
assert self.storage is not None
snapshot_data.update(
{
Expand All @@ -1846,6 +1849,7 @@ def deferred(self, handler: Callable, event_id: int = 1) -> DeferredEvent:
)

elif self._is_secret_event:
# Enforced by the consistency checker, but for type checkers:
assert self.secret is not None
snapshot_data.update(
{"secret_id": self.secret.id, "secret_label": self.secret.label},
Expand All @@ -1854,6 +1858,7 @@ def deferred(self, handler: Callable, event_id: int = 1) -> DeferredEvent:
snapshot_data["secret_revision"] = self.secret_revision

elif self._is_action_event:
# Enforced by the consistency checker, but for type checkers:
assert self.action is not None
snapshot_data["id"] = self.action.id

Expand Down

0 comments on commit 52220aa

Please sign in to comment.