From 5a2cb9704b134004275d7dc723db23f96667fa12 Mon Sep 17 00:00:00 2001 From: Rishat Fayzullin Date: Tue, 12 Mar 2024 17:27:52 +0300 Subject: [PATCH] Refactoring while review --- aiogram/fsm/storage/base.py | 6 +++--- aiogram/fsm/storage/mongo.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/aiogram/fsm/storage/base.py b/aiogram/fsm/storage/base.py index 3078ce44..a3f3f976 100644 --- a/aiogram/fsm/storage/base.py +++ b/aiogram/fsm/storage/base.py @@ -72,11 +72,11 @@ class DefaultKeyBuilder(KeyBuilder): if self.with_destiny: parts.append(key.destiny) elif key.destiny != DEFAULT_DESTINY: - raise ValueError( + error_message = ( "Default key builder is not configured to use key destiny other than the default." - "\n\n" - "Probably, you should set `with_destiny=True` in for DefaultKeyBuilder." + "\n\nProbably, you should set `with_destiny=True` in for DefaultKeyBuilder." ) + raise ValueError(error_message) parts.append(part) return self.separator.join(parts) diff --git a/aiogram/fsm/storage/mongo.py b/aiogram/fsm/storage/mongo.py index 48061566..8bc95217 100644 --- a/aiogram/fsm/storage/mongo.py +++ b/aiogram/fsm/storage/mongo.py @@ -44,7 +44,7 @@ class MongoStorage(BaseStorage): @classmethod def from_url( - cls, url: str, connection_kwargs: Dict[str, Any] = {}, **kwargs: Any + cls, url: str, connection_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Any ) -> "MongoStorage": """ Create an instance of :class:`MongoStorage` with specifying the connection string @@ -54,6 +54,8 @@ class MongoStorage(BaseStorage): :param kwargs: arguments to be passed to :class:`MongoStorage` :return: an instance of :class:`MongoStorage` """ + if connection_kwargs is None: + connection_kwargs = {} client = AsyncIOMotorClient(url, **connection_kwargs) return cls(client=client, **kwargs)