From bb80e176bf9ac1e9ff5f4e24fd8b2179dc6a4995 Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Fri, 24 Nov 2023 01:32:14 +0300 Subject: [PATCH] Fix async generator typehints --- pyrogram/client.py | 2 +- pyrogram/methods/chats/get_chat_event_log.py | 2 +- pyrogram/methods/chats/get_chat_members.py | 2 +- pyrogram/methods/chats/get_dialogs.py | 2 +- pyrogram/methods/chats/get_folders.py | 2 +- pyrogram/methods/chats/get_forum_topics.py | 2 +- pyrogram/methods/invite_links/get_chat_admin_invite_links.py | 2 +- pyrogram/methods/invite_links/get_chat_invite_link_joiners.py | 2 +- pyrogram/methods/invite_links/get_chat_join_requests.py | 2 +- pyrogram/methods/messages/get_chat_history.py | 2 +- pyrogram/methods/messages/get_discussion_replies.py | 2 +- pyrogram/methods/messages/search_global.py | 4 ++-- pyrogram/methods/messages/search_messages.py | 2 +- pyrogram/methods/stories/get_all_stories.py | 2 +- pyrogram/methods/stories/get_peer_stories.py | 2 +- pyrogram/methods/stories/get_pinned_stories.py | 2 +- pyrogram/methods/stories/get_stories_archive.py | 2 +- pyrogram/methods/users/get_chat_photos.py | 2 +- pyrogram/types/user_and_chats/chat.py | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pyrogram/client.py b/pyrogram/client.py index 7cec1059..323fc705 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -821,7 +821,7 @@ class Client(Methods): offset: int = 0, progress: Callable = None, progress_args: tuple = () - ) -> Optional[AsyncGenerator[bytes, None]]: + ) -> AsyncGenerator[bytes, None]: async with self.get_file_semaphore: file_type = file_id.file_type diff --git a/pyrogram/methods/chats/get_chat_event_log.py b/pyrogram/methods/chats/get_chat_event_log.py index 06fa01c8..a71c7566 100644 --- a/pyrogram/methods/chats/get_chat_event_log.py +++ b/pyrogram/methods/chats/get_chat_event_log.py @@ -32,7 +32,7 @@ class GetChatEventLog: limit: int = 0, filters: "types.ChatEventFilter" = None, user_ids: List[Union[int, str]] = None - ) -> Optional[AsyncGenerator["types.ChatEvent", None]]: + ) -> AsyncGenerator["types.ChatEvent", None]: """Get the actions taken by chat members and administrators in the last 48h. Only available for supergroups and channels. Requires administrator rights. diff --git a/pyrogram/methods/chats/get_chat_members.py b/pyrogram/methods/chats/get_chat_members.py index 49fb0a09..e51fa8c4 100644 --- a/pyrogram/methods/chats/get_chat_members.py +++ b/pyrogram/methods/chats/get_chat_members.py @@ -64,7 +64,7 @@ class GetChatMembers: query: str = "", limit: int = 0, filter: "enums.ChatMembersFilter" = enums.ChatMembersFilter.SEARCH - ) -> Optional[AsyncGenerator["types.ChatMember", None]]: + ) -> AsyncGenerator["types.ChatMember", None]: """Get the members list of a chat. A chat can be either a basic group, a supergroup or a channel. diff --git a/pyrogram/methods/chats/get_dialogs.py b/pyrogram/methods/chats/get_dialogs.py index 3509ccbc..2ebf090a 100644 --- a/pyrogram/methods/chats/get_dialogs.py +++ b/pyrogram/methods/chats/get_dialogs.py @@ -26,7 +26,7 @@ class GetDialogs: async def get_dialogs( self: "pyrogram.Client", limit: int = 0 - ) -> Optional[AsyncGenerator["types.Dialog", None]]: + ) -> AsyncGenerator["types.Dialog", None]: """Get a user's dialogs sequentially. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/chats/get_folders.py b/pyrogram/methods/chats/get_folders.py index e7a333ac..acd3628f 100644 --- a/pyrogram/methods/chats/get_folders.py +++ b/pyrogram/methods/chats/get_folders.py @@ -25,7 +25,7 @@ from pyrogram import types, raw class GetFolders: async def get_folders( self: "pyrogram.Client", - ) -> Optional[AsyncGenerator["types.Folder", None]]: + ) -> AsyncGenerator["types.Folder", None]: """Get a user's folders with chats sequentially. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/chats/get_forum_topics.py b/pyrogram/methods/chats/get_forum_topics.py index 3323380a..3bd38c03 100644 --- a/pyrogram/methods/chats/get_forum_topics.py +++ b/pyrogram/methods/chats/get_forum_topics.py @@ -28,7 +28,7 @@ class GetForumTopics: self: "pyrogram.Client", chat_id: Union[int, str], limit: int = 0 - ) -> Optional[AsyncGenerator["types.ForumTopic", None]]: + ) -> AsyncGenerator["types.ForumTopic", None]: """Get one or more topic from a chat. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/invite_links/get_chat_admin_invite_links.py b/pyrogram/methods/invite_links/get_chat_admin_invite_links.py index 62acca10..57de755e 100644 --- a/pyrogram/methods/invite_links/get_chat_admin_invite_links.py +++ b/pyrogram/methods/invite_links/get_chat_admin_invite_links.py @@ -30,7 +30,7 @@ class GetChatAdminInviteLinks: admin_id: Union[int, str], revoked: bool = False, limit: int = 0, - ) -> Optional[AsyncGenerator["types.ChatInviteLink", None]]: + ) -> AsyncGenerator["types.ChatInviteLink", None]: """Get the invite links created by an administrator in a chat. .. note:: diff --git a/pyrogram/methods/invite_links/get_chat_invite_link_joiners.py b/pyrogram/methods/invite_links/get_chat_invite_link_joiners.py index c1fc43a7..46c10597 100644 --- a/pyrogram/methods/invite_links/get_chat_invite_link_joiners.py +++ b/pyrogram/methods/invite_links/get_chat_invite_link_joiners.py @@ -29,7 +29,7 @@ class GetChatInviteLinkJoiners: chat_id: Union[int, str], invite_link: str, limit: int = 0 - ) -> Optional[AsyncGenerator["types.ChatJoiner", None]]: + ) -> AsyncGenerator["types.ChatJoiner", None]: """Get the members who joined the chat with the invite link. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/invite_links/get_chat_join_requests.py b/pyrogram/methods/invite_links/get_chat_join_requests.py index a75498e2..e0652e37 100644 --- a/pyrogram/methods/invite_links/get_chat_join_requests.py +++ b/pyrogram/methods/invite_links/get_chat_join_requests.py @@ -29,7 +29,7 @@ class GetChatJoinRequests: chat_id: Union[int, str], limit: int = 0, query: str = "" - ) -> Optional[AsyncGenerator["types.ChatJoiner", None]]: + ) -> AsyncGenerator["types.ChatJoiner", None]: """Get the pending join requests of a chat. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/messages/get_chat_history.py b/pyrogram/methods/messages/get_chat_history.py index b384c6ba..898b57cd 100644 --- a/pyrogram/methods/messages/get_chat_history.py +++ b/pyrogram/methods/messages/get_chat_history.py @@ -57,7 +57,7 @@ class GetChatHistory: offset: int = 0, offset_id: int = 0, offset_date: datetime = utils.zero_datetime() - ) -> Optional[AsyncGenerator["types.Message", None]]: + ) -> AsyncGenerator["types.Message", None]: """Get messages from a chat history. The messages are returned in reverse chronological order. diff --git a/pyrogram/methods/messages/get_discussion_replies.py b/pyrogram/methods/messages/get_discussion_replies.py index dd23751b..6454e869 100644 --- a/pyrogram/methods/messages/get_discussion_replies.py +++ b/pyrogram/methods/messages/get_discussion_replies.py @@ -28,7 +28,7 @@ class GetDiscussionReplies: chat_id: Union[int, str], message_id: int, limit: int = 0, - ) -> Optional[AsyncGenerator["types.Message", None]]: + ) -> AsyncGenerator["types.Message", None]: """Get the message replies of a discussion thread. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/messages/search_global.py b/pyrogram/methods/messages/search_global.py index f566c981..29738942 100644 --- a/pyrogram/methods/messages/search_global.py +++ b/pyrogram/methods/messages/search_global.py @@ -30,7 +30,7 @@ class SearchGlobal: query: str = "", filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY, limit: int = 0, - ) -> Optional[AsyncGenerator["types.Message", None]]: + ) -> AsyncGenerator["types.Message", None]: """Search messages globally from all of your chats. If you want to get the messages count only, see :meth:`~pyrogram.Client.search_global_count`. @@ -46,7 +46,7 @@ class SearchGlobal: query (``str``, *optional*): Text query string. Use "@" to search for mentions. - + filter (:obj:`~pyrogram.enums.MessagesFilter`, *optional*): Pass a filter in order to search for specific kind of messages only. Defaults to any message (no filter). diff --git a/pyrogram/methods/messages/search_messages.py b/pyrogram/methods/messages/search_messages.py index 4497ff1c..4bd5f13b 100644 --- a/pyrogram/methods/messages/search_messages.py +++ b/pyrogram/methods/messages/search_messages.py @@ -67,7 +67,7 @@ class SearchMessages: filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY, limit: int = 0, from_user: Union[int, str] = None - ) -> Optional[AsyncGenerator["types.Message", None]]: + ) -> AsyncGenerator["types.Message", None]: """Search for text and media messages inside a specific chat. If you want to get the messages count only, see :meth:`~pyrogram.Client.search_messages_count`. diff --git a/pyrogram/methods/stories/get_all_stories.py b/pyrogram/methods/stories/get_all_stories.py index b0585c0b..45e7636c 100644 --- a/pyrogram/methods/stories/get_all_stories.py +++ b/pyrogram/methods/stories/get_all_stories.py @@ -29,7 +29,7 @@ class GetAllStories: next: Optional[bool] = None, hidden: Optional[bool] = None, state: Optional[str] = None, - ) -> Optional[AsyncGenerator["types.Story", None]]: + ) -> AsyncGenerator["types.Story", None]: """Get all active stories. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/stories/get_peer_stories.py b/pyrogram/methods/stories/get_peer_stories.py index 37fd42ca..98d539af 100644 --- a/pyrogram/methods/stories/get_peer_stories.py +++ b/pyrogram/methods/stories/get_peer_stories.py @@ -27,7 +27,7 @@ class GetPeerStories: async def get_peer_stories( self: "pyrogram.Client", chat_id: Union[int, str] - ) -> Optional[AsyncGenerator["types.Story", None]]: + ) -> AsyncGenerator["types.Story", None]: """Get all active stories from an user by using user identifiers. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/stories/get_pinned_stories.py b/pyrogram/methods/stories/get_pinned_stories.py index 9d2fdfee..e05a4a74 100644 --- a/pyrogram/methods/stories/get_pinned_stories.py +++ b/pyrogram/methods/stories/get_pinned_stories.py @@ -30,7 +30,7 @@ class GetPinnedStories: chat_id: Union[int, str], offset_id: int = 0, limit: int = 0, - ) -> Optional[AsyncGenerator["types.Story", None]]: + ) -> AsyncGenerator["types.Story", None]: """Get pinned stories stories. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/stories/get_stories_archive.py b/pyrogram/methods/stories/get_stories_archive.py index 7612af50..6a84fe55 100644 --- a/pyrogram/methods/stories/get_stories_archive.py +++ b/pyrogram/methods/stories/get_stories_archive.py @@ -29,7 +29,7 @@ class GetStoriesArchive: chat_id: Union[int, str], limit: int = 0, offset_id: int = 0 - ) -> Optional[AsyncGenerator["types.Story", None]]: + ) -> AsyncGenerator["types.Story", None]: """Get stories archive. .. include:: /_includes/usable-by/users.rst diff --git a/pyrogram/methods/users/get_chat_photos.py b/pyrogram/methods/users/get_chat_photos.py index d22c68dc..05dfd92d 100644 --- a/pyrogram/methods/users/get_chat_photos.py +++ b/pyrogram/methods/users/get_chat_photos.py @@ -27,7 +27,7 @@ class GetChatPhotos: self: "pyrogram.Client", chat_id: Union[int, str], limit: int = 0, - ) -> Optional[AsyncGenerator["types.Photo", None]]: + ) -> AsyncGenerator["types.Photo", None]: """Get a chat or a user profile photos sequentially. .. include:: /_includes/usable-by/users-bots.rst diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 4d58bf8b..14accfb1 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -895,7 +895,7 @@ class Chat(Object): query: str = "", limit: int = 0, filter: "enums.ChatMembersFilter" = enums.ChatMembersFilter.SEARCH - ) -> Optional[AsyncGenerator["types.ChatMember", None]]: + ) -> AsyncGenerator["types.ChatMember", None]: """Bound method *get_members* of :obj:`~pyrogram.types.Chat`. Use as a shortcut for: