diff --git a/aiogram/dispatcher/state/context.py b/aiogram/dispatcher/state/context.py index 795e3fb9..757f1d6f 100644 --- a/aiogram/dispatcher/state/context.py +++ b/aiogram/dispatcher/state/context.py @@ -33,8 +33,8 @@ class CurrentUserContext(Generic[StorageDataT]): self.storage = storage self.key = key_maker(chat_id, user_id) - async def get_state(self, default: Optional[str] = None) -> Optional[str]: - return await self.storage.get_state(self.key, default=default) + async def get_state(self) -> Optional[str]: + return await self.storage.get_state(self.key) async def get_data(self) -> StorageDataT: return await self.storage.get_data(self.key) diff --git a/aiogram/dispatcher/storage/base.py b/aiogram/dispatcher/storage/base.py index 34809a6b..7f9a4ebb 100644 --- a/aiogram/dispatcher/storage/base.py +++ b/aiogram/dispatcher/storage/base.py @@ -4,7 +4,7 @@ _DataT = TypeVar("_DataT") class BaseStorage(Generic[_DataT]): - async def get_state(self, key: str, default: Optional[str] = None) -> Optional[str]: + async def get_state(self, key: str) -> Optional[str]: raise NotImplementedError async def set_state(self, key: str, state: Optional[str]) -> None: diff --git a/aiogram/dispatcher/storage/dict.py b/aiogram/dispatcher/storage/dict.py index 8e9070d4..33f246a7 100644 --- a/aiogram/dispatcher/storage/dict.py +++ b/aiogram/dispatcher/storage/dict.py @@ -13,19 +13,18 @@ class _UserStorageMetaData(TypedDict): class DictStorage(BaseStorage[Dict[str, Any]]): """ - In-memory based states storage. - This type of storage is not recommended for usage in bots, because you will lost all states after restarting. + Python dictionary data structure based state storage. + Not the most persistent storage, not recommended for in-production environments. """ def __init__(self) -> None: - # note: we can use TypedDict for Dict flat value self.data: Dict[str, _UserStorageMetaData] = {} def resolve_address(self, key: str) -> None: if key not in self.data: self.data[key] = {"state": None, "data": {}} - async def get_state(self, key: str, default: Optional[str] = None) -> Optional[str]: + async def get_state(self, key: str) -> Optional[str]: self.resolve_address(key) return self.data[key]["state"]