From 81b0fe54042e204ec256462b84d8778076a7dbb3 Mon Sep 17 00:00:00 2001 From: asimaranov Date: Sat, 18 Dec 2021 00:39:22 +0300 Subject: [PATCH] Fixed pydantic.errors.ConfigError due to unresolved LazyProxy type --- aiogram/dispatcher/filters/text.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/aiogram/dispatcher/filters/text.py b/aiogram/dispatcher/filters/text.py index 3dd36fbd..a790a9c3 100644 --- a/aiogram/dispatcher/filters/text.py +++ b/aiogram/dispatcher/filters/text.py @@ -5,8 +5,17 @@ from pydantic import root_validator from aiogram.dispatcher.filters import BaseFilter from aiogram.types import CallbackQuery, InlineQuery, Message, Poll -if TYPE_CHECKING: - from aiogram.utils.i18n.lazy_proxy import LazyProxy +try: + from babel.support import LazyProxy +except ImportError: # pragma: no cover + + class LazyProxy: # type: ignore + def __init__(self, func: Any, *args: Any, **kwargs: Any) -> None: + raise RuntimeError( + "LazyProxy can be used only when Babel installed\n" + "Just install Babel (`pip install Babel`) " + "or aiogram with i18n support (`pip install aiogram[i18n]`)" + ) TextType = Union[str, "LazyProxy"]