From d47bf34522e5537a0e38aa0e9f37ded5572e0390 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 22 Apr 2019 10:08:42 -0400 Subject: [PATCH] Replace assert statements by normal if/raise --- harmonyqml/backend/model/list_model.py | 6 ++++-- harmonyqml/backend/signal_manager.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/harmonyqml/backend/model/list_model.py b/harmonyqml/backend/model/list_model.py index 83ffe620..0b386f28 100644 --- a/harmonyqml/backend/model/list_model.py +++ b/harmonyqml/backend/model/list_model.py @@ -78,8 +78,10 @@ class ListModel(QAbstractListModel): def _convert_new_value(self, value: NewItem) -> ListItem: def convert() -> ListItem: if self._data and isinstance(value, Mapping): - assert set(value.keys()) <= set(self.roles), \ - f"{value}: must have all these keys: {self.roles}" + if not set(value.keys()) <= set(self.roles): + raise ValueError( + f"{value}: must have all these keys: {self.roles}" + ) return type(self._data[0])(**value) diff --git a/harmonyqml/backend/signal_manager.py b/harmonyqml/backend/signal_manager.py index 3f67932a..4d144b31 100644 --- a/harmonyqml/backend/signal_manager.py +++ b/harmonyqml/backend/signal_manager.py @@ -124,7 +124,8 @@ class SignalManager(QObject): inviter: Inviter = None, left_event: LeftEvent = None) -> None: - assert not (inviter and left_event) + if (inviter and left_event): + raise ValueError() model = self.backend.models.rooms[client.userId] no_update = []