From cb4f459597b85954eb03f34366086c1250a8a1bf Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 29 Oct 2019 21:19:55 +0200 Subject: [PATCH] Fix typing for until_date argument (can be datetime or timedelta) --- aiogram/bot/bot.py | 7 +++++-- aiogram/types/chat.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 5933f0db..5e8f05d9 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -1,5 +1,6 @@ from __future__ import annotations +import datetime import typing import warnings @@ -963,7 +964,8 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): return types.File(**result) async def kick_chat_member(self, chat_id: typing.Union[base.Integer, base.String], user_id: base.Integer, - until_date: typing.Union[base.Integer, None] = None) -> base.Boolean: + until_date: typing.Union[ + base.Integer, datetime.datetime, datetime.timedelta, None] = None) -> base.Boolean: """ Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group @@ -1018,7 +1020,8 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): user_id: base.Integer, permissions: typing.Optional[types.ChatPermissions] = None, # permissions argument need to be required after removing other `can_*` arguments - until_date: typing.Union[base.Integer, None] = None, + until_date: typing.Union[ + base.Integer, datetime.datetime, datetime.timedelta, None] = None, can_send_messages: typing.Union[base.Boolean, None] = None, can_send_media_messages: typing.Union[base.Boolean, None] = None, can_send_other_messages: typing.Union[base.Boolean, None] = None, diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index f5c521a5..66b8fe4d 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -1,6 +1,7 @@ from __future__ import annotations import asyncio +import datetime import typing from . import base @@ -164,7 +165,7 @@ class Chat(base.TelegramObject): return await self.bot.delete_chat_description(self.id, description) async def kick(self, user_id: base.Integer, - until_date: typing.Union[base.Integer, None] = None): + until_date: typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None] = None): """ Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group @@ -205,7 +206,7 @@ class Chat(base.TelegramObject): async def restrict(self, user_id: base.Integer, permissions: typing.Optional[ChatPermissions] = None, - until_date: typing.Union[base.Integer, None] = None, + until_date: typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None] = None, can_send_messages: typing.Union[base.Boolean, None] = None, can_send_media_messages: typing.Union[base.Boolean, None] = None, can_send_other_messages: typing.Union[base.Boolean, None] = None,