From: Christian Heller Date: Fri, 2 Aug 2024 09:30:30 +0000 (+0200) Subject: Minor typing fix. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/copy_structured?a=commitdiff_plain;h=69c2123dff59ff3df8e2abe0da059a9e6b0db05b;p=plomtask Minor typing fix. --- diff --git a/plomtask/db.py b/plomtask/db.py index dc61f1a..ee5f3b9 100644 --- a/plomtask/db.py +++ b/plomtask/db.py @@ -340,7 +340,8 @@ class BaseModel(Generic[BaseModelId]): def __getattribute__(self, name: str) -> Any: """Ensure fail if ._disappear() was called, except to check ._exists""" if name != '_exists' and not super().__getattribute__('_exists'): - raise HandledException('Object does not exist.') + msg = f'Object for attribute does not exist: {name}' + raise HandledException(msg) return super().__getattribute__(name) def _disappear(self) -> None: @@ -365,10 +366,11 @@ class BaseModel(Generic[BaseModelId]): cls.cache_ = {} @classmethod - def get_cache(cls: type[BaseModelInstance]) -> dict[Any, BaseModel[Any]]: + def get_cache(cls: type[BaseModelInstance] + ) -> dict[Any, BaseModelInstance]: """Get cache dictionary, create it if not yet existing.""" if not hasattr(cls, 'cache_'): - d: dict[Any, BaseModel[Any]] = {} + d: dict[Any, BaseModelInstance] = {} cls.cache_ = d return cls.cache_