Update method get_value

This commit is contained in:
wrrrzr 2024-03-06 14:30:57 +03:00
parent da278c8a1d
commit 61dfd60781
2 changed files with 4 additions and 4 deletions

View file

@ -20,8 +20,8 @@ class FSMContext:
async def get_data(self) -> Dict[str, Any]:
return await self.storage.get_data(key=self.key)
async def get_value(self, key: str) -> Any:
return await self.storage.get_value(key=self.key, data_key=key)
async def get_value(self, key: str, default: Any = None) -> Any:
return await self.storage.get_value(key=self.key, data_key=key, default=default)
async def update_data(
self, data: Optional[Dict[str, Any]] = None, **kwargs: Any

View file

@ -64,7 +64,7 @@ class BaseStorage(ABC):
"""
pass
async def get_value(self, key: StorageKey, data_key: str) -> Any:
async def get_value(self, key: StorageKey, data_key: str, default: Any) -> Any:
"""
Get selected value by key in current data
@ -73,7 +73,7 @@ class BaseStorage(ABC):
:return: value of current data by key
"""
current_data = await self.get_data(key=key)
return current_data[data_key]
return current_data.get(data_key)
async def update_data(self, key: StorageKey, data: Dict[str, Any]) -> Dict[str, Any]:
"""