-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7502782
commit bacbcb4
Showing
6 changed files
with
42 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
from abc import abstractmethod | ||
from typing import TYPE_CHECKING, Any, Dict, Union | ||
from typing import Any | ||
|
||
if TYPE_CHECKING: | ||
from aiogram_i18n import I18nMiddleware | ||
from aiogram.filters.base import Filter | ||
|
||
from aiogram_i18n.managers.base import CallableMixin | ||
|
||
class BaseLazyFilter: | ||
async def startup(self, middleware: "I18nMiddleware") -> None: | ||
pass | ||
|
||
class BaseLazyFilter(Filter): | ||
async def call(self, context_key: str, **kwargs: Any): | ||
return await CallableMixin(callback=self.startup).call(kwargs.pop(context_key), **kwargs) | ||
|
||
@abstractmethod | ||
async def __call__(self, *args: Any, **kwargs: Any) -> Union[bool, Dict[str, Any]]: | ||
async def startup(self, *args: Any, **kwargs: Any) -> None: | ||
pass | ||
|
||
def __await__(self): # type: ignore # pragma: no cover | ||
# Is needed only for inspection and this method is never be called | ||
return self.__call__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.