Fixed pydantic.errors.ConfigError due to unresolved LazyProxy type

This commit is contained in:
asimaranov 2021-12-18 00:39:22 +03:00
parent 76ae5c4415
commit 81b0fe5404

View file

@ -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"]