mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix compatibility with pydantic 1.5 (temporary)
This commit is contained in:
parent
01c6303d67
commit
e9fef19129
5 changed files with 117 additions and 77 deletions
|
|
@ -20,10 +20,14 @@ class CallableMixin:
|
|||
spec: inspect.FullArgSpec = field(init=False)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
callback = self.callback
|
||||
callback = inspect.unwrap(self.callback)
|
||||
self.awaitable = inspect.isawaitable(callback) or inspect.iscoroutinefunction(callback)
|
||||
while hasattr(callback, "__wrapped__"): # Try to resolve decorated callbacks
|
||||
callback = callback.__wrapped__ # type: ignore
|
||||
if isinstance(callback, BaseFilter):
|
||||
# Pydantic 1.5 has incorrect signature generator
|
||||
# Issue: https://github.com/samuelcolvin/pydantic/issues/1419
|
||||
# Fixes: https://github.com/samuelcolvin/pydantic/pull/1427
|
||||
# TODO: Remove this temporary fix
|
||||
callback = inspect.unwrap(callback.__call__)
|
||||
self.spec = inspect.getfullargspec(callback)
|
||||
|
||||
def _prepare_kwargs(self, kwargs: Dict[str, Any]) -> Dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class BaseHandler(BaseHandlerMixin[T], ABC):
|
|||
|
||||
@property
|
||||
def update(self) -> Update:
|
||||
return cast(Update, self.data["update"])
|
||||
return cast(Update, self.data.get("update", self.data.get("event_update")))
|
||||
|
||||
@abstractmethod
|
||||
async def handle(self) -> Any: # pragma: no cover
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue