From 21c5e8ba2c6982e6e66bf6d88482b72059ce3555 Mon Sep 17 00:00:00 2001 From: rdbende Date: Fri, 19 Jan 2024 22:01:32 +0100 Subject: [PATCH 1/2] Fix accidentaly messed up return type default_location getter --- cozy/model/settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cozy/model/settings.py b/cozy/model/settings.py index c9202233..ff23a297 100644 --- a/cozy/model/settings.py +++ b/cozy/model/settings.py @@ -1,14 +1,14 @@ import logging +from typing import NoReturn import peewee - -import cozy.ext.inject as inject from peewee import SqliteDatabase +import cozy.ext.inject as inject from cozy.db.book import Book from cozy.db.settings import Settings as SettingsModel from cozy.db.storage import Storage as StorageModel -from cozy.model.storage import Storage, InvalidPath +from cozy.model.storage import InvalidPath, Storage from cozy.report import reporter log = logging.getLogger("model.storage_location") @@ -47,11 +47,11 @@ def last_played_book(self, new_value): self._db_object.save(only=self._db_object.dirty_fields) @property - def default_location(self) -> bool: + def default_location(self) -> Storage | NoReturn: for location in self.storage_locations: if location.default: - return True - return False + return location + assert False, "this should never happen" @property def storage_locations(self) -> list[Storage]: From af9ec9f6307cd9dff14a9d5002823cfcb48b171d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedek=20D=C3=A9v=C3=A9nyi?= Date: Sat, 20 Jan 2024 12:40:39 +0100 Subject: [PATCH 2/2] Update cozy/model/settings.py Co-authored-by: Naglis Jonaitis <827324+naglis@users.noreply.github.com> --- cozy/model/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cozy/model/settings.py b/cozy/model/settings.py index ff23a297..1739530e 100644 --- a/cozy/model/settings.py +++ b/cozy/model/settings.py @@ -51,7 +51,7 @@ def default_location(self) -> Storage | NoReturn: for location in self.storage_locations: if location.default: return location - assert False, "this should never happen" + raise AssertionError("This should never happen") @property def storage_locations(self) -> list[Storage]: