From 99d24562dfecfa2d4800e54917b42b4c58317068 Mon Sep 17 00:00:00 2001 From: Aditya Yadav Date: Thu, 15 Dec 2022 23:12:16 +0530 Subject: [PATCH] resolve merge conflicts --- telegram/_bot.py | 2 +- telegram/_chat.py | 4 ++-- telegram/_files/inputmedia.py | 44 ++++++++++++++++++++--------------- telegram/_message.py | 4 ++-- telegram/_poll.py | 21 ++++++++++++++--- telegram/_user.py | 4 ++-- telegram/_videochat.py | 7 +++++- telegram/_webhookinfo.py | 11 ++++++++- 8 files changed, 66 insertions(+), 31 deletions(-) diff --git a/telegram/_bot.py b/telegram/_bot.py index 5b89301a025..7503ab63197 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -1805,7 +1805,7 @@ async def send_media_group( caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Sequence["MessageEntity"] = None, - ) -> List[Message]: + ) -> Tuple[Message, ...]: """Use this method to send a group of photos or videos as an album. Note: diff --git a/telegram/_chat.py b/telegram/_chat.py index a57c4cf1ba4..4f5f195f712 100644 --- a/telegram/_chat.py +++ b/telegram/_chat.py @@ -20,7 +20,7 @@ """This module contains an object that represents a Telegram Chat.""" from datetime import datetime from html import escape -from typing import TYPE_CHECKING, ClassVar, List, Optional, Sequence, Union +from typing import TYPE_CHECKING, ClassVar, List, Optional, Sequence, Tuple, Union from telegram import constants from telegram._chatlocation import ChatLocation @@ -1292,7 +1292,7 @@ async def send_media_group( caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Sequence["MessageEntity"] = None, - ) -> List["Message"]: + ) -> Tuple["Message", ...]: """Shortcut for:: await bot.send_media_group(update.effective_chat.id, *args, **kwargs) diff --git a/telegram/_files/inputmedia.py b/telegram/_files/inputmedia.py index 75cd519629d..f5031cdcb2c 100644 --- a/telegram/_files/inputmedia.py +++ b/telegram/_files/inputmedia.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. """Base class for Telegram InputMedia Objects.""" -from typing import List, Optional, Tuple, Union +from typing import Optional, Sequence, Union from telegram._files.animation import Animation from telegram._files.audio import Audio @@ -55,7 +55,8 @@ class InputMedia(TelegramObject): caption (:obj:`str`, optional): Caption of the media to be sent, 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. - caption_entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities| + caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): + |caption_entities| parse_mode (:obj:`str`, optional): |parse_mode| Attributes: @@ -63,7 +64,7 @@ class InputMedia(TelegramObject): media (:obj:`str` | :class:`telegram.InputFile`): Media to send. caption (:obj:`str`): Optional. Caption of the media to be sent. parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting. - caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special + caption_entities (Sequence[:class:`telegram.MessageEntity`]): Optional. List of special entities that appear in the caption. """ @@ -74,7 +75,7 @@ def __init__( media_type: str, media: Union[str, InputFile, MediaType], caption: str = None, - caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, + caption_entities: Sequence[MessageEntity] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, *, api_kwargs: JSONDict = None, @@ -124,7 +125,8 @@ class InputMediaAnimation(InputMedia): 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. parse_mode (:obj:`str`, optional): |parse_mode| - caption_entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities| + caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): + |caption_entities| width (:obj:`int`, optional): Animation width. height (:obj:`int`, optional): Animation height. duration (:obj:`int`, optional): Animation duration in seconds. @@ -134,7 +136,7 @@ class InputMediaAnimation(InputMedia): media (:obj:`str` | :class:`telegram.InputFile`): Animation to send. caption (:obj:`str`): Optional. Caption of the document to be sent. parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting. - caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special + caption_entities (Sequence[:class:`telegram.MessageEntity`]): Optional. List of special entities that appear in the caption. thumb (:class:`telegram.InputFile`): Optional. Thumbnail of the file to send. width (:obj:`int`): Optional. Animation width. @@ -154,7 +156,7 @@ def __init__( width: int = None, height: int = None, duration: int = None, - caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, + caption_entities: Sequence[MessageEntity] = None, filename: str = None, *, api_kwargs: JSONDict = None, @@ -202,14 +204,15 @@ class InputMediaPhoto(InputMedia): 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. parse_mode (:obj:`str`, optional): |parse_mode| - caption_entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities| + caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): + |caption_entities| Attributes: type (:obj:`str`): :tg-const:`telegram.constants.InputMediaType.PHOTO`. media (:obj:`str` | :class:`telegram.InputFile`): Photo to send. caption (:obj:`str`): Optional. Caption of the document to be sent. parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting. - caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special + caption_entities (Sequence[:class:`telegram.MessageEntity`]): Optional. List of special entities that appear in the caption. """ @@ -221,7 +224,7 @@ def __init__( media: Union[FileInput, PhotoSize], caption: str = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, + caption_entities: Sequence[MessageEntity] = None, filename: str = None, *, api_kwargs: JSONDict = None, @@ -266,7 +269,8 @@ class InputMediaVideo(InputMedia): 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. parse_mode (:obj:`str`, optional): |parse_mode| - caption_entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities| + caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): + |caption_entities| width (:obj:`int`, optional): Video width. height (:obj:`int`, optional): Video height. duration (:obj:`int`, optional): Video duration in seconds. @@ -283,7 +287,7 @@ class InputMediaVideo(InputMedia): media (:obj:`str` | :class:`telegram.InputFile`): Video file to send. caption (:obj:`str`): Optional. Caption of the document to be sent. parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting. - caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special + caption_entities (Sequence[:class:`telegram.MessageEntity`]): Optional. List of special entities that appear in the caption. width (:obj:`int`): Optional. Video width. height (:obj:`int`): Optional. Video height. @@ -306,7 +310,7 @@ def __init__( supports_streaming: bool = None, parse_mode: ODVInput[str] = DEFAULT_NONE, thumb: FileInput = None, - caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, + caption_entities: Sequence[MessageEntity] = None, filename: str = None, *, api_kwargs: JSONDict = None, @@ -361,7 +365,8 @@ class InputMediaAudio(InputMedia): 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. parse_mode (:obj:`str`, optional): |parse_mode| - caption_entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities| + caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): + |caption_entities| duration (:obj:`int`): Duration of the audio in seconds as defined by sender. performer (:obj:`str`, optional): Performer of the audio as defined by sender or by audio tags. @@ -377,7 +382,7 @@ class InputMediaAudio(InputMedia): media (:obj:`str` | :class:`telegram.InputFile`): Audio file to send. caption (:obj:`str`): Optional. Caption of the document to be sent. parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting. - caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special + caption_entities (Sequence[:class:`telegram.MessageEntity`]): Optional. List of special entities that appear in the caption. duration (:obj:`int`): Duration of the audio in seconds. performer (:obj:`str`): Optional. Performer of the audio as defined by sender or by audio @@ -398,7 +403,7 @@ def __init__( duration: int = None, performer: str = None, title: str = None, - caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, + caption_entities: Sequence[MessageEntity] = None, filename: str = None, *, api_kwargs: JSONDict = None, @@ -446,7 +451,8 @@ class InputMediaDocument(InputMedia): 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. parse_mode (:obj:`str`, optional): |parse_mode| - caption_entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities| + caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): + |caption_entities| thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ optional): |thumbdocstringnopath| @@ -461,7 +467,7 @@ class InputMediaDocument(InputMedia): media (:obj:`str` | :class:`telegram.InputFile`): File to send. caption (:obj:`str`): Optional. Caption of the document to be sent. parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting. - caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special + caption_entities (Sequence[:class:`telegram.MessageEntity`]): Optional. List of special entities that appear in the caption. thumb (:class:`telegram.InputFile`): Optional. Thumbnail of the file to send. disable_content_type_detection (:obj:`bool`): Optional. Disables automatic server-side @@ -479,7 +485,7 @@ def __init__( caption: str = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_content_type_detection: bool = None, - caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None, + caption_entities: Sequence[MessageEntity] = None, filename: str = None, *, api_kwargs: JSONDict = None, diff --git a/telegram/_message.py b/telegram/_message.py index 13d6eee9adb..13340026383 100644 --- a/telegram/_message.py +++ b/telegram/_message.py @@ -21,7 +21,7 @@ import datetime import sys from html import escape -from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Union +from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple, Union from telegram._chat import Chat from telegram._dice import Dice @@ -1095,7 +1095,7 @@ async def reply_media_group( caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Sequence["MessageEntity"] = None, - ) -> List["Message"]: + ) -> Tuple["Message", ...]: """Shortcut for:: await bot.send_media_group(update.effective_message.chat_id, *args, **kwargs) diff --git a/telegram/_poll.py b/telegram/_poll.py index 675d9288f7d..c5fe3d797bc 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -89,11 +89,16 @@ class PollAnswer(TelegramObject): option_ids (Sequence[:obj:`int`]): 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote. + .. versionchanged:: 20.0 + |sequenceclassargs| + Attributes: poll_id (:obj:`str`): Unique poll identifier. user (:class:`telegram.User`): The user, who changed the answer to the poll. option_ids (Sequence[:obj:`int`]): Identifiers of answer options, chosen by the user. + .. versionchanged:: 20.0 + |tupleclassattrs| """ __slots__ = ("option_ids", "user", "poll_id") @@ -136,6 +141,10 @@ class Poll(TelegramObject): question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`- :tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters. options (Sequence[:class:`PollOption`]): List of poll options. + + .. versionchanged:: 20.0 + |sequenceclassargs| + is_closed (:obj:`bool`): :obj:`True`, if the poll is closed. is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. @@ -162,7 +171,10 @@ class Poll(TelegramObject): id (:obj:`str`): Unique poll identifier. question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`- :tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters. - options (Sequence[:class:`PollOption`]): List of poll options. + options (Tuple[:class:`PollOption`]): List of poll options. + + .. versionchanged:: 20.0 + |tupleclassattrs| total_voter_count (:obj:`int`): Total number of users that voted in the poll. is_closed (:obj:`bool`): :obj:`True`, if the poll is closed. is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. @@ -174,12 +186,15 @@ class Poll(TelegramObject): explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters. - explanation_entities (Sequence[:class:`telegram.MessageEntity`]): Special entities + explanation_entities (Tuple[:class:`telegram.MessageEntity`]): Special entities like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`. This list is empty if the message does not contain explanation entities. .. versionchanged:: 20.0 - This attribute is now always a (possibly empty) list and never :obj:`None`. + |tupleclassattrs| + + .. versionchanged:: 20.0 + This attribute is now always a (possibly empty) tuple and never :obj:`None`. open_period (:obj:`int`): Optional. Amount of time in seconds the poll will be active after creation. close_date (:obj:`datetime.datetime`): Optional. Point in time when the poll will be diff --git a/telegram/_user.py b/telegram/_user.py index e99242ec8a5..2e0d2ac9b83 100644 --- a/telegram/_user.py +++ b/telegram/_user.py @@ -19,7 +19,7 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains an object that represents a Telegram User.""" from datetime import datetime -from typing import TYPE_CHECKING, List, Optional, Sequence, Union +from typing import TYPE_CHECKING, List, Optional, Sequence, Tuple, Union from telegram._inline.inlinekeyboardbutton import InlineKeyboardButton from telegram._menubutton import MenuButton @@ -482,7 +482,7 @@ async def send_media_group( caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Sequence["MessageEntity"] = None, - ) -> List["Message"]: + ) -> Tuple["Message", ...]: """Shortcut for:: await bot.send_media_group(update.effective_user.id, *args, **kwargs) diff --git a/telegram/_videochat.py b/telegram/_videochat.py index 9a7a5fa7485..80c8cb092a8 100644 --- a/telegram/_videochat.py +++ b/telegram/_videochat.py @@ -91,9 +91,14 @@ class VideoChatParticipantsInvited(TelegramObject): Args: users (Sequence[:class:`telegram.User`]): New members that were invited to the video chat. + .. versionchanged:: 20.0 + |sequenceclassargs| + Attributes: - users (Sequence[:class:`telegram.User`]): New members that were invited to the video chat. + users (Tuple[:class:`telegram.User`]): New members that were invited to the video chat. + .. versionchanged:: 20.0 + |tupleclassattrs| """ __slots__ = ("users",) diff --git a/telegram/_webhookinfo.py b/telegram/_webhookinfo.py index 601c56fc33c..011b61dc6ba 100644 --- a/telegram/_webhookinfo.py +++ b/telegram/_webhookinfo.py @@ -58,6 +58,10 @@ class WebhookInfo(TelegramObject): allowed_updates (Sequence[:obj:`str`], optional): A list of update types the bot is subscribed to. Defaults to all update types, except :attr:`telegram.Update.chat_member`. + + .. versionchanged:: 20.0 + |sequenceclassargs| + last_synchronization_error_date (:obj:`int`, optional): Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters. @@ -74,9 +78,14 @@ class WebhookInfo(TelegramObject): most recent error that happened when trying to deliver an update via webhook. max_connections (:obj:`int`): Optional. Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery. - allowed_updates (Sequence[:obj:`str`]): Optional. A list of update types the bot is + allowed_updates (Tuple[:obj:`str`]): Optional. A list of update types the bot is subscribed to. Defaults to all update types, except :attr:`telegram.Update.chat_member`. + + .. versionchanged:: 20.0 + + * |tupleclassattrs| + * |alwaystuple| last_synchronization_error_date (:obj:`int`): Optional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters.