mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Merge pull request #318 from aiogram/dev-3.x-refactor-sessions
Dev 3.x refactor sessions
This commit is contained in:
commit
05dd42712d
7 changed files with 151 additions and 44 deletions
|
|
@ -55,6 +55,16 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
|
|||
def build_request(self) -> Request: # pragma: no cover
|
||||
pass
|
||||
|
||||
request_timeout: Optional[float] = None
|
||||
|
||||
def dict(self, **kwargs: Any) -> Any:
|
||||
# override dict of pydantic.BaseModel to overcome exporting request_timeout field
|
||||
exclude = kwargs.pop("exclude", set())
|
||||
if isinstance(exclude, set):
|
||||
exclude.add("request_timeout")
|
||||
|
||||
return super().dict(exclude=exclude, **kwargs)
|
||||
|
||||
def build_response(self, data: Dict[str, Any]) -> Response[T]:
|
||||
# noinspection PyTypeChecker
|
||||
return Response[self.__returning__](**data) # type: ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue