From b5f086b9cae3e5bf44a8ba43fbc06f30819c5fac Mon Sep 17 00:00:00 2001 From: "tg:@mars_hall" Date: Fri, 22 Mar 2024 18:50:49 +0100 Subject: [PATCH] Add typehints to all of the decorators classes (#34) Signed-off-by: eyMarv --- pyrogram/methods/decorators/on_callback_query.py | 8 ++++++-- pyrogram/methods/decorators/on_chat_join_request.py | 8 ++++++-- pyrogram/methods/decorators/on_chat_member_updated.py | 8 ++++++-- pyrogram/methods/decorators/on_chosen_inline_result.py | 8 ++++++-- pyrogram/methods/decorators/on_deleted_messages.py | 8 ++++++-- pyrogram/methods/decorators/on_disconnect.py | 4 ++-- pyrogram/methods/decorators/on_edited_message.py | 8 ++++++-- pyrogram/methods/decorators/on_inline_query.py | 8 ++++++-- pyrogram/methods/decorators/on_message.py | 8 ++++++-- pyrogram/methods/decorators/on_poll.py | 8 ++++++-- pyrogram/methods/decorators/on_raw_update.py | 7 +++++-- pyrogram/methods/decorators/on_story.py | 8 ++++++-- pyrogram/methods/decorators/on_user_status.py | 8 ++++++-- 13 files changed, 73 insertions(+), 26 deletions(-) diff --git a/pyrogram/methods/decorators/on_callback_query.py b/pyrogram/methods/decorators/on_callback_query.py index 43069f7c2..fa4f24279 100644 --- a/pyrogram/methods/decorators/on_callback_query.py +++ b/pyrogram/methods/decorators/on_callback_query.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnCallbackQuery: - def on_callback_query(self=None, filters=None, group: int = 0) -> Callable: + def on_callback_query( + self: Union["OnCallbackQuery", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling callback queries. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_chat_join_request.py b/pyrogram/methods/decorators/on_chat_join_request.py index 06a6cdeb6..bd6b7bd81 100644 --- a/pyrogram/methods/decorators/on_chat_join_request.py +++ b/pyrogram/methods/decorators/on_chat_join_request.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnChatJoinRequest: - def on_chat_join_request(self=None, filters=None, group: int = 0) -> Callable: + def on_chat_join_request( + self: Union["OnChatJoinRequest", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling chat join requests. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_chat_member_updated.py b/pyrogram/methods/decorators/on_chat_member_updated.py index 49705abef..36493f762 100644 --- a/pyrogram/methods/decorators/on_chat_member_updated.py +++ b/pyrogram/methods/decorators/on_chat_member_updated.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnChatMemberUpdated: - def on_chat_member_updated(self=None, filters=None, group: int = 0) -> Callable: + def on_chat_member_updated( + self: Union["OnChatMemberUpdated", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling event changes on chat members. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_chosen_inline_result.py b/pyrogram/methods/decorators/on_chosen_inline_result.py index 7cbf15e78..aae09e580 100644 --- a/pyrogram/methods/decorators/on_chosen_inline_result.py +++ b/pyrogram/methods/decorators/on_chosen_inline_result.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnChosenInlineResult: - def on_chosen_inline_result(self=None, filters=None, group: int = 0) -> Callable: + def on_chosen_inline_result( + self: Union["OnChosenInlineResult", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling chosen inline results. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_deleted_messages.py b/pyrogram/methods/decorators/on_deleted_messages.py index 6d3a4b4ab..4f67c50c5 100644 --- a/pyrogram/methods/decorators/on_deleted_messages.py +++ b/pyrogram/methods/decorators/on_deleted_messages.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnDeletedMessages: - def on_deleted_messages(self=None, filters=None, group: int = 0) -> Callable: + def on_deleted_messages( + self: Union["OnDeletedMessages", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling deleted messages. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_disconnect.py b/pyrogram/methods/decorators/on_disconnect.py index 6a5875947..9d624cbb0 100644 --- a/pyrogram/methods/decorators/on_disconnect.py +++ b/pyrogram/methods/decorators/on_disconnect.py @@ -16,13 +16,13 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional import pyrogram class OnDisconnect: - def on_disconnect(self=None) -> Callable: + def on_disconnect(self: Optional["OnDisconnect"] = None) -> Callable: """Decorator for handling disconnections. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_edited_message.py b/pyrogram/methods/decorators/on_edited_message.py index f7133cde8..71baaef51 100644 --- a/pyrogram/methods/decorators/on_edited_message.py +++ b/pyrogram/methods/decorators/on_edited_message.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnEditedMessage: - def on_edited_message(self=None, filters=None, group: int = 0) -> Callable: + def on_edited_message( + self: Union["OnEditedMessage", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling edited messages. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_inline_query.py b/pyrogram/methods/decorators/on_inline_query.py index 6373a72f5..dc88fb963 100644 --- a/pyrogram/methods/decorators/on_inline_query.py +++ b/pyrogram/methods/decorators/on_inline_query.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnInlineQuery: - def on_inline_query(self=None, filters=None, group: int = 0) -> Callable: + def on_inline_query( + self: Union["OnInlineQuery", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling inline queries. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_message.py b/pyrogram/methods/decorators/on_message.py index ea6a64be9..24a5914ac 100644 --- a/pyrogram/methods/decorators/on_message.py +++ b/pyrogram/methods/decorators/on_message.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnMessage: - def on_message(self=None, filters=None, group: int = 0) -> Callable: + def on_message( + self: Union["OnMessage", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling new messages. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_poll.py b/pyrogram/methods/decorators/on_poll.py index e1f8bf065..be8503f21 100644 --- a/pyrogram/methods/decorators/on_poll.py +++ b/pyrogram/methods/decorators/on_poll.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnPoll: - def on_poll(self=None, filters=None, group: int = 0) -> Callable: + def on_poll( + self: Union["OnPoll", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling poll updates. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_raw_update.py b/pyrogram/methods/decorators/on_raw_update.py index f6f2ef3df..e94b378e2 100644 --- a/pyrogram/methods/decorators/on_raw_update.py +++ b/pyrogram/methods/decorators/on_raw_update.py @@ -16,13 +16,16 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional import pyrogram class OnRawUpdate: - def on_raw_update(self=None, group: int = 0) -> Callable: + def on_raw_update( + self: Optional["OnRawUpdate"] = None, + group: int = 0, + ) -> Callable: """Decorator for handling raw updates. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_story.py b/pyrogram/methods/decorators/on_story.py index fb10b7f2a..81e58375b 100644 --- a/pyrogram/methods/decorators/on_story.py +++ b/pyrogram/methods/decorators/on_story.py @@ -18,14 +18,18 @@ # along with pyroblack. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnStory: - def on_story(self=None, filters=None, group: int = 0) -> Callable: + def on_story( + self: Union["OnStory", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling new stories. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the diff --git a/pyrogram/methods/decorators/on_user_status.py b/pyrogram/methods/decorators/on_user_status.py index 7f01be690..a44629130 100644 --- a/pyrogram/methods/decorators/on_user_status.py +++ b/pyrogram/methods/decorators/on_user_status.py @@ -16,14 +16,18 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Callable +from typing import Callable, Optional, Union import pyrogram from pyrogram.filters import Filter class OnUserStatus: - def on_user_status(self=None, filters=None, group: int = 0) -> Callable: + def on_user_status( + self: Union["OnUserStatus", Filter, None] = None, + filters: Optional[Filter] = None, + group: int = 0, + ) -> Callable: """Decorator for handling user status updates. This does the same thing as :meth:`~pyrogram.Client.add_handler` using the