diff --git a/docs/source/inclusions/bot_methods.rst b/docs/source/inclusions/bot_methods.rst index dfe053fa1..a5428f2f0 100644 --- a/docs/source/inclusions/bot_methods.rst +++ b/docs/source/inclusions/bot_methods.rst @@ -237,7 +237,7 @@ - Used for setting the keywords of a sticker * - :meth:`~telegram.Bot.set_sticker_mask_position` - Used for setting the mask position of a mask sticker - * - :meth:`~telegram.Bot.set_sticker_set_thumb` + * - :meth:`~telegram.Bot.set_sticker_set_thumbnail` - Used for setting the thumbnail of a sticker set * - :meth:`~telegram.Bot.set_custom_emoji_sticker_set_thumbnail` - Used for setting the thumbnail of a custom emoji sticker set diff --git a/docs/substitutions/global.rst b/docs/substitutions/global.rst index 6549b469a..151e347af 100644 --- a/docs/substitutions/global.rst +++ b/docs/substitutions/global.rst @@ -14,10 +14,6 @@ .. |thumbdocstringnopath| replace:: |thumbdocstringbase| |uploadinputnopath| -.. |thumbargumentdeprecation| replace:: As of Bot API 6.6 this argument is deprecated in favor of - -.. |thumbattributedeprecation| replace:: As of Bot API 6.6 this attribute is deprecated in favor of - .. |editreplymarkup| replace:: It is currently only possible to edit messages without :attr:`telegram.Message.reply_markup` or with inline keyboards. .. |toapikwargsbase| replace:: These arguments are also considered by :meth:`~telegram.TelegramObject.to_dict` and :meth:`~telegram.TelegramObject.to_json`, i.e. when passing objects to Telegram. Passing them to Telegram is however not guaranteed to work for all kinds of objects, e.g. this will fail for objects that can not directly be JSON serialized. @@ -59,3 +55,9 @@ .. |datetime_localization| replace:: The default timezone of the bot is used for localization, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. .. |post_methods_note| replace:: If you implement custom logic that implies that you will **not** be using :class:`~telegram.ext.Application`'s methods :meth:`~telegram.ext.Application.run_polling` or :meth:`~telegram.ext.Application.run_webhook` to run your application (like it's done in `Custom Webhook Bot Example `__), the callback you set in this method **will not be called automatically**. So instead of setting a callback with this method, you have to explicitly ``await`` the function that you want to run at this stage of your application's life (in the `example mentioned above `__, that would be in ``async with application`` context manager). + +.. |removed_thumb_note| replace:: Removed the deprecated argument and attribute ``thumb``. + +.. |removed_thumb_url_note| replace:: Removed the deprecated argument and attribute ``thumb_url``. + +.. |removed_thumb_wildcard_note| replace:: Removed the deprecated arguments and attributes ``thumb_*``. diff --git a/telegram/_bot.py b/telegram/_bot.py index 2e835f50c..5fdce2f74 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -105,14 +105,13 @@ from telegram._utils.types import ( ReplyMarkup, ) from telegram._utils.warnings import warn -from telegram._utils.warnings_transition import warn_about_thumb_return_thumbnail from telegram._webhookinfo import WebhookInfo from telegram.constants import InlineQueryLimit from telegram.error import InvalidToken from telegram.request import BaseRequest, RequestData from telegram.request._httpxrequest import HTTPXRequest from telegram.request._requestparameter import RequestParameter -from telegram.warnings import PTBDeprecationWarning, PTBUserWarning +from telegram.warnings import PTBUserWarning if TYPE_CHECKING: from telegram import ( @@ -188,6 +187,10 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): the file path will be passed in the `file URI scheme `_. + .. versionchanged:: NEXT.VERSION + Removed deprecated methods ``set_sticker_set_thumb`` and ``setStickerSetThumb``. + Use :meth:`set_sticker_set_thumbnail` and :meth:`setStickerSetThumbnail` instead. + Args: token (:obj:`str`): Bot's unique authentication token. base_url (:obj:`str`, optional): Telegram Bot API service URL. @@ -213,6 +216,9 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): .. include:: inclusions/bot_methods.rst + .. |removed_thumb_arg| replace:: Removed deprecated argument ``thumb``. Use + ``thumbnail`` instead. + """ # This is a class variable since we want to override the logger name in ExtBot @@ -1078,7 +1084,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -1104,6 +1109,9 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_arg| + Args: chat_id (:obj:`int` | :obj:`str`): |chat_id_channel| audio (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ @@ -1143,18 +1151,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstring| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ optional): |thumbdocstring| @@ -1174,21 +1170,13 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`telegram.error.TelegramError` """ - thumbnail_or_thumb: FileInput = warn_about_thumb_return_thumbnail( - deprecated_arg=thumb, - new_arg=thumbnail, - warn_callback=self._warn, - stacklevel=3, - ) data: JSONDict = { "chat_id": chat_id, "audio": self._parse_file_input(audio, Audio, filename=filename), "duration": duration, "performer": performer, "title": title, - "thumbnail": self._parse_file_input(thumbnail_or_thumb, attach=True) - if thumbnail_or_thumb - else None, + "thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None, } return await self._send_message( @@ -1220,7 +1208,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, disable_content_type_detection: Optional[bool] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, @@ -1244,6 +1231,9 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_arg| + Args: chat_id (:obj:`int` | :obj:`str`): |chat_id_channel| document (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ @@ -1285,18 +1275,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstring| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ optional): |thumbdocstring| @@ -1314,20 +1292,11 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`telegram.error.TelegramError` """ - thumbnail_or_thumb: FileInput = warn_about_thumb_return_thumbnail( - deprecated_arg=thumb, - new_arg=thumbnail, - warn_callback=self._warn, - stacklevel=3, - ) - data: JSONDict = { "chat_id": chat_id, "document": self._parse_file_input(document, Document, filename=filename), "disable_content_type_detection": disable_content_type_detection, - "thumbnail": self._parse_file_input(thumbnail_or_thumb, attach=True) - if thumbnail_or_thumb - else None, + "thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None, } return await self._send_message( @@ -1449,7 +1418,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): height: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, supports_streaming: Optional[bool] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -1472,12 +1440,15 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): changed in the future. Note: - :paramref:`thumb` will be ignored for small video files, for which Telegram can + :paramref:`thumbnail` will be ignored for small video files, for which Telegram can easily generate thumbnails. However, this behaviour is undocumented and might be changed by Telegram. .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_arg| + Args: chat_id (:obj:`int` | :obj:`str`): |chat_id_channel| video (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ @@ -1519,18 +1490,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstring| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. has_spoiler (:obj:`bool`, optional): Pass :obj:`True` if the video needs to be covered with a spoiler animation. @@ -1554,12 +1513,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`telegram.error.TelegramError` """ - thumbnail_or_thumb: FileInput = warn_about_thumb_return_thumbnail( - deprecated_arg=thumb, - new_arg=thumbnail, - warn_callback=self._warn, - stacklevel=3, - ) data: JSONDict = { "chat_id": chat_id, "video": self._parse_file_input(video, Video, filename=filename), @@ -1567,9 +1520,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): "width": width, "height": height, "supports_streaming": supports_streaming, - "thumbnail": self._parse_file_input(thumbnail_or_thumb, attach=True) - if thumbnail_or_thumb - else None, + "thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None, "has_spoiler": has_spoiler, } @@ -1602,7 +1553,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, message_thread_id: Optional[int] = None, @@ -1620,12 +1570,15 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): Use this method to send video messages. Note: - :paramref:`thumb` will be ignored for small video files, for which Telegram can + :paramref:`thumbnail` will be ignored for small video files, for which Telegram can easily generate thumbnails. However, this behaviour is undocumented and might be changed by Telegram. .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_arg| + Args: chat_id (:obj:`int` | :obj:`str`): |chat_id_channel| video_note (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ @@ -1659,18 +1612,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstring| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ optional): |thumbdocstring| @@ -1690,20 +1631,12 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`telegram.error.TelegramError` """ - thumbnail_or_thumb: FileInput = warn_about_thumb_return_thumbnail( - deprecated_arg=thumb, - new_arg=thumbnail, - warn_callback=self._warn, - stacklevel=3, - ) data: JSONDict = { "chat_id": chat_id, "video_note": self._parse_file_input(video_note, VideoNote, filename=filename), "duration": duration, "length": length, - "thumbnail": self._parse_file_input(thumbnail_or_thumb, attach=True) - if thumbnail_or_thumb - else None, + "thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None, } return await self._send_message( @@ -1730,7 +1663,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_notification: DVInput[bool] = DEFAULT_NONE, @@ -1757,12 +1689,15 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): changed in the future. Note: - :paramref:`thumb` will be ignored for small files, for which Telegram can easily + :paramref:`thumbnail` will be ignored for small files, for which Telegram can easily generate thumbnails. However, this behaviour is undocumented and might be changed by Telegram. .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_arg| + Args: chat_id (:obj:`int` | :obj:`str`): |chat_id_channel| animation (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ @@ -1775,18 +1710,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): duration (:obj:`int`, optional): Duration of sent animation in seconds. width (:obj:`int`, optional): Animation width. height (:obj:`int`, optional): Animation height. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstring| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. caption (:obj:`str`, optional): Animation caption (may also be used when resending animations by file_id), 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after @@ -1834,21 +1757,13 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`telegram.error.TelegramError` """ - thumbnail_or_thumb: FileInput = warn_about_thumb_return_thumbnail( - deprecated_arg=thumb, - new_arg=thumbnail, - warn_callback=self._warn, - stacklevel=3, - ) data: JSONDict = { "chat_id": chat_id, "animation": self._parse_file_input(animation, Animation, filename=filename), "duration": duration, "width": width, "height": height, - "thumbnail": self._parse_file_input(thumbnail_or_thumb, attach=True) - if thumbnail_or_thumb - else None, + "thumbnail": self._parse_file_input(thumbnail, attach=True) if thumbnail else None, "has_spoiler": has_spoiler, } @@ -2820,15 +2735,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): cache_time: Optional[int] = None, is_personal: Optional[bool] = None, next_offset: Optional[str] = None, - # Deprecated params since bot api 6.7 - # <---- - switch_pm_text: Optional[str] = None, - switch_pm_parameter: Optional[str] = None, - # ---> - # New params since bot api 6.7 - # <---- button: Optional[InlineQueryResultsButton] = None, - # ---> *, current_offset: Optional[str] = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2849,8 +2756,9 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): .. seealso:: :wiki:`Working with Files and Media ` - .. |api6_7_depr| replace:: Since Bot API 6.7, this argument is deprecated in favour of - :paramref:`button`. + + .. versionchanged:: NEXT.VERSION + Removed deprecated arguments ``switch_pm_text`` and ``switch_pm_parameter``. Args: inline_query_id (:obj:`str`): Unique identifier for the answered query. @@ -2869,20 +2777,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed :tg-const:`telegram.InlineQuery.MAX_OFFSET_LENGTH` bytes. - switch_pm_text (:obj:`str`, optional): If passed, clients will display a button with - specified text that switches the user to a private chat with the bot and sends the - bot a start message with the parameter :paramref:`switch_pm_parameter`. - - .. deprecated:: 20.3 - |api6_7_depr| - switch_pm_parameter (:obj:`str`, optional): Deep-linking parameter for the - :guilabel:`/start` message sent to the bot when user presses the switch button. - :tg-const:`telegram.InlineQuery.MIN_SWITCH_PM_TEXT_LENGTH`- - :tg-const:`telegram.InlineQuery.MAX_SWITCH_PM_TEXT_LENGTH` characters, - only ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed. - - .. deprecated:: 20.3 - |api6_7_depr| button (:class:`telegram.InlineQueryResultsButton`, optional): A button to be shown above the inline query results. @@ -2901,26 +2795,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): :class:`telegram.error.TelegramError` """ - if (switch_pm_text or switch_pm_parameter) and button: - raise TypeError( - "Since Bot API 6.7, the parameter `button is mutually exclusive to the deprecated " - "parameters `switch_pm_text` and `switch_pm_parameter`. Please use the new " - "parameter `button`." - ) - - if switch_pm_text and switch_pm_parameter: - self._warn( - "Since Bot API 6.7, the parameters `switch_pm_text` and `switch_pm_parameter` are " - "deprecated in favour of the new parameter `button`. Please use the new parameter " - "`button` instead.", - category=PTBDeprecationWarning, - stacklevel=3, - ) - button = InlineQueryResultsButton( - text=switch_pm_text, - start_parameter=switch_pm_parameter, - ) - effective_results, next_offset = self._effective_inline_results( results=results, next_offset=next_offset, current_offset=current_offset ) @@ -5605,14 +5479,8 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. async def upload_sticker_file( self, user_id: Union[str, int], - png_sticker: Optional[ - FileInput - ] = None, # Deprecated since bot api 6.6. Optional for compatiblity. - # New parameters since bot api 6.6: - # <--- - sticker: Optional[FileInput] = None, # Actually required, but optional for compatibility. - sticker_format: Optional[str] = None, # Actually required, but optional for compatibility. - # ---> + sticker: Optional[FileInput], + sticker_format: Optional[str], *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -5625,6 +5493,9 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. :meth:`create_new_sticker_set` and :meth:`add_sticker_to_set` methods (can be used multiple times). + .. versionchanged:: NEXT.VERSION + Removed deprecated parameter ``png_sticker``. + Args: user_id (:obj:`int`): User identifier of sticker file owner. sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`): @@ -5641,65 +5512,17 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. .. versionadded:: 20.2 - png_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \ - optional): - **PNG** image with the sticker, must be up to 512 kilobytes in size, - dimensions must not exceed 512px, and either width or height must be exactly 512px. - |uploadinput| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - Since Bot API 6.6, this parameter has been deprecated in favor of - :paramref:`sticker` and :paramref:`sticker_format`. - Returns: :class:`telegram.File`: On success, the uploaded File is returned. Raises: - :exc:`TypeError`: Raised when: 1) ``sticker`` and ``sticker_format`` are passed - together with ``png_sticker``. 2) If neither the new parameters nor - the deprecated parameters are passed. - - :class:`telegram.error.TelegramError`: For other errors. + :class:`telegram.error.TelegramError` """ - if not png_sticker and not all((sticker, sticker_format)): - raise TypeError( - "Since Bot API 6.6, the parameters `sticker` and `sticker_format` " - "are required, please pass them as well." - ) - - if png_sticker and any((sticker, sticker_format)): - raise TypeError( - "Since Bot API 6.6, the parameters `sticker` and `sticker_format` " - "are mutually exclusive with the deprecated parameter " - "`png_sticker`. Please use the new parameters " - "`sticker` and `sticker_format` instead." - ) - # If we had allowed this, the created sticker set would have used the newer parameters - # only, which would have been confusing. - - if png_sticker: - self._warn( - "Since Bot API 6.6, the parameter `png_sticker` for " - "`upload_sticker_file` is deprecated. Please use the new parameters " - "`sticker` and `sticker_format` instead.", - stacklevel=3, - category=PTBDeprecationWarning, - ) - data: JSONDict = { "user_id": user_id, "sticker": self._parse_file_input(sticker), # type: ignore[arg-type] "sticker_format": sticker_format, - # Deprecated param since bot api 6.6 - "png_sticker": self._parse_file_input(png_sticker), # type: ignore[arg-type] } result = await self._post( "uploadStickerFile", @@ -5712,233 +5535,12 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. ) return File.de_json(result, self) # type: ignore[return-value] - @_log - async def create_new_sticker_set( - self, - user_id: Union[str, int], - name: str, - title: str, - # Deprecated params since bot api 6.6 - # <---- - emojis: Optional[str] = None, # Was made optional for compatibility purposes - png_sticker: Optional[FileInput] = None, - mask_position: Optional[MaskPosition] = None, - tgs_sticker: Optional[FileInput] = None, - webm_sticker: Optional[FileInput] = None, - # ----> - sticker_type: Optional[str] = None, - # New params since bot api 6.6 - # <---- - stickers: Optional[ - Sequence[InputSticker] - ] = None, # Actually a required param. Optional for compat. - sticker_format: Optional[str] = None, # Actually a required param. Optional for compat. - needs_repainting: Optional[bool] = None, - # ----> - *, - read_timeout: ODVInput[float] = DEFAULT_NONE, - write_timeout: ODVInput[float] = 20, - connect_timeout: ODVInput[float] = DEFAULT_NONE, - pool_timeout: ODVInput[float] = DEFAULT_NONE, - api_kwargs: Optional[JSONDict] = None, - ) -> bool: - """ - Use this method to create new sticker set owned by a user. - The bot will be able to edit the created sticker set thus created. - - .. versionchanged:: 20.0 - The parameter ``contains_masks`` has been removed. Use :paramref:`sticker_type` - instead. - - .. versionchanged:: 20.2 - Since Bot API 6.6, the parameters :paramref:`stickers` and :paramref:`sticker_format` - replace the parameters :paramref:`png_sticker`, :paramref:`tgs_sticker`, - :paramref:`webm_sticker`, :paramref:`emojis`, and :paramref:`mask_position`. - - .. |api6_6_depr| replace:: Since Bot API 6.6, this argument is deprecated in favour of - :paramref:`stickers` and :paramref:`sticker_format`. - - Args: - user_id (:obj:`int`): User identifier of created sticker set owner. - name (:obj:`str`): Short name of sticker set, to be used in t.me/addstickers/ URLs - (e.g., animals). Can contain only english letters, digits and underscores. - Must begin with a letter, can't contain consecutive underscores and - must end in "_by_". is case insensitive. - :tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`- - :tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters. - title (:obj:`str`): Sticker set title, - :tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`- - :tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters. - - stickers (Sequence[:class:`telegram.InputSticker`]): A sequence of - :tg-const:`telegram.constants.StickerSetLimit.MIN_INITIAL_STICKERS`- - :tg-const:`telegram.constants.StickerSetLimit.MAX_INITIAL_STICKERS` initial - stickers to be added to the sticker set. - - .. versionadded:: 20.2 - - sticker_format (:obj:`str`): Format of stickers in the set, must be one of - :attr:`~telegram.constants.StickerFormat.STATIC`, - :attr:`~telegram.constants.StickerFormat.ANIMATED` or - :attr:`~telegram.constants.StickerFormat.VIDEO`. - - .. versionadded:: 20.2 - - sticker_type (:obj:`str`, optional): Type of stickers in the set, pass - :attr:`telegram.Sticker.REGULAR` or :attr:`telegram.Sticker.MASK`, or - :attr:`telegram.Sticker.CUSTOM_EMOJI`. By default, a regular sticker set is created - - .. versionadded:: 20.0 - - needs_repainting (:obj:`bool`, optional): Pass :obj:`True` if stickers in the sticker - set must be repainted to the color of text when used in messages, the accent color - if used as emoji status, white on chat photos, or another appropriate color based - on context; for custom emoji sticker sets only. - - .. versionadded:: 20.2 - - png_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \ - optional): **PNG** image with the sticker, - must be up to 512 kilobytes in size, dimensions must not exceed 512px, - and either width or height must be exactly 512px. - |fileinput| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |api6_6_depr| - - tgs_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \ - optional): **TGS** animation with the sticker. |uploadinput| - See https://core.telegram.org/stickers#animation-requirements for technical - requirements. - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |api6_6_depr| - - webm_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`,\ - optional): **WEBM** video with the sticker. |uploadinput| - See https://core.telegram.org/stickers#video-requirements for - technical requirements. - - .. versionadded:: 13.11 - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |api6_6_depr| - - emojis (:obj:`str`, optional): One or more emoji corresponding to the sticker. - - .. deprecated:: 20.2 - |api6_6_depr| - - mask_position (:class:`telegram.MaskPosition`, optional): Position where the mask - should be placed on faces. - - .. deprecated:: 20.2 - |api6_6_depr| - - Returns: - :obj:`bool`: On success, :obj:`True` is returned. - - Raises: - :exc:`TypeError`: Raised when: 1) ``stickers`` and ``sticker_format`` are passed - together with the deprecated parameters. 2) If neither the new parameters nor - the deprecated parameters are passed. - - :class:`telegram.error.TelegramError`: For other errors. - """ - pre_api_6_6_params = { - "emojis": emojis, - "png_sticker": png_sticker, - "mask_position": mask_position, - "tgs_sticker": tgs_sticker, - "webm_sticker": webm_sticker, - } - - if not any(pre_api_6_6_params.values()) and not all((stickers, sticker_format)): - raise TypeError( - "Since Bot API 6.6, the parameters `stickers` and `sticker_format` " - "are required, please pass them as well." - ) - - if any(pre_api_6_6_params.values()) and any((stickers, sticker_format)): - raise TypeError( - "Since Bot API 6.6, the parameters `stickers` and `sticker_format` " - "are mutually exclusive with the deprecated parameters " - f"{set(pre_api_6_6_params)}. Please use the new parameter " - "`stickers` and `sticker_format` instead." - ) - # If we had allowed this, the created sticker set would have used the newer parameters - # only, which would have been confusing. - - if any(pre_api_6_6_params.values()): - self._warn( - f"Since Bot API 6.6, the parameters {set(pre_api_6_6_params)} for " - "`create_new_sticker_set` are deprecated. Please use the new parameter " - "`stickers` and `sticker_format` instead.", - stacklevel=3, - category=PTBDeprecationWarning, - ) - - data: JSONDict = { - "user_id": user_id, - "name": name, - "title": title, - "stickers": stickers, - "sticker_format": sticker_format, - "sticker_type": sticker_type, - "needs_repainting": needs_repainting, - # Deprecated params since bot api 6.6 - "emojis": emojis, - "png_sticker": self._parse_file_input(png_sticker) if png_sticker else None, - "tgs_sticker": self._parse_file_input(tgs_sticker) if tgs_sticker else None, - "webm_sticker": self._parse_file_input(webm_sticker) if webm_sticker else None, - "mask_position": mask_position, - } - - return await self._post( - "createNewStickerSet", - data, - read_timeout=read_timeout, - write_timeout=write_timeout, - connect_timeout=connect_timeout, - pool_timeout=pool_timeout, - api_kwargs=api_kwargs, - ) - @_log async def add_sticker_to_set( self, user_id: Union[str, int], name: str, - # Deprecated params since bot api 6.6 - # ---- - emojis: Optional[str] = None, # Was made optional for compatibility reasons - png_sticker: Optional[FileInput] = None, - mask_position: Optional[MaskPosition] = None, - tgs_sticker: Optional[FileInput] = None, - webm_sticker: Optional[FileInput] = None, - # ---- - # New in bot api 6.6: - sticker: Optional[ - InputSticker - ] = None, # Actually a required param, but is optional for compat. + sticker: Optional[InputSticker], *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -5955,13 +5557,13 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. sticker sets can have up to :tg-const:`telegram.constants.StickerSetLimit.MAX_STATIC_STICKERS` stickers. - .. |api6_6| replace:: Since Bot API 6.6, this argument is deprecated in favour of - :paramref:`sticker`. - .. versionchanged:: 20.2 Since Bot API 6.6, the parameter :paramref:`sticker` replace the parameters - :paramref:`png_sticker`, :paramref:`tgs_sticker`, :paramref:`webm_sticker`, - :paramref:`emojis`, and :paramref:`mask_position`. + ``png_sticker``, ``tgs_sticker``, ``webm_sticker``, ``emojis``, and ``mask_position``. + + .. versionchanged:: NEXT.VERSION + Removed deprecated parameters ``png_sticker``, ``tgs_sticker``, ``webm_sticker``, + ``emojis``, and ``mask_position``. Args: user_id (:obj:`int`): User identifier of created sticker set owner. @@ -5972,114 +5574,17 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. .. versionadded:: 20.2 - emojis (:obj:`str`, optional): One or more emoji corresponding to the sticker. - - .. deprecated:: 20.2 - |api6_6| - - png_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \ - optional): **PNG** image with the sticker, - must be up to 512 kilobytes in size, dimensions must not exceed 512px, - and either width or height must be exactly 512px. - |fileinput| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |api6_6| - - mask_position (:class:`telegram.MaskPosition`, optional): Position where the mask - should be placed on faces. - - .. deprecated:: 20.2 - |api6_6| - - tgs_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \ - optional): **TGS** animation with the sticker. |uploadinput| - See https://core.telegram.org/stickers#animation-requirements for technical - requirements. - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |api6_6| - - webm_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`,\ - optional): **WEBM** video with the sticker. |uploadinput| - See https://core.telegram.org/stickers#video-requirements for - technical requirements. - - .. versionadded:: 13.11 - - .. versionchanged:: 20.0 - File paths as input is also accepted for bots *not* running in - :paramref:`~telegram.Bot.local_mode`. - - .. deprecated:: 20.2 - |api6_6| - Returns: :obj:`bool`: On success, :obj:`True` is returned. Raises: - :exc:`TypeError`: Raised when: 1) ``sticker`` is passed - together with the deprecated parameters. 2) If neither the new parameter nor - the deprecated parameters are passed. - - :class:`telegram.error.TelegramError`: For other errors. + :class:`telegram.error.TelegramError` """ - pre_api_6_6_params = { - "emojis": emojis, - "png_sticker": png_sticker, - "mask_position": mask_position, - "tgs_sticker": tgs_sticker, - "webm_sticker": webm_sticker, - } - - if not any(pre_api_6_6_params.values()) and not sticker: - raise TypeError( - "The parameter `sticker` is a required argument since Bot API 6.6 and" - " must be passed." - ) - - if any(pre_api_6_6_params.values()) and sticker: - raise TypeError( - "Since Bot API 6.6, the parameter `sticker` " - "is mutually exclusive with the deprecated parameters " - f"{set(pre_api_6_6_params)}. Please use the new parameter " - "`sticker` instead." - ) - - if any(pre_api_6_6_params.values()): - self._warn( - f"Since Bot API 6.6, the parameters {set(pre_api_6_6_params)} for " - "`add_sticker_to_set` are deprecated. Please use the new parameter `sticker` " - "instead.", - stacklevel=3, - category=PTBDeprecationWarning, - ) - data: JSONDict = { "user_id": user_id, "name": name, "sticker": sticker, - # Deprecated params since bot api 6.6: - "emojis": emojis, - "png_sticker": self._parse_file_input(png_sticker) if png_sticker else None, - "tgs_sticker": self._parse_file_input(tgs_sticker) if tgs_sticker else None, - "webm_sticker": self._parse_file_input(webm_sticker) if webm_sticker else None, - "mask_position": mask_position, } return await self._post( @@ -6128,6 +5633,105 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. api_kwargs=api_kwargs, ) + @_log + async def create_new_sticker_set( + self, + user_id: Union[str, int], + name: str, + title: str, + stickers: Optional[Sequence[InputSticker]], + sticker_format: Optional[str], + sticker_type: Optional[str] = None, + needs_repainting: Optional[bool] = None, + *, + read_timeout: ODVInput[float] = DEFAULT_NONE, + write_timeout: ODVInput[float] = 20, + connect_timeout: ODVInput[float] = DEFAULT_NONE, + pool_timeout: ODVInput[float] = DEFAULT_NONE, + api_kwargs: Optional[JSONDict] = None, + ) -> bool: + """ + Use this method to create new sticker set owned by a user. + The bot will be able to edit the created sticker set thus created. + + .. versionchanged:: 20.0 + The parameter ``contains_masks`` has been removed. Use :paramref:`sticker_type` + instead. + + .. versionchanged:: 20.2 + Since Bot API 6.6, the parameters :paramref:`stickers` and :paramref:`sticker_format` + replace the parameters ``png_sticker``, ``tgs_sticker``,``webm_sticker``, ``emojis``, + and ``mask_position``. + + .. versionchanged:: NEXT.VERSION + Removed the deprecated parameters mentioned above and adjusted the order of the + parameters. + + Args: + user_id (:obj:`int`): User identifier of created sticker set owner. + name (:obj:`str`): Short name of sticker set, to be used in t.me/addstickers/ URLs + (e.g., animals). Can contain only english letters, digits and underscores. + Must begin with a letter, can't contain consecutive underscores and + must end in "_by_". is case insensitive. + :tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`- + :tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters. + title (:obj:`str`): Sticker set title, + :tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`- + :tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters. + + stickers (Sequence[:class:`telegram.InputSticker`]): A sequence of + :tg-const:`telegram.constants.StickerSetLimit.MIN_INITIAL_STICKERS`- + :tg-const:`telegram.constants.StickerSetLimit.MAX_INITIAL_STICKERS` initial + stickers to be added to the sticker set. + + .. versionadded:: 20.2 + + sticker_format (:obj:`str`): Format of stickers in the set, must be one of + :attr:`~telegram.constants.StickerFormat.STATIC`, + :attr:`~telegram.constants.StickerFormat.ANIMATED` or + :attr:`~telegram.constants.StickerFormat.VIDEO`. + + .. versionadded:: 20.2 + + sticker_type (:obj:`str`, optional): Type of stickers in the set, pass + :attr:`telegram.Sticker.REGULAR` or :attr:`telegram.Sticker.MASK`, or + :attr:`telegram.Sticker.CUSTOM_EMOJI`. By default, a regular sticker set is created + + .. versionadded:: 20.0 + + needs_repainting (:obj:`bool`, optional): Pass :obj:`True` if stickers in the sticker + set must be repainted to the color of text when used in messages, the accent color + if used as emoji status, white on chat photos, or another appropriate color based + on context; for custom emoji sticker sets only. + + .. versionadded:: 20.2 + + Returns: + :obj:`bool`: On success, :obj:`True` is returned. + + Raises: + :class:`telegram.error.TelegramError` + """ + data: JSONDict = { + "user_id": user_id, + "name": name, + "title": title, + "stickers": stickers, + "sticker_format": sticker_format, + "sticker_type": sticker_type, + "needs_repainting": needs_repainting, + } + + return await self._post( + "createNewStickerSet", + data, + read_timeout=read_timeout, + write_timeout=write_timeout, + connect_timeout=connect_timeout, + pool_timeout=pool_timeout, + api_kwargs=api_kwargs, + ) + @_log async def delete_sticker_from_set( self, @@ -6248,95 +5852,6 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. :class:`telegram.error.TelegramError` """ - return await self._set_sticker_set_thumbnail( - name=name, - user_id=user_id, - thumbnail=thumbnail, - read_timeout=read_timeout, - write_timeout=write_timeout, - connect_timeout=connect_timeout, - pool_timeout=pool_timeout, - api_kwargs=api_kwargs, - ) - - @_log - async def set_sticker_set_thumb( - self, - name: str, - user_id: Union[str, int], - thumb: Optional[FileInput] = None, - *, - read_timeout: ODVInput[float] = DEFAULT_NONE, - write_timeout: ODVInput[float] = DEFAULT_NONE, - connect_timeout: ODVInput[float] = DEFAULT_NONE, - pool_timeout: ODVInput[float] = DEFAULT_NONE, - api_kwargs: Optional[JSONDict] = None, - ) -> bool: - """Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set - for animated sticker sets only. Video thumbnails can be set only for video sticker sets - only. - - .. deprecated:: 20.2 - Bot API 6.6 renamed this method to :meth:`~Bot.set_sticker_set_thumbnail`. - - Args: - name (:obj:`str`): Sticker set name - user_id (:obj:`int`): User identifier of created sticker set owner. - thumb (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \ - optional): A **PNG** image with the thumbnail, must - be up to 128 kilobytes in size and have width and height exactly 100px, or a - **TGS** animation with the thumbnail up to 32 kilobytes in size; see - https://core.telegram.org/stickers#animation-requirements for animated - sticker technical requirements, or a **WEBM** video with the thumbnail up to 32 - kilobytes in size; see - https://core.telegram.org/stickers#video-requirements for video sticker - technical requirements. - |fileinput| - Animated sticker set thumbnails can't be uploaded via HTTP URL. - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - Returns: - :obj:`bool`: On success, :obj:`True` is returned. - - Raises: - :class:`telegram.error.TelegramError` - - """ - self._warn( - message=( - "Bot API 6.6 renamed the method 'setStickerSetThumb' to 'setStickerSetThumbnail', " - "hence method 'set_sticker_set_thumb' was renamed to 'set_sticker_set_thumbnail' " - "in PTB." - ), - category=PTBDeprecationWarning, - stacklevel=3, - ) - - return await self._set_sticker_set_thumbnail( - name=name, - user_id=user_id, - thumbnail=thumb, - read_timeout=read_timeout, - write_timeout=write_timeout, - connect_timeout=connect_timeout, - pool_timeout=pool_timeout, - api_kwargs=api_kwargs, - ) - - @_log - async def _set_sticker_set_thumbnail( - self, - name: str, - user_id: Union[str, int], - thumbnail: Optional[FileInput] = None, - *, - read_timeout: ODVInput[float] = DEFAULT_NONE, - write_timeout: ODVInput[float] = DEFAULT_NONE, - connect_timeout: ODVInput[float] = DEFAULT_NONE, - pool_timeout: ODVInput[float] = DEFAULT_NONE, - api_kwargs: Optional[JSONDict] = None, - ) -> bool: data: JSONDict = { "name": name, "user_id": user_id, @@ -8483,12 +7998,6 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified. """Alias for :meth:`set_sticker_position_in_set`""" deleteStickerFromSet = delete_sticker_from_set """Alias for :meth:`delete_sticker_from_set`""" - setStickerSetThumb = set_sticker_set_thumb - """Alias for :meth:`set_sticker_set_thumb` - - .. deprecated:: 20.2 - Bot API 6.6 renamed this method to :meth:`~Bot.set_sticker_set_thumbnail`. - """ setStickerSetThumbnail = set_sticker_set_thumbnail """Alias for :meth:`set_sticker_set_thumbnail`""" setPassportDataErrors = set_passport_data_errors diff --git a/telegram/_chat.py b/telegram/_chat.py index 3163ab06a..3a199f5ff 100644 --- a/telegram/_chat.py +++ b/telegram/_chat.py @@ -1557,7 +1557,6 @@ class Chat(TelegramObject): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -1592,7 +1591,6 @@ class Chat(TelegramObject): reply_to_message_id=reply_to_message_id, reply_markup=reply_markup, parse_mode=parse_mode, - thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, filename=filename, @@ -1614,7 +1612,6 @@ class Chat(TelegramObject): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, disable_content_type_detection: Optional[bool] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, @@ -1652,7 +1649,6 @@ class Chat(TelegramObject): connect_timeout=connect_timeout, pool_timeout=pool_timeout, parse_mode=parse_mode, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, disable_content_type_detection=disable_content_type_detection, @@ -1898,7 +1894,6 @@ class Chat(TelegramObject): duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_notification: DVInput[bool] = DEFAULT_NONE, @@ -1934,7 +1929,6 @@ class Chat(TelegramObject): duration=duration, width=width, height=height, - thumb=thumb, caption=caption, parse_mode=parse_mode, disable_notification=disable_notification, @@ -2068,7 +2062,6 @@ class Chat(TelegramObject): height: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, supports_streaming: Optional[bool] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -2109,7 +2102,6 @@ class Chat(TelegramObject): height=height, parse_mode=parse_mode, supports_streaming=supports_streaming, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, @@ -2128,7 +2120,6 @@ class Chat(TelegramObject): disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, message_thread_id: Optional[int] = None, @@ -2163,7 +2154,6 @@ class Chat(TelegramObject): write_timeout=write_timeout, connect_timeout=connect_timeout, pool_timeout=pool_timeout, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, diff --git a/telegram/_chatmember.py b/telegram/_chatmember.py index 41d8e93f9..ae15587a8 100644 --- a/telegram/_chatmember.py +++ b/telegram/_chatmember.py @@ -130,6 +130,12 @@ class ChatMember(TelegramObject): data["until_date"] = from_timestamp(data["until_date"], tzinfo=loc_tzinfo) + # This is a deprecated field that TG still returns for backwards compatibility + # Let's filter it out to speed up the de-json process + if cls is ChatMemberRestricted and data.get("can_send_media_messages") is not None: + api_kwargs = {"can_send_media_messages": data.pop("can_send_media_messages")} + return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs) + return super().de_json(data=data, bot=bot) @@ -360,6 +366,9 @@ class ChatMemberRestricted(ChatMember): All arguments were made positional and their order was changed. The argument can_manage_topics was added. + .. versionchanged:: NEXT.VERSION + Removed deprecated argument and attribute ``can_send_media_messages``. + Args: user (:class:`telegram.User`): Information about the user. is_member (:obj:`bool`): :obj:`True`, if the user is a @@ -372,11 +381,6 @@ class ChatMemberRestricted(ChatMember): to pin messages; groups and supergroups only. can_send_messages (:obj:`bool`): :obj:`True`, if the user is allowed to send text messages, contacts, invoices, locations and venues. - can_send_media_messages (:obj:`bool`): :obj:`True`, if the user is allowed - to send audios, documents, photos, videos, video notes and voice notes. - - .. deprecated:: 20.1 - Bot API 6.5 replaced this argument with granular media settings. can_send_polls (:obj:`bool`): :obj:`True`, if the user is allowed to send polls. can_send_other_messages (:obj:`bool`): :obj:`True`, if the user is allowed @@ -427,11 +431,6 @@ class ChatMemberRestricted(ChatMember): to pin messages; groups and supergroups only. can_send_messages (:obj:`bool`): :obj:`True`, if the user is allowed to send text messages, contacts, locations and venues. - can_send_media_messages (:obj:`bool`): :obj:`True`, if the user is allowed - to send audios, documents, photos, videos, video notes and voice notes. - - .. deprecated:: 20.1 - Bot API 6.5 replaced this attribute with granular media settings. can_send_polls (:obj:`bool`): :obj:`True`, if the user is allowed to send polls. can_send_other_messages (:obj:`bool`): :obj:`True`, if the user is allowed @@ -476,7 +475,6 @@ class ChatMemberRestricted(ChatMember): "can_invite_users", "can_pin_messages", "can_send_messages", - "can_send_media_messages", "can_send_polls", "can_send_other_messages", "can_add_web_page_previews", @@ -498,7 +496,6 @@ class ChatMemberRestricted(ChatMember): can_invite_users: bool, can_pin_messages: bool, can_send_messages: bool, - can_send_media_messages: bool, can_send_polls: bool, can_send_other_messages: bool, can_add_web_page_previews: bool, @@ -520,7 +517,6 @@ class ChatMemberRestricted(ChatMember): self.can_invite_users: bool = can_invite_users self.can_pin_messages: bool = can_pin_messages self.can_send_messages: bool = can_send_messages - self.can_send_media_messages: bool = can_send_media_messages self.can_send_polls: bool = can_send_polls self.can_send_other_messages: bool = can_send_other_messages self.can_add_web_page_previews: bool = can_add_web_page_previews diff --git a/telegram/_chatpermissions.py b/telegram/_chatpermissions.py index a2385d2be..ebec64def 100644 --- a/telegram/_chatpermissions.py +++ b/telegram/_chatpermissions.py @@ -17,31 +17,36 @@ # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains an object that represents a Telegram ChatPermission.""" -from typing import Optional +from typing import TYPE_CHECKING, Optional from telegram._telegramobject import TelegramObject from telegram._utils.types import JSONDict -from telegram._utils.warnings import warn -from telegram.warnings import PTBDeprecationWarning + +if TYPE_CHECKING: + from telegram import Bot class ChatPermissions(TelegramObject): """Describes actions that a non-administrator user is allowed to take in a chat. Objects of this class are comparable in terms of equality. Two objects of this class are - considered equal, if their :attr:`can_send_messages`, :attr:`can_send_media_messages`, + considered equal, if their :attr:`can_send_messages`, :attr:`can_send_polls`, :attr:`can_send_other_messages`, :attr:`can_add_web_page_previews`, - :attr:`can_change_info`, :attr:`can_invite_users`, :attr:`can_pin_messages`, and + :attr:`can_change_info`, :attr:`can_invite_users`, :attr:`can_pin_messages`, + :attr:`can_send_audios`, :attr:`can_send_documents`, :attr:`can_send_photos`, + :attr:`can_send_videos`, :attr:`can_send_video_notes`, :attr:`can_send_voice_notes`, and :attr:`can_manage_topics` are equal. .. versionchanged:: 20.0 :attr:`can_manage_topics` is considered as well when comparing objects of this type in terms of equality. - .. deprecated:: 20.1 - :attr:`can_send_audios`, :attr:`can_send_documents`, :attr:`can_send_photos`, - :attr:`can_send_videos`, :attr:`can_send_video_notes` and :attr:`can_send_voice_notes` - will be considered as well when comparing objects of this type in terms of equality in - V21. + .. versionchanged:: NEXT.VERSION + + * :attr:`can_send_audios`, :attr:`can_send_documents`, :attr:`can_send_photos`, + :attr:`can_send_videos`, :attr:`can_send_video_notes` and :attr:`can_send_voice_notes` + are considered as well when comparing objects of this type in terms of equality. + * Removed deprecated argument and attribute ``can_send_media_messages``. + Note: Though not stated explicitly in the official docs, Telegram changes not only the @@ -51,19 +56,11 @@ class ChatPermissions(TelegramObject): Args: can_send_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to send text messages, contacts, locations and venues. - can_send_media_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to - send audios, documents, photos, videos, video notes and voice notes, implies - :attr:`can_send_messages`. - - .. deprecated:: 20.1 - Bot API 6.5 replaced this argument with granular media settings. - can_send_polls (:obj:`bool`, optional): :obj:`True`, if the user is allowed to send polls, - implies :attr:`can_send_messages`. + can_send_polls (:obj:`bool`, optional): :obj:`True`, if the user is allowed to send polls. can_send_other_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to - send animations, games, stickers and use inline bots, implies - :attr:`can_send_media_messages`. + send animations, games, stickers and use inline bots. can_add_web_page_previews (:obj:`bool`, optional): :obj:`True`, if the user is allowed to - add web page previews to their messages, implies :attr:`can_send_media_messages`. + add web page previews to their messages. can_change_info (:obj:`bool`, optional): :obj:`True`, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups. can_invite_users (:obj:`bool`, optional): :obj:`True`, if the user is allowed to invite new @@ -99,19 +96,12 @@ class ChatPermissions(TelegramObject): Attributes: can_send_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to send text messages, contacts, locations and venues. - can_send_media_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to - send audios, documents, photos, videos, video notes and voice notes, implies - :attr:`can_send_messages`. - - .. deprecated:: 20.1 - Bot API 6.5 replaced this attribute with granular media settings. can_send_polls (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to send polls, implies :attr:`can_send_messages`. can_send_other_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to - send animations, games, stickers and use inline bots, implies - :attr:`can_send_media_messages`. + send animations, games, stickers and use inline bots. can_add_web_page_previews (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to - add web page previews to their messages, implies :attr:`can_send_media_messages`. + add web page previews to their messages. can_change_info (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups. can_invite_users (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to invite @@ -151,7 +141,6 @@ class ChatPermissions(TelegramObject): "can_invite_users", "can_send_polls", "can_send_messages", - "can_send_media_messages", "can_change_info", "can_pin_messages", "can_add_web_page_previews", @@ -167,7 +156,6 @@ class ChatPermissions(TelegramObject): def __init__( self, can_send_messages: Optional[bool] = None, - can_send_media_messages: Optional[bool] = None, can_send_polls: Optional[bool] = None, can_send_other_messages: Optional[bool] = None, can_add_web_page_previews: Optional[bool] = None, @@ -187,7 +175,6 @@ class ChatPermissions(TelegramObject): super().__init__(api_kwargs=api_kwargs) # Required self.can_send_messages: Optional[bool] = can_send_messages - self.can_send_media_messages: Optional[bool] = can_send_media_messages self.can_send_polls: Optional[bool] = can_send_polls self.can_send_other_messages: Optional[bool] = can_send_other_messages self.can_add_web_page_previews: Optional[bool] = can_add_web_page_previews @@ -204,7 +191,6 @@ class ChatPermissions(TelegramObject): self._id_attrs = ( self.can_send_messages, - self.can_send_media_messages, self.can_send_polls, self.can_send_other_messages, self.can_add_web_page_previews, @@ -212,23 +198,16 @@ class ChatPermissions(TelegramObject): self.can_invite_users, self.can_pin_messages, self.can_manage_topics, + self.can_send_audios, + self.can_send_documents, + self.can_send_photos, + self.can_send_videos, + self.can_send_video_notes, + self.can_send_voice_notes, ) self._freeze() - def __eq__(self, other: object) -> bool: - warn( - "In v21, granular media settings will be considered as well when comparing" - " ChatPermissions instances.", - PTBDeprecationWarning, - stacklevel=2, - ) - return super().__eq__(other) - - def __hash__(self) -> int: - # Intend: Added so support the own __eq__ function (which otherwise breaks hashing) - return super().__hash__() - @classmethod def all_permissions(cls) -> "ChatPermissions": """ @@ -239,7 +218,7 @@ class ChatPermissions(TelegramObject): .. versionadded:: 20.0 """ - return cls(*(15 * (True,))) + return cls(*(14 * (True,))) @classmethod def no_permissions(cls) -> "ChatPermissions": @@ -249,4 +228,20 @@ class ChatPermissions(TelegramObject): .. versionadded:: 20.0 """ - return cls(*(15 * (False,))) + return cls(*(14 * (False,))) + + @classmethod + def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["ChatPermissions"]: + """See :meth:`telegram.TelegramObject.de_json`.""" + data = cls._parse_data(data) + + if not data: + return None + + api_kwargs = {} + # This is a deprecated field that TG still returns for backwards compatibility + # Let's filter it out to speed up the de-json process + if data.get("can_send_media_messages") is not None: + api_kwargs["can_send_media_messages"] = data.pop("can_send_media_messages") + + return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs) diff --git a/telegram/_files/_basethumbedmedium.py b/telegram/_files/_basethumbedmedium.py index e0ba2ec9e..0c7491f14 100644 --- a/telegram/_files/_basethumbedmedium.py +++ b/telegram/_files/_basethumbedmedium.py @@ -22,10 +22,6 @@ from typing import TYPE_CHECKING, Optional, Type, TypeVar from telegram._files._basemedium import _BaseMedium from telegram._files.photosize import PhotoSize from telegram._utils.types import JSONDict -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) if TYPE_CHECKING: from telegram import Bot @@ -48,10 +44,6 @@ class _BaseThumbedMedium(_BaseMedium): is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. file_size (:obj:`int`, optional): File size. - thumb (:class:`telegram.PhotoSize`, optional): Thumbnail as defined by sender. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:class:`telegram.PhotoSize`, optional): Thumbnail as defined by sender. .. versionadded:: 20.2 @@ -75,7 +67,6 @@ class _BaseThumbedMedium(_BaseMedium): file_id: str, file_unique_id: str, file_size: Optional[int] = None, - thumb: Optional[PhotoSize] = None, thumbnail: Optional[PhotoSize] = None, *, api_kwargs: Optional[JSONDict] = None, @@ -87,26 +78,7 @@ class _BaseThumbedMedium(_BaseMedium): api_kwargs=api_kwargs, ) - self.thumbnail: Optional[PhotoSize] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb, - new_arg=thumbnail, - deprecated_arg_name="thumb", - new_arg_name="thumbnail", - bot_api_version="6.6", - stacklevel=3, - ) - - @property - def thumb(self) -> Optional[PhotoSize]: - """:class:`telegram.PhotoSize`: Optional. Thumbnail as defined by sender. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb", new_attr_name="thumbnail", bot_api_version="6.6" - ) - return self.thumbnail + self.thumbnail: Optional[PhotoSize] = thumbnail @classmethod def de_json( diff --git a/telegram/_files/animation.py b/telegram/_files/animation.py index aa7c91600..2a10a3bad 100644 --- a/telegram/_files/animation.py +++ b/telegram/_files/animation.py @@ -30,6 +30,9 @@ class Animation(_BaseThumbedMedium): Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`file_unique_id` is equal. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: file_id (:obj:`str`): Identifier for this file, which can be used to download or reuse the file. @@ -39,10 +42,6 @@ class Animation(_BaseThumbedMedium): width (:obj:`int`): Video width as defined by sender. height (:obj:`int`): Video height as defined by sender. duration (:obj:`int`): Duration of the video in seconds as defined by sender. - thumb (:class:`telegram.PhotoSize`, optional): Animation thumbnail as defined by sender. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. file_name (:obj:`str`, optional): Original animation filename as defined by sender. mime_type (:obj:`str`, optional): MIME type of the file as defined by sender. file_size (:obj:`int`, optional): File size in bytes. @@ -79,7 +78,6 @@ class Animation(_BaseThumbedMedium): width: int, height: int, duration: int, - thumb: Optional[PhotoSize] = None, file_name: Optional[str] = None, mime_type: Optional[str] = None, file_size: Optional[int] = None, @@ -91,7 +89,6 @@ class Animation(_BaseThumbedMedium): file_id=file_id, file_unique_id=file_unique_id, file_size=file_size, - thumb=thumb, api_kwargs=api_kwargs, thumbnail=thumbnail, ) diff --git a/telegram/_files/audio.py b/telegram/_files/audio.py index f0e315ce1..2a751512a 100644 --- a/telegram/_files/audio.py +++ b/telegram/_files/audio.py @@ -30,6 +30,9 @@ class Audio(_BaseThumbedMedium): Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`file_unique_id` is equal. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: file_id (:obj:`str`): Identifier for this file, which can be used to download @@ -43,11 +46,6 @@ class Audio(_BaseThumbedMedium): file_name (:obj:`str`, optional): Original filename as defined by sender. mime_type (:obj:`str`, optional): MIME type of the file as defined by sender. file_size (:obj:`int`, optional): File size in bytes. - thumb (:class:`telegram.PhotoSize`, optional): Thumbnail of the album cover to - which the music file belongs. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:class:`telegram.PhotoSize`, optional): Thumbnail of the album cover to which the music file belongs. @@ -84,7 +82,6 @@ class Audio(_BaseThumbedMedium): title: Optional[str] = None, mime_type: Optional[str] = None, file_size: Optional[int] = None, - thumb: Optional[PhotoSize] = None, file_name: Optional[str] = None, thumbnail: Optional[PhotoSize] = None, *, @@ -94,7 +91,6 @@ class Audio(_BaseThumbedMedium): file_id=file_id, file_unique_id=file_unique_id, file_size=file_size, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, ) diff --git a/telegram/_files/document.py b/telegram/_files/document.py index a16c6900e..c5a73ca3e 100644 --- a/telegram/_files/document.py +++ b/telegram/_files/document.py @@ -31,15 +31,14 @@ class Document(_BaseThumbedMedium): Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`file_unique_id` is equal. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: file_id (:obj:`str`): Identifier for this file, which can be used to download or reuse the file. file_unique_id (:obj:`str`): Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. - thumb (:class:`telegram.PhotoSize`, optional): Document thumbnail as defined by sender. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. file_name (:obj:`str`, optional): Original filename as defined by sender. mime_type (:obj:`str`, optional): MIME type of the file as defined by sender. file_size (:obj:`int`, optional): File size in bytes. @@ -67,7 +66,6 @@ class Document(_BaseThumbedMedium): self, file_id: str, file_unique_id: str, - thumb: Optional[PhotoSize] = None, file_name: Optional[str] = None, mime_type: Optional[str] = None, file_size: Optional[int] = None, @@ -79,7 +77,6 @@ class Document(_BaseThumbedMedium): file_id=file_id, file_unique_id=file_unique_id, file_size=file_size, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, ) diff --git a/telegram/_files/inputmedia.py b/telegram/_files/inputmedia.py index 1c978ebf3..c3f6a6b77 100644 --- a/telegram/_files/inputmedia.py +++ b/telegram/_files/inputmedia.py @@ -31,10 +31,6 @@ from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.files import parse_file_input from telegram._utils.types import FileInput, JSONDict, ODVInput -from telegram._utils.warnings_transition import ( - warn_about_deprecated_attr_in_property, - warn_about_thumb_return_thumbnail, -) from telegram.constants import InputMediaType MediaType = Union[Animation, Audio, Document, PhotoSize, Video] @@ -107,11 +103,13 @@ class InputMedia(TelegramObject): self._freeze() @staticmethod - def _parse_thumb_input(thumb: Optional[FileInput]) -> Optional[Union[str, InputFile]]: + def _parse_thumbnail_input(thumbnail: Optional[FileInput]) -> Optional[Union[str, InputFile]]: # We use local_mode=True because we don't have access to the actual setting and want # things to work in local mode. return ( - parse_file_input(thumb, attach=True, local_mode=True) if thumb is not None else thumb + parse_file_input(thumbnail, attach=True, local_mode=True) + if thumbnail is not None + else thumbnail ) @@ -125,6 +123,9 @@ class InputMediaAnimation(InputMedia): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ :class:`telegram.Animation`): File to send. |fileinputnopath| @@ -137,14 +138,6 @@ class InputMediaAnimation(InputMedia): :obj:`tempfile` module. .. versionadded:: 13.1 - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstringnopath| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. caption (:obj:`str`, optional): Caption of the animation to be sent, 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities parsing. @@ -196,7 +189,6 @@ class InputMediaAnimation(InputMedia): def __init__( self, media: Union[FileInput, Animation], - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, width: Optional[int] = None, @@ -219,7 +211,6 @@ class InputMediaAnimation(InputMedia): # things to work in local mode. media = parse_file_input(media, filename=filename, attach=True, local_mode=True) - thumbnail = warn_about_thumb_return_thumbnail(deprecated_arg=thumb, new_arg=thumbnail) super().__init__( InputMediaType.ANIMATION, media, @@ -229,26 +220,14 @@ class InputMediaAnimation(InputMedia): api_kwargs=api_kwargs, ) with self._unfrozen(): - self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumbnail) + self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input( + thumbnail + ) self.width: Optional[int] = width self.height: Optional[int] = height self.duration: Optional[int] = duration self.has_spoiler: Optional[bool] = has_spoiler - @property - def thumb(self) -> Optional[Union[str, InputFile]]: - """:class:`telegram.InputFile`: Optional. |thumbdocstringbase| - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb", - new_attr_name="thumbnail", - bot_api_version="6.6", - ) - return self.thumbnail - class InputMediaPhoto(InputMedia): """Represents a photo to be sent. @@ -337,9 +316,12 @@ class InputMediaVideo(InputMedia): * When using a :class:`telegram.Video` for the :attr:`media` attribute, it will take the width, height and duration from that video, unless otherwise specified with the optional arguments. - * :paramref:`thumb` will be ignored for small video files, for which Telegram can easily - generate thumbnails. However, this behaviour is undocumented and might be changed - by Telegram. + * :paramref:`thumbnail` will be ignored for small video files, for which Telegram can + easily generate thumbnails. However, this behaviour is undocumented and might be + changed by Telegram. + + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| Args: media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ @@ -367,14 +349,6 @@ class InputMediaVideo(InputMedia): duration (:obj:`int`, optional): Video duration in seconds. supports_streaming (:obj:`bool`, optional): Pass :obj:`True`, if the uploaded video is suitable for streaming. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstringnopath| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. has_spoiler (:obj:`bool`, optional): Pass :obj:`True`, if the video needs to be covered with a spoiler animation. @@ -429,7 +403,6 @@ class InputMediaVideo(InputMedia): duration: Optional[int] = None, supports_streaming: Optional[bool] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, caption_entities: Optional[Sequence[MessageEntity]] = None, filename: Optional[str] = None, has_spoiler: Optional[bool] = None, @@ -447,7 +420,6 @@ class InputMediaVideo(InputMedia): # things to work in local mode. media = parse_file_input(media, filename=filename, attach=True, local_mode=True) - thumbnail = warn_about_thumb_return_thumbnail(deprecated_arg=thumb, new_arg=thumbnail) super().__init__( InputMediaType.VIDEO, media, @@ -460,24 +432,12 @@ class InputMediaVideo(InputMedia): self.width: Optional[int] = width self.height: Optional[int] = height self.duration: Optional[int] = duration - self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumbnail) + self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input( + thumbnail + ) self.supports_streaming: Optional[bool] = supports_streaming self.has_spoiler: Optional[bool] = has_spoiler - @property - def thumb(self) -> Optional[Union[str, InputFile]]: - """:class:`telegram.InputFile`: Optional. |thumbdocstringbase| - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb", - new_attr_name="thumbnail", - bot_api_version="6.6", - ) - return self.thumbnail - class InputMediaAudio(InputMedia): """Represents an audio file to be treated as music to be sent. @@ -489,6 +449,9 @@ class InputMediaAudio(InputMedia): duration, performer and title from that video, unless otherwise specified with the optional arguments. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ :class:`telegram.Audio`): File to send. |fileinputnopath| @@ -514,14 +477,6 @@ class InputMediaAudio(InputMedia): performer (:obj:`str`, optional): Performer of the audio as defined by sender or by audio tags. title (:obj:`str`, optional): Title of the audio as defined by sender or by audio tags. - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstringnopath| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ optional): |thumbdocstringnopath| @@ -555,7 +510,6 @@ class InputMediaAudio(InputMedia): def __init__( self, media: Union[FileInput, Audio], - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, duration: Optional[int] = None, @@ -577,7 +531,6 @@ class InputMediaAudio(InputMedia): # things to work in local mode. media = parse_file_input(media, filename=filename, attach=True, local_mode=True) - thumbnail = warn_about_thumb_return_thumbnail(deprecated_arg=thumb, new_arg=thumbnail) super().__init__( InputMediaType.AUDIO, media, @@ -587,31 +540,22 @@ class InputMediaAudio(InputMedia): api_kwargs=api_kwargs, ) with self._unfrozen(): - self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumbnail) + self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input( + thumbnail + ) self.duration: Optional[int] = duration self.title: Optional[str] = title self.performer: Optional[str] = performer - @property - def thumb(self) -> Optional[Union[str, InputFile]]: - """:class:`telegram.InputFile`: Optional. |thumbdocstringbase| - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb", - new_attr_name="thumbnail", - bot_api_version="6.6", - ) - return self.thumbnail - class InputMediaDocument(InputMedia): """Represents a general file to be sent. .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \ :class:`telegram.Document`): File to send. |fileinputnopath| @@ -633,14 +577,6 @@ class InputMediaDocument(InputMedia): .. versionchanged:: 20.0 |sequenceclassargs| - thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \ - optional): |thumbdocstringnopath| - - .. versionchanged:: 13.2 - Accept :obj:`bytes` as input. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. disable_content_type_detection (:obj:`bool`, optional): Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always :obj:`True`, if the document is sent as part of an album. @@ -675,7 +611,6 @@ class InputMediaDocument(InputMedia): def __init__( self, media: Union[FileInput, Document], - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_content_type_detection: Optional[bool] = None, @@ -689,7 +624,6 @@ class InputMediaDocument(InputMedia): # things to work in local mode. media = parse_file_input(media, Document, filename=filename, attach=True, local_mode=True) - thumbnail = warn_about_thumb_return_thumbnail(deprecated_arg=thumb, new_arg=thumbnail) super().__init__( InputMediaType.DOCUMENT, media, @@ -699,19 +633,7 @@ class InputMediaDocument(InputMedia): api_kwargs=api_kwargs, ) with self._unfrozen(): - self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumb_input(thumbnail) + self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input( + thumbnail + ) self.disable_content_type_detection: Optional[bool] = disable_content_type_detection - - @property - def thumb(self) -> Optional[Union[str, InputFile]]: - """:class:`telegram.InputFile`: Optional. |thumbdocstringbase| - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb", - new_attr_name="thumbnail", - bot_api_version="6.6", - ) - return self.thumbnail diff --git a/telegram/_files/sticker.py b/telegram/_files/sticker.py index c0a83ea01..7e51fdc25 100644 --- a/telegram/_files/sticker.py +++ b/telegram/_files/sticker.py @@ -26,10 +26,6 @@ from telegram._files.photosize import PhotoSize from telegram._telegramobject import TelegramObject from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.types import JSONDict -from telegram._utils.warnings_transition import ( - warn_about_deprecated_attr_in_property, - warn_about_thumb_return_thumbnail, -) if TYPE_CHECKING: from telegram import Bot @@ -46,6 +42,9 @@ class Sticker(_BaseThumbedMedium): arguments had to be changed. Use keyword arguments to make sure that the arguments are passed correctly. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: file_id (:obj:`str`): Identifier for this file, which can be used to download or reuse the file. @@ -63,11 +62,6 @@ class Sticker(_BaseThumbedMedium): format, which is determined by the fields :attr:`is_animated` and :attr:`is_video`. .. versionadded:: 20.0 - thumb (:class:`telegram.PhotoSize`, optional): Sticker thumbnail in the ``.WEBP`` or - ``.JPG`` format. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. emoji (:obj:`str`, optional): Emoji associated with the sticker set_name (:obj:`str`, optional): Name of the sticker set to which the sticker belongs. mask_position (:class:`telegram.MaskPosition`, optional): For mask stickers, the position @@ -157,7 +151,6 @@ class Sticker(_BaseThumbedMedium): is_animated: bool, is_video: bool, type: str, # pylint: disable=redefined-builtin - thumb: Optional[PhotoSize] = None, emoji: Optional[str] = None, file_size: Optional[int] = None, set_name: Optional[str] = None, @@ -173,7 +166,6 @@ class Sticker(_BaseThumbedMedium): file_id=file_id, file_unique_id=file_unique_id, file_size=file_size, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, ) @@ -234,6 +226,9 @@ class StickerSet(TelegramObject): .. versionchanged:: 20.0 The parameter ``contains_masks`` has been removed. Use :paramref:`sticker_type` instead. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: name (:obj:`str`): Sticker set name. title (:obj:`str`): Sticker set title. @@ -251,11 +246,6 @@ class StickerSet(TelegramObject): :attr:`telegram.Sticker.CUSTOM_EMOJI`. .. versionadded:: 20.0 - thumb (:class:`telegram.PhotoSize`, optional): Sticker set thumbnail in the ``.WEBP``, - ``.TGS``, or ``.WEBM`` format. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. thumbnail (:class:`telegram.PhotoSize`, optional): Sticker set thumbnail in the ``.WEBP``, ``.TGS``, or ``.WEBM`` format. @@ -302,7 +292,6 @@ class StickerSet(TelegramObject): stickers: Sequence[Sticker], is_video: bool, sticker_type: str, - thumb: Optional[PhotoSize] = None, thumbnail: Optional[PhotoSize] = None, *, api_kwargs: Optional[JSONDict] = None, @@ -316,28 +305,11 @@ class StickerSet(TelegramObject): self.sticker_type: str = sticker_type # Optional - self.thumbnail: Optional[PhotoSize] = warn_about_thumb_return_thumbnail( - deprecated_arg=thumb, new_arg=thumbnail - ) + self.thumbnail: Optional[PhotoSize] = thumbnail self._id_attrs = (self.name,) self._freeze() - @property - def thumb(self) -> Optional[PhotoSize]: - """:class:`telegram.PhotoSize`: Optional. Sticker set thumbnail in the ``.WEBP``, - ``.TGS``, or ``.WEBM`` format. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb", - new_attr_name="thumbnail", - bot_api_version="6.6", - ) - return self.thumbnail - @classmethod def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["StickerSet"]: """See :meth:`telegram.TelegramObject.de_json`.""" diff --git a/telegram/_files/video.py b/telegram/_files/video.py index b77acc71b..300164922 100644 --- a/telegram/_files/video.py +++ b/telegram/_files/video.py @@ -30,6 +30,9 @@ class Video(_BaseThumbedMedium): Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`file_unique_id` is equal. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: file_id (:obj:`str`): Identifier for this file, which can be used to download or reuse the file. @@ -39,10 +42,6 @@ class Video(_BaseThumbedMedium): width (:obj:`int`): Video width as defined by sender. height (:obj:`int`): Video height as defined by sender. duration (:obj:`int`): Duration of the video in seconds as defined by sender. - thumb (:class:`telegram.PhotoSize`, optional): Video thumbnail. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. file_name (:obj:`str`, optional): Original filename as defined by sender. mime_type (:obj:`str`, optional): MIME type of a file as defined by sender. file_size (:obj:`int`, optional): File size in bytes. @@ -76,7 +75,6 @@ class Video(_BaseThumbedMedium): width: int, height: int, duration: int, - thumb: Optional[PhotoSize] = None, mime_type: Optional[str] = None, file_size: Optional[int] = None, file_name: Optional[str] = None, @@ -88,7 +86,6 @@ class Video(_BaseThumbedMedium): file_id=file_id, file_unique_id=file_unique_id, file_size=file_size, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, ) diff --git a/telegram/_files/videonote.py b/telegram/_files/videonote.py index 463b717fe..87eaaf5fc 100644 --- a/telegram/_files/videonote.py +++ b/telegram/_files/videonote.py @@ -31,6 +31,9 @@ class VideoNote(_BaseThumbedMedium): Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`file_unique_id` is equal. + .. versionchanged:: NEXT.VERSION + |removed_thumb_note| + Args: file_id (:obj:`str`): Identifier for this file, which can be used to download or reuse the file. @@ -40,10 +43,6 @@ class VideoNote(_BaseThumbedMedium): length (:obj:`int`): Video width and height (diameter of the video message) as defined by sender. duration (:obj:`int`): Duration of the video in seconds as defined by sender. - thumb (:class:`telegram.PhotoSize`, optional): Video thumbnail. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail`. file_size (:obj:`int`, optional): File size in bytes. thumbnail (:class:`telegram.PhotoSize`, optional): Video thumbnail. @@ -73,7 +72,6 @@ class VideoNote(_BaseThumbedMedium): file_unique_id: str, length: int, duration: int, - thumb: Optional[PhotoSize] = None, file_size: Optional[int] = None, thumbnail: Optional[PhotoSize] = None, *, @@ -83,7 +81,6 @@ class VideoNote(_BaseThumbedMedium): file_id=file_id, file_unique_id=file_unique_id, file_size=file_size, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, ) diff --git a/telegram/_inline/inlinequery.py b/telegram/_inline/inlinequery.py index 1dc0d9f8f..63a73b8ac 100644 --- a/telegram/_inline/inlinequery.py +++ b/telegram/_inline/inlinequery.py @@ -145,8 +145,6 @@ class InlineQuery(TelegramObject): cache_time: Optional[int] = None, is_personal: Optional[bool] = None, next_offset: Optional[str] = None, - switch_pm_text: Optional[str] = None, - switch_pm_parameter: Optional[str] = None, button: Optional[InlineQueryResultsButton] = None, *, current_offset: Optional[str] = None, @@ -192,8 +190,6 @@ class InlineQuery(TelegramObject): cache_time=cache_time, is_personal=is_personal, next_offset=next_offset, - switch_pm_text=switch_pm_text, - switch_pm_parameter=switch_pm_parameter, button=button, read_timeout=read_timeout, write_timeout=write_timeout, diff --git a/telegram/_inline/inlinequeryresultarticle.py b/telegram/_inline/inlinequeryresultarticle.py index d82ee58c6..0fd31f127 100644 --- a/telegram/_inline/inlinequeryresultarticle.py +++ b/telegram/_inline/inlinequeryresultarticle.py @@ -23,10 +23,6 @@ from typing import TYPE_CHECKING, Optional from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._utils.types import JSONDict -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -39,6 +35,9 @@ class InlineQueryResultArticle(InlineQueryResult): Examples: :any:`Inline Bot ` + .. versionchanged:: NEXT.VERSION + Removed the deprecated arguments and attributes ``thumb_*``. + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -52,18 +51,6 @@ class InlineQueryResultArticle(InlineQueryResult): hide_url (:obj:`bool`, optional): Pass :obj:`True`, if you don't want the URL to be shown in the message. description (:obj:`str`, optional): Short description of the result. - thumb_url (:obj:`str`, optional): Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. - thumb_width (:obj:`int`, optional): Thumbnail width. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_width`. - thumb_height (:obj:`int`, optional): Thumbnail height. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_height`. thumbnail_url (:obj:`str`, optional): Url of the thumbnail for the result. .. versionadded:: 20.2 @@ -121,9 +108,6 @@ class InlineQueryResultArticle(InlineQueryResult): url: Optional[str] = None, hide_url: Optional[bool] = None, description: Optional[str] = None, - thumb_url: Optional[str] = None, - thumb_width: Optional[int] = None, - thumb_height: Optional[int] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None, @@ -141,66 +125,6 @@ class InlineQueryResultArticle(InlineQueryResult): self.url: Optional[str] = url self.hide_url: Optional[bool] = hide_url self.description: Optional[str] = description - self.thumbnail_url: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) - self.thumbnail_width: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_width, - new_arg=thumbnail_width, - deprecated_arg_name="thumb_width", - new_arg_name="thumbnail_width", - bot_api_version="6.6", - ) - self.thumbnail_height: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_height, - new_arg=thumbnail_height, - deprecated_arg_name="thumb_height", - new_arg_name="thumbnail_height", - bot_api_version="6.6", - ) - - @property - def thumb_url(self) -> Optional[str]: - """:obj:`str`: Optional. Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_width(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail width. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_width`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_width", - new_attr_name="thumbnail_width", - bot_api_version="6.6", - ) - return self.thumbnail_width - - @property - def thumb_height(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail height. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_height`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_height", - new_attr_name="thumbnail_height", - bot_api_version="6.6", - ) - return self.thumbnail_height + self.thumbnail_url: Optional[str] = thumbnail_url + self.thumbnail_width: Optional[int] = thumbnail_width + self.thumbnail_height: Optional[int] = thumbnail_height diff --git a/telegram/_inline/inlinequeryresultcontact.py b/telegram/_inline/inlinequeryresultcontact.py index 6a5653e41..ec68b1817 100644 --- a/telegram/_inline/inlinequeryresultcontact.py +++ b/telegram/_inline/inlinequeryresultcontact.py @@ -23,10 +23,6 @@ from typing import TYPE_CHECKING, Optional from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._utils.types import JSONDict -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -39,6 +35,9 @@ class InlineQueryResultContact(InlineQueryResult): Alternatively, you can use :attr:`input_message_content` to send a message with the specified content instead of the contact. + .. versionchanged:: NEXT.VERSION + |removed_thumb_wildcard_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -52,18 +51,6 @@ class InlineQueryResultContact(InlineQueryResult): to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the message to be sent instead of the contact. - thumb_url (:obj:`str`, optional): Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. - thumb_width (:obj:`int`, optional): Thumbnail width. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_width`. - thumb_height (:obj:`int`, optional): Thumbnail height. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_height`. thumbnail_url (:obj:`str`, optional): Url of the thumbnail for the result. .. versionadded:: 20.2 @@ -120,9 +107,6 @@ class InlineQueryResultContact(InlineQueryResult): last_name: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional["InputMessageContent"] = None, - thumb_url: Optional[str] = None, - thumb_width: Optional[int] = None, - thumb_height: Optional[int] = None, vcard: Optional[str] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, @@ -141,66 +125,6 @@ class InlineQueryResultContact(InlineQueryResult): self.vcard: Optional[str] = vcard self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - self.thumbnail_url: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) - self.thumbnail_width: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_width, - new_arg=thumbnail_width, - deprecated_arg_name="thumb_width", - new_arg_name="thumbnail_width", - bot_api_version="6.6", - ) - self.thumbnail_height: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_height, - new_arg=thumbnail_height, - deprecated_arg_name="thumb_height", - new_arg_name="thumbnail_height", - bot_api_version="6.6", - ) - - @property - def thumb_url(self) -> Optional[str]: - """:obj:`str`: Optional. Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_width(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail width. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_width`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_width", - new_attr_name="thumbnail_width", - bot_api_version="6.6", - ) - return self.thumbnail_width - - @property - def thumb_height(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail height. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_height`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_height", - new_attr_name="thumbnail_height", - bot_api_version="6.6", - ) - return self.thumbnail_height + self.thumbnail_url: Optional[str] = thumbnail_url + self.thumbnail_width: Optional[int] = thumbnail_width + self.thumbnail_height: Optional[int] = thumbnail_height diff --git a/telegram/_inline/inlinequeryresultdocument.py b/telegram/_inline/inlinequeryresultdocument.py index ac81a628f..9733a2171 100644 --- a/telegram/_inline/inlinequeryresultdocument.py +++ b/telegram/_inline/inlinequeryresultdocument.py @@ -25,10 +25,6 @@ from telegram._messageentity import MessageEntity from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.types import JSONDict, ODVInput -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -44,6 +40,9 @@ class InlineQueryResultDocument(InlineQueryResult): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_wildcard_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -66,18 +65,6 @@ class InlineQueryResultDocument(InlineQueryResult): to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the message to be sent instead of the file. - thumb_url (:obj:`str`, optional): URL of the thumbnail (JPEG only) for the file. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. - thumb_width (:obj:`int`, optional): Thumbnail width. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_width`. - thumb_height (:obj:`int`, optional): Thumbnail height. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_height`. thumbnail_url (:obj:`str`, optional): URL of the thumbnail (JPEG only) for the file. .. versionadded:: 20.2 @@ -150,9 +137,6 @@ class InlineQueryResultDocument(InlineQueryResult): description: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional["InputMessageContent"] = None, - thumb_url: Optional[str] = None, - thumb_width: Optional[int] = None, - thumb_height: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Optional[Sequence[MessageEntity]] = None, thumbnail_url: Optional[str] = None, @@ -175,66 +159,6 @@ class InlineQueryResultDocument(InlineQueryResult): self.description: Optional[str] = description self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - self.thumbnail_url: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) - self.thumbnail_width: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_width, - new_arg=thumbnail_width, - deprecated_arg_name="thumb_width", - new_arg_name="thumbnail_width", - bot_api_version="6.6", - ) - self.thumbnail_height: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_height, - new_arg=thumbnail_height, - deprecated_arg_name="thumb_height", - new_arg_name="thumbnail_height", - bot_api_version="6.6", - ) - - @property - def thumb_url(self) -> Optional[str]: - """:obj:`str`: Optional. URL of the thumbnail (JPEG only) for the file. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_width(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail width. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_width`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_width", - new_attr_name="thumbnail_width", - bot_api_version="6.6", - ) - return self.thumbnail_width - - @property - def thumb_height(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail height. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_height`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_height", - new_attr_name="thumbnail_height", - bot_api_version="6.6", - ) - return self.thumbnail_height + self.thumbnail_url: Optional[str] = thumbnail_url + self.thumbnail_width: Optional[int] = thumbnail_width + self.thumbnail_height: Optional[int] = thumbnail_height diff --git a/telegram/_inline/inlinequeryresultgif.py b/telegram/_inline/inlinequeryresultgif.py index 62db88b3d..905e1f643 100644 --- a/telegram/_inline/inlinequeryresultgif.py +++ b/telegram/_inline/inlinequeryresultgif.py @@ -25,10 +25,6 @@ from telegram._messageentity import MessageEntity from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.types import JSONDict, ODVInput -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -43,6 +39,9 @@ class InlineQueryResultGif(InlineQueryResult): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_wildcard_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -79,16 +78,6 @@ class InlineQueryResultGif(InlineQueryResult): to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the message to be sent instead of the GIF animation. - thumb_mime_type (:obj:`str`, optional): MIME type of the thumbnail, must be one of - ``'image/jpeg'``, ``'image/gif'``, or ``'video/mp4'``. Defaults to ``'image/jpeg'``. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_mime_type`. - thumb_url (:obj:`str`, optional): URL of the static (JPEG or GIF) or animated (MPEG4) - thumbnail for the result. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. Raises: :class:`ValueError`: If neither :paramref:`thumbnail_url` nor :paramref:`thumb_url` is @@ -148,10 +137,7 @@ class InlineQueryResultGif(InlineQueryResult): self, id: str, # pylint: disable=redefined-builtin gif_url: str, - # thumbnail_url is not optional in Telegram API, but we want to support thumb_url as well, - # so thumbnail_url may not be passed. We will raise ValueError manually if neither - # thumbnail_url nor thumb_url are passed - thumbnail_url: Optional[str] = None, + thumbnail_url: str, gif_width: Optional[int] = None, gif_height: Optional[int] = None, title: Optional[str] = None, @@ -160,31 +146,16 @@ class InlineQueryResultGif(InlineQueryResult): input_message_content: Optional["InputMessageContent"] = None, gif_duration: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb_mime_type: Optional[str] = None, caption_entities: Optional[Sequence[MessageEntity]] = None, thumbnail_mime_type: Optional[str] = None, - # thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url. - thumb_url: Optional[str] = None, *, api_kwargs: Optional[JSONDict] = None, ): - if not (thumbnail_url or thumb_url): - raise ValueError( - "You must pass either 'thumbnail_url' or 'thumb_url'. Note that 'thumb_url' is " - "deprecated." - ) - # Required super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs) with self._unfrozen(): self.gif_url: str = gif_url - self.thumbnail_url: str = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) + self.thumbnail_url: str = thumbnail_url # Optionals self.gif_width: Optional[int] = gif_width @@ -196,40 +167,4 @@ class InlineQueryResultGif(InlineQueryResult): self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities) self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - self.thumbnail_mime_type: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_mime_type, - new_arg=thumbnail_mime_type, - deprecated_arg_name="thumb_mime_type", - new_arg_name="thumbnail_mime_type", - bot_api_version="6.6", - ) - - @property - def thumb_url(self) -> str: - """:obj:`str`: URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the - result. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_mime_type(self) -> Optional[str]: - """:obj:`str`: Optional. Optional. MIME type of the thumbnail, must be one of - ``'image/jpeg'``, ``'image/gif'``, or ``'video/mp4'``. Defaults to ``'image/jpeg'``. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_mime_type`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_mime_type", - new_attr_name="thumbnail_mime_type", - bot_api_version="6.6", - ) - return self.thumbnail_mime_type + self.thumbnail_mime_type: Optional[str] = thumbnail_mime_type diff --git a/telegram/_inline/inlinequeryresultlocation.py b/telegram/_inline/inlinequeryresultlocation.py index 291aa5dd3..a885ec73e 100644 --- a/telegram/_inline/inlinequeryresultlocation.py +++ b/telegram/_inline/inlinequeryresultlocation.py @@ -24,10 +24,6 @@ from telegram import constants from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._utils.types import JSONDict -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) if TYPE_CHECKING: from telegram import InputMessageContent @@ -39,6 +35,9 @@ class InlineQueryResultLocation(InlineQueryResult): Alternatively, you can use :attr:`input_message_content` to send a message with the specified content instead of the location. + .. versionchanged:: NEXT.VERSION + |removed_thumb_wildcard_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -66,18 +65,6 @@ class InlineQueryResultLocation(InlineQueryResult): to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the message to be sent instead of the location. - thumb_url (:obj:`str`, optional): Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. - thumb_width (:obj:`int`, optional): Thumbnail width. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_width`. - thumb_height (:obj:`int`, optional): Thumbnail height. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_height`. thumbnail_url (:obj:`str`, optional): Url of the thumbnail for the result. .. versionadded:: 20.2 @@ -152,9 +139,6 @@ class InlineQueryResultLocation(InlineQueryResult): live_period: Optional[int] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional["InputMessageContent"] = None, - thumb_url: Optional[str] = None, - thumb_width: Optional[int] = None, - thumb_height: Optional[int] = None, horizontal_accuracy: Optional[float] = None, heading: Optional[int] = None, proximity_alert_radius: Optional[int] = None, @@ -175,75 +159,15 @@ class InlineQueryResultLocation(InlineQueryResult): self.live_period: Optional[int] = live_period self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - self.thumbnail_url: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) - self.thumbnail_width: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_width, - new_arg=thumbnail_width, - deprecated_arg_name="thumb_width", - new_arg_name="thumbnail_width", - bot_api_version="6.6", - ) - self.thumbnail_height: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_height, - new_arg=thumbnail_height, - deprecated_arg_name="thumb_height", - new_arg_name="thumbnail_height", - bot_api_version="6.6", - ) + self.thumbnail_url: Optional[str] = thumbnail_url + self.thumbnail_width: Optional[int] = thumbnail_width + self.thumbnail_height: Optional[int] = thumbnail_height self.horizontal_accuracy: Optional[float] = horizontal_accuracy self.heading: Optional[int] = heading self.proximity_alert_radius: Optional[int] = ( int(proximity_alert_radius) if proximity_alert_radius else None ) - @property - def thumb_url(self) -> Optional[str]: - """:obj:`str`: Optional. Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_width(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail width. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_width`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_width", - new_attr_name="thumbnail_width", - bot_api_version="6.6", - ) - return self.thumbnail_width - - @property - def thumb_height(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail height. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_height`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_height", - new_attr_name="thumbnail_height", - bot_api_version="6.6", - ) - return self.thumbnail_height - HORIZONTAL_ACCURACY: Final[int] = constants.LocationLimit.HORIZONTAL_ACCURACY """:const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY` diff --git a/telegram/_inline/inlinequeryresultmpeg4gif.py b/telegram/_inline/inlinequeryresultmpeg4gif.py index 287274332..c85b6e77c 100644 --- a/telegram/_inline/inlinequeryresultmpeg4gif.py +++ b/telegram/_inline/inlinequeryresultmpeg4gif.py @@ -25,10 +25,6 @@ from telegram._messageentity import MessageEntity from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.types import JSONDict, ODVInput -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -44,6 +40,9 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_wildcard_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -141,10 +140,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): self, id: str, # pylint: disable=redefined-builtin mpeg4_url: str, - # thumbnail_url is not optional in Telegram API, but we want to support thumb_url as well, - # so thumbnail_url may not be passed. We will raise ValueError manually if neither - # thumbnail_url nor thumb_url are passed - thumbnail_url: Optional[str] = None, + thumbnail_url: str, mpeg4_width: Optional[int] = None, mpeg4_height: Optional[int] = None, title: Optional[str] = None, @@ -153,31 +149,16 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): input_message_content: Optional["InputMessageContent"] = None, mpeg4_duration: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb_mime_type: Optional[str] = None, caption_entities: Optional[Sequence[MessageEntity]] = None, thumbnail_mime_type: Optional[str] = None, - # thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url. - thumb_url: Optional[str] = None, *, api_kwargs: Optional[JSONDict] = None, ): - if not (thumbnail_url or thumb_url): - raise ValueError( - "You must pass either 'thumbnail_url' or 'thumb_url'. Note that 'thumb_url' is " - "deprecated." - ) - # Required super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs) with self._unfrozen(): self.mpeg4_url: str = mpeg4_url - self.thumbnail_url: str = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) + self.thumbnail_url: str = thumbnail_url # Optional self.mpeg4_width: Optional[int] = mpeg4_width @@ -189,40 +170,4 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities) self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - self.thumbnail_mime_type: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_mime_type, - new_arg=thumbnail_mime_type, - deprecated_arg_name="thumb_mime_type", - new_arg_name="thumbnail_mime_type", - bot_api_version="6.6", - ) - - @property - def thumb_url(self) -> str: - """:obj:`str`: URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the - result. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_mime_type(self) -> Optional[str]: - """:obj:`str`: Optional. Optional. MIME type of the thumbnail, must be one of - ``'image/jpeg'``, ``'image/gif'``, or ``'video/mp4'``. Defaults to ``'image/jpeg'``. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_mime_type`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_mime_type", - new_attr_name="thumbnail_mime_type", - bot_api_version="6.6", - ) - return self.thumbnail_mime_type + self.thumbnail_mime_type: Optional[str] = thumbnail_mime_type diff --git a/telegram/_inline/inlinequeryresultphoto.py b/telegram/_inline/inlinequeryresultphoto.py index b27096162..7cf806df8 100644 --- a/telegram/_inline/inlinequeryresultphoto.py +++ b/telegram/_inline/inlinequeryresultphoto.py @@ -25,10 +25,6 @@ from telegram._messageentity import MessageEntity from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.types import JSONDict, ODVInput -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -43,6 +39,9 @@ class InlineQueryResultPhoto(InlineQueryResult): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_url_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -75,10 +74,6 @@ class InlineQueryResultPhoto(InlineQueryResult): to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the message to be sent instead of the photo. - thumb_url (:obj:`str`, optional): URL of the thumbnail for the photo. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. Raises: :class:`ValueError`: If neither :paramref:`thumbnail_url` nor :paramref:`thumb_url` is @@ -131,10 +126,7 @@ class InlineQueryResultPhoto(InlineQueryResult): self, id: str, # pylint: disable=redefined-builtin photo_url: str, - # thumbnail_url is not optional in Telegram API, but we want to support thumb_url as well, - # so thumbnail_url may not be passed. We will raise ValueError manually if neither - # thumbnail_url nor thumb_url are passed - thumbnail_url: Optional[str] = None, + thumbnail_url: str, photo_width: Optional[int] = None, photo_height: Optional[int] = None, title: Optional[str] = None, @@ -144,28 +136,14 @@ class InlineQueryResultPhoto(InlineQueryResult): input_message_content: Optional["InputMessageContent"] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Optional[Sequence[MessageEntity]] = None, - # thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url. - thumb_url: Optional[str] = None, *, api_kwargs: Optional[JSONDict] = None, ): - if not (thumbnail_url or thumb_url): - raise ValueError( - "You must pass either 'thumbnail_url' or 'thumb_url'. Note that 'thumb_url' is " - "deprecated." - ) - # Required super().__init__(InlineQueryResultType.PHOTO, id, api_kwargs=api_kwargs) with self._unfrozen(): self.photo_url: str = photo_url - self.thumbnail_url: str = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) + self.thumbnail_url: str = thumbnail_url # Optionals self.photo_width: Optional[int] = photo_width @@ -177,17 +155,3 @@ class InlineQueryResultPhoto(InlineQueryResult): self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities) self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - - @property - def thumb_url(self) -> Optional[str]: - """:obj:`str`: URL of the thumbnail for the photo. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url diff --git a/telegram/_inline/inlinequeryresultsbutton.py b/telegram/_inline/inlinequeryresultsbutton.py index 8b0572388..d15b9877d 100644 --- a/telegram/_inline/inlinequeryresultsbutton.py +++ b/telegram/_inline/inlinequeryresultsbutton.py @@ -16,7 +16,6 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=redefined-builtin """This module contains the class that represent a Telegram InlineQueryResultsButton.""" from typing import TYPE_CHECKING, Final, Optional diff --git a/telegram/_inline/inlinequeryresultvenue.py b/telegram/_inline/inlinequeryresultvenue.py index df2179f6e..32b61e357 100644 --- a/telegram/_inline/inlinequeryresultvenue.py +++ b/telegram/_inline/inlinequeryresultvenue.py @@ -23,10 +23,6 @@ from typing import TYPE_CHECKING, Optional from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup from telegram._inline.inlinequeryresult import InlineQueryResult from telegram._utils.types import JSONDict -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -43,6 +39,9 @@ class InlineQueryResultVenue(InlineQueryResult): Foursquare details and Google Pace details are mutually exclusive. However, this behaviour is undocumented and might be changed by Telegram. + .. versionchanged:: NEXT.VERSION + |removed_thumb_wildcard_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -63,18 +62,6 @@ class InlineQueryResultVenue(InlineQueryResult): to the message. input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the message to be sent instead of the venue. - thumb_url (:obj:`str`, optional): Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. - thumb_width (:obj:`int`, optional): Thumbnail width. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_width`. - thumb_height (:obj:`int`, optional): Thumbnail height. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_height`. thumbnail_url (:obj:`str`, optional): Url of the thumbnail for the result. .. versionadded:: 20.2 @@ -145,9 +132,6 @@ class InlineQueryResultVenue(InlineQueryResult): foursquare_type: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional["InputMessageContent"] = None, - thumb_url: Optional[str] = None, - thumb_width: Optional[int] = None, - thumb_height: Optional[int] = None, google_place_id: Optional[str] = None, google_place_type: Optional[str] = None, thumbnail_url: Optional[str] = None, @@ -171,66 +155,6 @@ class InlineQueryResultVenue(InlineQueryResult): self.google_place_type: Optional[str] = google_place_type self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - self.thumbnail_url: Optional[str] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) - self.thumbnail_width: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_width, - new_arg=thumbnail_width, - deprecated_arg_name="thumb_width", - new_arg_name="thumbnail_width", - bot_api_version="6.6", - ) - self.thumbnail_height: Optional[int] = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_height, - new_arg=thumbnail_height, - deprecated_arg_name="thumb_height", - new_arg_name="thumbnail_height", - bot_api_version="6.6", - ) - - @property - def thumb_url(self) -> Optional[str]: - """:obj:`str`: Optional. Url of the thumbnail for the result. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url - - @property - def thumb_width(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail width. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_width`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_width", - new_attr_name="thumbnail_width", - bot_api_version="6.6", - ) - return self.thumbnail_width - - @property - def thumb_height(self) -> Optional[int]: - """:obj:`str`: Optional. Thumbnail height. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_height`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_height", - new_attr_name="thumbnail_height", - bot_api_version="6.6", - ) - return self.thumbnail_height + self.thumbnail_url: Optional[str] = thumbnail_url + self.thumbnail_width: Optional[int] = thumbnail_width + self.thumbnail_height: Optional[int] = thumbnail_height diff --git a/telegram/_inline/inlinequeryresultvideo.py b/telegram/_inline/inlinequeryresultvideo.py index f0e5339d2..f7d87ab4a 100644 --- a/telegram/_inline/inlinequeryresultvideo.py +++ b/telegram/_inline/inlinequeryresultvideo.py @@ -25,10 +25,6 @@ from telegram._messageentity import MessageEntity from telegram._utils.argumentparsing import parse_sequence_arg from telegram._utils.defaultvalue import DEFAULT_NONE from telegram._utils.types import JSONDict, ODVInput -from telegram._utils.warnings_transition import ( - warn_about_deprecated_arg_return_new_arg, - warn_about_deprecated_attr_in_property, -) from telegram.constants import InlineQueryResultType if TYPE_CHECKING: @@ -48,6 +44,9 @@ class InlineQueryResultVideo(InlineQueryResult): .. seealso:: :wiki:`Working with Files and Media ` + .. versionchanged:: NEXT.VERSION + |removed_thumb_url_note| + Args: id (:obj:`str`): Unique identifier for this result, :tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`- @@ -89,10 +88,6 @@ class InlineQueryResultVideo(InlineQueryResult): message to be sent instead of the video. This field is required if ``InlineQueryResultVideo`` is used to send an HTML-page as a result (e.g., a YouTube video). - thumb_url (:obj:`str`, optional): URL of the thumbnail (JPEG only) for the video. - - .. deprecated:: 20.2 - |thumbargumentdeprecation| :paramref:`thumbnail_url`. Raises: :class:`ValueError`: If neither :paramref:`thumbnail_url` nor :paramref:`thumb_url` is @@ -156,13 +151,8 @@ class InlineQueryResultVideo(InlineQueryResult): id: str, # pylint: disable=redefined-builtin video_url: str, mime_type: str, - # thumbnail_url and title are not optional in Telegram API, but we want to support - # thumb_url as well, so thumbnail_url may not be passed if thumb_url is passed. - # We will raise ValueError manually if neither thumbnail_url nor thumb_url are passed. - thumbnail_url: Optional[str] = None, - # title had to be made optional because of thumbnail_url. This is compensated by raising - # TypeError manually if title is not passed. - title: Optional[str] = None, + thumbnail_url: str, + title: str, caption: Optional[str] = None, video_width: Optional[int] = None, video_height: Optional[int] = None, @@ -172,35 +162,15 @@ class InlineQueryResultVideo(InlineQueryResult): input_message_content: Optional["InputMessageContent"] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, caption_entities: Optional[Sequence[MessageEntity]] = None, - # thumb_url is not optional in Telegram API, but it is here, along with thumbnail_url. - thumb_url: Optional[str] = None, *, api_kwargs: Optional[JSONDict] = None, ): - if not (thumbnail_url or thumb_url): - raise ValueError( - "You must pass either 'thumbnail_url' or 'thumb_url'. Note that 'thumb_url' is " - "deprecated." - ) - - if title is None: - raise TypeError( - "InlineQueryResultVideo.__init__() missing a required argument: you forgot to pass" - " either 'title' or 'thumbnail_url'." - ) - # Required super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs) with self._unfrozen(): self.video_url: str = video_url self.mime_type: str = mime_type - self.thumbnail_url: str = warn_about_deprecated_arg_return_new_arg( - deprecated_arg=thumb_url, - new_arg=thumbnail_url, - deprecated_arg_name="thumb_url", - new_arg_name="thumbnail_url", - bot_api_version="6.6", - ) + self.thumbnail_url: str = thumbnail_url self.title: str = title # Optional @@ -213,17 +183,3 @@ class InlineQueryResultVideo(InlineQueryResult): self.description: Optional[str] = description self.reply_markup: Optional[InlineKeyboardMarkup] = reply_markup self.input_message_content: Optional[InputMessageContent] = input_message_content - - @property - def thumb_url(self) -> str: - """:obj:`str`: URL of the thumbnail (JPEG only) for the video. - - .. deprecated:: 20.2 - |thumbattributedeprecation| :attr:`thumbnail_url`. - """ - warn_about_deprecated_attr_in_property( - deprecated_attr_name="thumb_url", - new_attr_name="thumbnail_url", - bot_api_version="6.6", - ) - return self.thumbnail_url diff --git a/telegram/_keyboardbutton.py b/telegram/_keyboardbutton.py index 651279c08..7fe9810f7 100644 --- a/telegram/_keyboardbutton.py +++ b/telegram/_keyboardbutton.py @@ -24,9 +24,7 @@ from telegram._keyboardbuttonpolltype import KeyboardButtonPollType from telegram._keyboardbuttonrequest import KeyboardButtonRequestChat, KeyboardButtonRequestUser from telegram._telegramobject import TelegramObject from telegram._utils.types import JSONDict -from telegram._utils.warnings import warn from telegram._webappinfo import WebAppInfo -from telegram.warnings import PTBDeprecationWarning if TYPE_CHECKING: from telegram import Bot @@ -56,9 +54,9 @@ class KeyboardButton(TelegramObject): .. versionchanged:: 20.0 :attr:`web_app` is considered as well when comparing objects of this type in terms of equality. - .. deprecated:: 20.1 - :paramref:`request_user` and :paramref:`request_chat` will be considered as well when - comparing objects of this type in terms of equality in V21. + .. versionchanged:: NEXT.VERSION + :attr:`request_user` and :attr:`request_chat` are considered as well when + comparing objects of this type in terms of equality. Args: text (:obj:`str`): Text of the button. If none of the optional fields are used, it will be @@ -157,23 +155,12 @@ class KeyboardButton(TelegramObject): self.request_location, self.request_poll, self.web_app, + self.request_user, + self.request_chat, ) self._freeze() - def __eq__(self, other: object) -> bool: - warn( - "In v21, `request_user` and `request_chat` will be considered as well when comparing" - " KeyboardButton instances.", - PTBDeprecationWarning, - stacklevel=2, - ) - return super().__eq__(other) - - def __hash__(self) -> int: - # Intend: Added so support the own __eq__ function (which otherwise breaks hashing) - return super().__hash__() - @classmethod def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["KeyboardButton"]: """See :meth:`telegram.TelegramObject.de_json`.""" diff --git a/telegram/_message.py b/telegram/_message.py index 493afc3b5..d5048981e 100644 --- a/telegram/_message.py +++ b/telegram/_message.py @@ -68,7 +68,6 @@ from telegram._utils.types import ( ODVInput, ReplyMarkup, ) -from telegram._utils.warnings import warn from telegram._videochat import ( VideoChatEnded, VideoChatParticipantsInvited, @@ -79,7 +78,6 @@ from telegram._webappdata import WebAppData from telegram._writeaccessallowed import WriteAccessAllowed from telegram.constants import MessageAttachmentType, ParseMode from telegram.helpers import escape_markdown -from telegram.warnings import PTBDeprecationWarning if TYPE_CHECKING: from telegram import ( @@ -598,10 +596,9 @@ class Message(TelegramObject): .. |custom_emoji_formatting_note| replace:: Custom emoji entities will be ignored by this function. Instead, the supplied replacement for the emoji will be used. - .. |custom_emoji_md1_deprecation| replace:: Since custom emoji entities are not supported by - :attr:`~telegram.constants.ParseMode.MARKDOWN`, this method will raise a - :exc:`ValueError` in future versions instead of falling back to the supplied replacement - for the emoji. + .. |custom_emoji_no_md1_support| replace:: Since custom emoji entities are not supported by + :attr:`~telegram.constants.ParseMode.MARKDOWN`, this method now raises a + :exc:`ValueError` when encountering a custom emoji. """ # fmt: on @@ -1423,7 +1420,6 @@ class Message(TelegramObject): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -1465,7 +1461,6 @@ class Message(TelegramObject): reply_to_message_id=reply_to_message_id, reply_markup=reply_markup, parse_mode=parse_mode, - thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, filename=filename, @@ -1487,7 +1482,6 @@ class Message(TelegramObject): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, disable_content_type_detection: Optional[bool] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, @@ -1532,7 +1526,6 @@ class Message(TelegramObject): connect_timeout=connect_timeout, pool_timeout=pool_timeout, parse_mode=parse_mode, - thumb=thumb, api_kwargs=api_kwargs, disable_content_type_detection=disable_content_type_detection, allow_sending_without_reply=allow_sending_without_reply, @@ -1548,7 +1541,6 @@ class Message(TelegramObject): duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_notification: DVInput[bool] = DEFAULT_NONE, @@ -1592,7 +1584,6 @@ class Message(TelegramObject): duration=duration, width=width, height=height, - thumb=thumb, caption=caption, parse_mode=parse_mode, disable_notification=disable_notification, @@ -1675,7 +1666,6 @@ class Message(TelegramObject): height: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, supports_streaming: Optional[bool] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -1723,7 +1713,6 @@ class Message(TelegramObject): height=height, parse_mode=parse_mode, supports_streaming=supports_streaming, - thumb=thumb, api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, @@ -1742,7 +1731,6 @@ class Message(TelegramObject): disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, message_thread_id: Optional[int] = None, @@ -1785,7 +1773,6 @@ class Message(TelegramObject): write_timeout=write_timeout, connect_timeout=connect_timeout, pool_timeout=pool_timeout, - thumb=thumb, api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, filename=filename, @@ -3558,24 +3545,17 @@ class Message(TelegramObject): insert = f"||{escaped_text}||" elif entity.type == MessageEntity.CUSTOM_EMOJI: if version == 1: - # this ensures compatibility to previous PTB versions - insert = escaped_text - warn( - "Custom emoji entities are not supported for Markdown version 1. " - "Future version of PTB will raise a ValueError instead of falling " - "back to the alternative standard emoji.", - stacklevel=3, - category=PTBDeprecationWarning, + raise ValueError( + "Custom emoji entities are not supported for Markdown version 1" ) - else: - # This should never be needed because ids are numeric but the documentation - # specifically mentions it so here we are - custom_emoji_id = escape_markdown( - entity.custom_emoji_id, - version=version, - entity_type=MessageEntity.CUSTOM_EMOJI, - ) - insert = f"![{escaped_text}](tg://emoji?id={custom_emoji_id})" + # This should never be needed because ids are numeric but the documentation + # specifically mentions it so here we are + custom_emoji_id = escape_markdown( + entity.custom_emoji_id, + version=version, + entity_type=MessageEntity.CUSTOM_EMOJI, + ) + insert = f"![{escaped_text}](tg://emoji?id={custom_emoji_id})" else: insert = escaped_text @@ -3624,8 +3604,8 @@ class Message(TelegramObject): * |custom_emoji_formatting_note| - .. deprecated:: 20.3 - |custom_emoji_md1_deprecation| + .. versionchanged:: NEXT.VERSION + |custom_emoji_no_md1_support| Returns: :obj:`str`: Message text with entities formatted as Markdown. @@ -3671,8 +3651,8 @@ class Message(TelegramObject): * |custom_emoji_formatting_note| - .. deprecated:: 20.3 - |custom_emoji_md1_deprecation| + .. versionchanged:: NEXT.VERSION + |custom_emoji_no_md1_support| Returns: :obj:`str`: Message text with entities formatted as Markdown. @@ -3718,8 +3698,8 @@ class Message(TelegramObject): * |custom_emoji_formatting_note| - .. deprecated:: 20.3 - |custom_emoji_md1_deprecation| + .. versionchanged:: NEXT.VERSION + |custom_emoji_no_md1_support| Returns: :obj:`str`: Message caption with caption entities formatted as Markdown. @@ -3767,8 +3747,8 @@ class Message(TelegramObject): * |custom_emoji_formatting_note| - .. deprecated:: 20.3 - |custom_emoji_md1_deprecation| + .. versionchanged:: NEXT.VERSION + |custom_emoji_no_md1_support| Returns: :obj:`str`: Message caption with caption entities formatted as Markdown. diff --git a/telegram/_user.py b/telegram/_user.py index 7c5be15d4..20e777ecc 100644 --- a/telegram/_user.py +++ b/telegram/_user.py @@ -555,7 +555,6 @@ class User(TelegramObject): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -593,7 +592,6 @@ class User(TelegramObject): reply_to_message_id=reply_to_message_id, reply_markup=reply_markup, parse_mode=parse_mode, - thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, filename=filename, @@ -751,7 +749,6 @@ class User(TelegramObject): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, disable_content_type_detection: Optional[bool] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, @@ -792,7 +789,6 @@ class User(TelegramObject): connect_timeout=connect_timeout, pool_timeout=pool_timeout, parse_mode=parse_mode, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, disable_content_type_detection=disable_content_type_detection, @@ -1005,7 +1001,6 @@ class User(TelegramObject): duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_notification: DVInput[bool] = DEFAULT_NONE, @@ -1044,7 +1039,6 @@ class User(TelegramObject): duration=duration, width=width, height=height, - thumb=thumb, caption=caption, parse_mode=parse_mode, disable_notification=disable_notification, @@ -1123,7 +1117,6 @@ class User(TelegramObject): height: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, supports_streaming: Optional[bool] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -1167,7 +1160,6 @@ class User(TelegramObject): height=height, parse_mode=parse_mode, supports_streaming=supports_streaming, - thumb=thumb, thumbnail=thumbnail, api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, @@ -1247,7 +1239,6 @@ class User(TelegramObject): disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, message_thread_id: Optional[int] = None, @@ -1285,7 +1276,6 @@ class User(TelegramObject): write_timeout=write_timeout, connect_timeout=connect_timeout, pool_timeout=pool_timeout, - thumb=thumb, api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, filename=filename, diff --git a/telegram/_utils/warnings_transition.py b/telegram/_utils/warnings_transition.py index 2e3b0ebad..c3799a125 100644 --- a/telegram/_utils/warnings_transition.py +++ b/telegram/_utils/warnings_transition.py @@ -85,23 +85,3 @@ def warn_about_deprecated_attr_in_property( PTBDeprecationWarning, stacklevel=stacklevel + 1, ) - - -def warn_about_thumb_return_thumbnail( - deprecated_arg: Any, - new_arg: Any, - stacklevel: int = 2, - warn_callback: Callable[[str, Type[Warning], int], None] = warn, -) -> Any: - """A helper function to warn about using a deprecated 'thumb' argument and return it or the - new 'thumbnail' argument, introduced in API 6.6. - """ - return warn_about_deprecated_arg_return_new_arg( - deprecated_arg=deprecated_arg, - new_arg=new_arg, - warn_callback=warn_callback, - deprecated_arg_name="thumb", - new_arg_name="thumbnail", - bot_api_version="6.6", - stacklevel=stacklevel + 1, - ) diff --git a/telegram/_version.py b/telegram/_version.py index 7300f1aeb..fafbc7330 100644 --- a/telegram/_version.py +++ b/telegram/_version.py @@ -62,6 +62,4 @@ __version__: Final[str] = str(__version_info__) from telegram import constants # noqa: E402 # pylint: disable=wrong-import-position __bot_api_version__: Final[str] = constants.BOT_API_VERSION -__bot_api_version_info__: Final[ - constants._BotAPIVersion -] = constants.BOT_API_VERSION_INFO # pylint: disable=protected-access +__bot_api_version_info__: Final[constants._BotAPIVersion] = constants.BOT_API_VERSION_INFO diff --git a/telegram/ext/_extbot.py b/telegram/ext/_extbot.py index f60ced8e4..a302d9b0c 100644 --- a/telegram/ext/_extbot.py +++ b/telegram/ext/_extbot.py @@ -147,6 +147,9 @@ class ExtBot(Bot, Generic[RLARGS]): :attr:`bot.callback_data_cache.maxsize ` to access the size of the cache. + .. versionchanged:: NEXT.VERSION + Removed deprecated methods ``set_sticker_set_thumb`` and ``setStickerSetThumb``. + Args: defaults (:class:`telegram.ext.Defaults`, optional): An object containing default values to be used if not set explicitly in the bot methods. @@ -732,14 +735,7 @@ class ExtBot(Bot, Generic[RLARGS]): self, user_id: Union[str, int], name: str, - emojis: Optional[str] = None, # Was made optional for compatibility reasons - png_sticker: Optional[FileInput] = None, - mask_position: Optional[MaskPosition] = None, - tgs_sticker: Optional[FileInput] = None, - webm_sticker: Optional[FileInput] = None, - sticker: Optional[ - InputSticker - ] = None, # Actually a required param, but is optional for compat. + sticker: Optional[InputSticker], *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -752,11 +748,6 @@ class ExtBot(Bot, Generic[RLARGS]): user_id=user_id, name=name, sticker=sticker, - emojis=emojis, - png_sticker=png_sticker, - mask_position=mask_position, - tgs_sticker=tgs_sticker, - webm_sticker=webm_sticker, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -801,8 +792,6 @@ class ExtBot(Bot, Generic[RLARGS]): cache_time: Optional[int] = None, is_personal: Optional[bool] = None, next_offset: Optional[str] = None, - switch_pm_text: Optional[str] = None, - switch_pm_parameter: Optional[str] = None, button: Optional[InlineQueryResultsButton] = None, *, current_offset: Optional[str] = None, @@ -819,8 +808,6 @@ class ExtBot(Bot, Generic[RLARGS]): cache_time=cache_time, is_personal=is_personal, next_offset=next_offset, - switch_pm_text=switch_pm_text, - switch_pm_parameter=switch_pm_parameter, current_offset=current_offset, read_timeout=read_timeout, write_timeout=write_timeout, @@ -1063,16 +1050,9 @@ class ExtBot(Bot, Generic[RLARGS]): user_id: Union[str, int], name: str, title: str, - emojis: Optional[str] = None, # Was made optional for compatibility purposes - png_sticker: Optional[FileInput] = None, - mask_position: Optional[MaskPosition] = None, - tgs_sticker: Optional[FileInput] = None, - webm_sticker: Optional[FileInput] = None, + stickers: Optional[Sequence[InputSticker]], + sticker_format: Optional[str], sticker_type: Optional[str] = None, - stickers: Optional[ - Sequence[InputSticker] - ] = None, # Actually a required param. Optional for compat. - sticker_format: Optional[str] = None, # Actually a required param. Optional for compat. needs_repainting: Optional[bool] = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1088,13 +1068,8 @@ class ExtBot(Bot, Generic[RLARGS]): title=title, stickers=stickers, sticker_format=sticker_format, - needs_repainting=needs_repainting, - emojis=emojis, - png_sticker=png_sticker, - mask_position=mask_position, - tgs_sticker=tgs_sticker, - webm_sticker=webm_sticker, sticker_type=sticker_type, + needs_repainting=needs_repainting, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2179,7 +2154,6 @@ class ExtBot(Bot, Generic[RLARGS]): duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, - thumb: Optional[FileInput] = None, caption: Optional[str] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, disable_notification: DVInput[bool] = DEFAULT_NONE, @@ -2206,7 +2180,6 @@ class ExtBot(Bot, Generic[RLARGS]): duration=duration, width=width, height=height, - thumb=thumb, caption=caption, parse_mode=parse_mode, disable_notification=disable_notification, @@ -2238,7 +2211,6 @@ class ExtBot(Bot, Generic[RLARGS]): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -2264,7 +2236,6 @@ class ExtBot(Bot, Generic[RLARGS]): reply_to_message_id=reply_to_message_id, reply_markup=reply_markup, parse_mode=parse_mode, - thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, @@ -2387,7 +2358,6 @@ class ExtBot(Bot, Generic[RLARGS]): reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, - thumb: Optional[FileInput] = None, disable_content_type_detection: Optional[bool] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, @@ -2411,7 +2381,6 @@ class ExtBot(Bot, Generic[RLARGS]): reply_to_message_id=reply_to_message_id, reply_markup=reply_markup, parse_mode=parse_mode, - thumb=thumb, disable_content_type_detection=disable_content_type_detection, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, @@ -2859,7 +2828,6 @@ class ExtBot(Bot, Generic[RLARGS]): height: Optional[int] = None, parse_mode: ODVInput[str] = DEFAULT_NONE, supports_streaming: Optional[bool] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Optional[Sequence["MessageEntity"]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, @@ -2887,7 +2855,6 @@ class ExtBot(Bot, Generic[RLARGS]): height=height, parse_mode=parse_mode, supports_streaming=supports_streaming, - thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, @@ -2911,7 +2878,6 @@ class ExtBot(Bot, Generic[RLARGS]): disable_notification: DVInput[bool] = DEFAULT_NONE, reply_to_message_id: Optional[int] = None, reply_markup: Optional[ReplyMarkup] = None, - thumb: Optional[FileInput] = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, message_thread_id: Optional[int] = None, @@ -2933,7 +2899,6 @@ class ExtBot(Bot, Generic[RLARGS]): disable_notification=disable_notification, reply_to_message_id=reply_to_message_id, reply_markup=reply_markup, - thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, message_thread_id=message_thread_id, @@ -3294,30 +3259,6 @@ class ExtBot(Bot, Generic[RLARGS]): api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args), ) - async def set_sticker_set_thumb( - self, - name: str, - user_id: Union[str, int], - thumb: Optional[FileInput] = None, - *, - read_timeout: ODVInput[float] = DEFAULT_NONE, - write_timeout: ODVInput[float] = DEFAULT_NONE, - connect_timeout: ODVInput[float] = DEFAULT_NONE, - pool_timeout: ODVInput[float] = DEFAULT_NONE, - api_kwargs: Optional[JSONDict] = None, - rate_limit_args: Optional[RLARGS] = None, - ) -> bool: - return await super().set_sticker_set_thumb( - name=name, - user_id=user_id, - thumb=thumb, - read_timeout=read_timeout, - write_timeout=write_timeout, - connect_timeout=connect_timeout, - pool_timeout=pool_timeout, - api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args), - ) - async def set_webhook( self, url: str, @@ -3509,11 +3450,8 @@ class ExtBot(Bot, Generic[RLARGS]): async def upload_sticker_file( self, user_id: Union[str, int], - png_sticker: Optional[ - FileInput - ] = None, # Deprecated since bot api 6.6. Optional for compatiblity. - sticker: Optional[FileInput] = None, # Actually required, but optional for compatibility. - sticker_format: Optional[str] = None, # Actually required, but optional for compatibility. + sticker: Optional[FileInput], + sticker_format: Optional[str], *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -3526,7 +3464,6 @@ class ExtBot(Bot, Generic[RLARGS]): user_id=user_id, sticker=sticker, sticker_format=sticker_format, - png_sticker=png_sticker, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -3864,7 +3801,6 @@ class ExtBot(Bot, Generic[RLARGS]): addStickerToSet = add_sticker_to_set setStickerPositionInSet = set_sticker_position_in_set deleteStickerFromSet = delete_sticker_from_set - setStickerSetThumb = set_sticker_set_thumb setStickerSetThumbnail = set_sticker_set_thumbnail setPassportDataErrors = set_passport_data_errors sendPoll = send_poll diff --git a/tests/_files/test_animation.py b/tests/_files/test_animation.py index 8f32386be..23ec3b50a 100644 --- a/tests/_files/test_animation.py +++ b/tests/_files/test_animation.py @@ -31,10 +31,6 @@ from tests.auxil.bot_method_checks import ( check_shortcut_call, check_shortcut_signature, ) -from tests.auxil.deprecations import ( - check_thumb_deprecation_warning_for_method_args, - check_thumb_deprecation_warnings_for_args_and_attrs, -) from tests.auxil.files import data_file from tests.auxil.slots import mro_slots @@ -86,18 +82,6 @@ class TestAnimationWithoutRequest(TestAnimationBase): assert animation.file_name.startswith("game.gif") == self.file_name.startswith("game.gif") assert isinstance(animation.thumbnail, PhotoSize) - def test_thumb_property_deprecation_warning(self, recwarn): - animation = Animation( - self.animation_file_id, - self.animation_file_unique_id, - thumb=object(), - width=self.width, - height=self.height, - duration=self.duration, - ) - assert animation.thumb is animation.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_de_json(self, bot, animation): json_dict = { "file_id": self.animation_file_id, @@ -194,28 +178,6 @@ class TestAnimationWithoutRequest(TestAnimationBase): monkeypatch.setattr(bot.request, "post", make_assertion) assert await bot.send_animation(animation=animation, chat_id=chat_id) - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_send_animation_thumb_deprecation_warning( - self, recwarn, monkeypatch, bot_class, bot, raw_bot, chat_id, animation - ): - async def make_assertion(url, request_data: RequestData, *args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - - monkeypatch.setattr(bot.request, "post", make_assertion) - await bot.send_animation(chat_id, animation, thumb="thumb") - check_thumb_deprecation_warning_for_method_args(recwarn, __file__) - - async def test_send_animation_with_local_files_throws_error_with_different_thumb_and_thumbnail( - self, bot, chat_id - ): - file = data_file("telegram.jpg") - different_file = data_file("telegram_no_standard_header.jpg") - - with pytest.raises(ValueError, match="different entities as 'thumb' and 'thumbnail'"): - await bot.send_animation(chat_id, file, thumbnail=file, thumb=different_file) - async def test_get_file_instance_method(self, monkeypatch, animation): async def make_assertion(*_, **kwargs): return kwargs["file_id"] == animation.file_id diff --git a/tests/_files/test_audio.py b/tests/_files/test_audio.py index 574650f1a..3ea394d0b 100644 --- a/tests/_files/test_audio.py +++ b/tests/_files/test_audio.py @@ -31,10 +31,6 @@ from tests.auxil.bot_method_checks import ( check_shortcut_call, check_shortcut_signature, ) -from tests.auxil.deprecations import ( - check_thumb_deprecation_warning_for_method_args, - check_thumb_deprecation_warnings_for_args_and_attrs, -) from tests.auxil.files import data_file from tests.auxil.slots import mro_slots @@ -93,11 +89,6 @@ class TestAudioWithoutRequest(TestAudioBase): assert audio.thumbnail.width == self.thumb_width assert audio.thumbnail.height == self.thumb_height - def test_thumb_property_deprecation_warning(self, recwarn): - audio = Audio(self.audio_file_id, self.audio_file_unique_id, self.duration, thumb=object()) - assert audio.thumb is audio.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_de_json(self, bot, audio): json_dict = { "file_id": self.audio_file_id, @@ -161,19 +152,6 @@ class TestAudioWithoutRequest(TestAudioBase): monkeypatch.setattr(bot.request, "post", make_assertion) assert await bot.send_audio(audio=audio, chat_id=chat_id) - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_send_audio_thumb_deprecation_warning( - self, recwarn, monkeypatch, bot_class, bot, raw_bot, chat_id, audio - ): - async def make_assertion(url, request_data: RequestData, *args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - - monkeypatch.setattr(bot.request, "post", make_assertion) - await bot.send_audio(chat_id, audio, thumb="thumb") - check_thumb_deprecation_warning_for_method_args(recwarn, __file__) - async def test_send_audio_custom_filename(self, bot, chat_id, audio_file, monkeypatch): async def make_assertion(url, request_data: RequestData, *args, **kwargs): return next(iter(request_data.multipart_data.values()))[0] == "custom_filename" @@ -205,15 +183,6 @@ class TestAudioWithoutRequest(TestAudioBase): finally: bot._local_mode = False - async def test_send_audio_with_local_files_throws_error_with_different_thumb_and_thumbnail( - self, bot, chat_id - ): - file = data_file("telegram.jpg") - different_file = data_file("telegram_no_standard_header.jpg") - - with pytest.raises(ValueError, match="different entities as 'thumb' and 'thumbnail'"): - await bot.send_audio(chat_id, file, thumbnail=file, thumb=different_file) - async def test_get_file_instance_method(self, monkeypatch, audio): async def make_assertion(*_, **kwargs): return kwargs["file_id"] == audio.file_id diff --git a/tests/_files/test_document.py b/tests/_files/test_document.py index 4ab040e14..f5ccdbeb8 100644 --- a/tests/_files/test_document.py +++ b/tests/_files/test_document.py @@ -31,10 +31,6 @@ from tests.auxil.bot_method_checks import ( check_shortcut_call, check_shortcut_signature, ) -from tests.auxil.deprecations import ( - check_thumb_deprecation_warning_for_method_args, - check_thumb_deprecation_warnings_for_args_and_attrs, -) from tests.auxil.files import data_file from tests.auxil.slots import mro_slots @@ -85,11 +81,6 @@ class TestDocumentWithoutRequest(TestDocumentBase): assert document.thumbnail.width == self.thumb_width assert document.thumbnail.height == self.thumb_height - def test_thumb_property_deprecation_warning(self, recwarn): - document = Document(file_id="file_id", file_unique_id="file_unique_id", thumb=object()) - assert document.thumb is document.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_de_json(self, bot, document): json_dict = { "file_id": self.document_file_id, @@ -160,19 +151,6 @@ class TestDocumentWithoutRequest(TestDocumentBase): assert message - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_send_document_thumb_deprecation_warning( - self, recwarn, monkeypatch, bot_class, bot, raw_bot, chat_id, document - ): - async def make_assertion(url, request_data: RequestData, *args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - - monkeypatch.setattr(bot.request, "post", make_assertion) - await bot.send_document(chat_id, document, thumb="thumb") - check_thumb_deprecation_warning_for_method_args(recwarn, __file__) - @pytest.mark.parametrize("local_mode", [True, False]) async def test_send_document_local_files(self, monkeypatch, bot, chat_id, local_mode): try: @@ -199,15 +177,6 @@ class TestDocumentWithoutRequest(TestDocumentBase): finally: bot._local_mode = False - async def test_send_document_with_local_files_throws_error_with_different_thumb_and_thumbnail( - self, bot, chat_id - ): - file = data_file("telegram.jpg") - different_file = data_file("telegram_no_standard_header.jpg") - - with pytest.raises(ValueError, match="different entities as 'thumb' and 'thumbnail'"): - await bot.send_document(chat_id, file, thumbnail=file, thumb=different_file) - async def test_get_file_instance_method(self, monkeypatch, document): async def make_assertion(*_, **kwargs): return kwargs["file_id"] == document.file_id diff --git a/tests/_files/test_inputmedia.py b/tests/_files/test_inputmedia.py index bade46cf2..f00dd1656 100644 --- a/tests/_files/test_inputmedia.py +++ b/tests/_files/test_inputmedia.py @@ -46,8 +46,6 @@ from tests.auxil.slots import mro_slots # noinspection PyUnresolvedReferences from tests.test_forum import emoji_id, real_topic # noqa: F401 -from ..auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs - # noinspection PyUnresolvedReferences from .test_audio import audio, audio_file # noqa: F401 @@ -160,14 +158,8 @@ class TestInputMediaVideoWithoutRequest(TestInputMediaVideoBase): assert input_media_video.caption_entities == tuple(self.caption_entities) assert input_media_video.supports_streaming == self.supports_streaming assert isinstance(input_media_video.thumbnail, InputFile) - assert input_media_video.thumb is input_media_video.thumbnail assert input_media_video.has_spoiler == self.has_spoiler - def test_thumb_property_deprecation_warning(self, recwarn): - input_media_video = InputMediaVideo(self.media, thumb=object()) - assert input_media_video.thumb is input_media_video.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_caption_entities_always_tuple(self): input_media_video = InputMediaVideo(self.media) assert input_media_video.caption_entities == () @@ -211,14 +203,6 @@ class TestInputMediaVideoWithoutRequest(TestInputMediaVideoBase): assert input_media_video.media == data_file("telegram.mp4").as_uri() assert input_media_video.thumbnail == data_file("telegram.jpg").as_uri() - def test_with_local_files_throws_exception_with_different_thumb_and_thumbnail(self): - with pytest.raises(ValueError, match="You passed different entities as 'thumb' and "): - InputMediaVideo( - data_file("telegram.mp4"), - thumbnail=data_file("telegram.jpg"), - thumb=data_file("telegram_no_standard_header.jpg"), - ) - class TestInputMediaPhotoBase: type_ = "photo" @@ -304,14 +288,8 @@ class TestInputMediaAnimationWithoutRequest(TestInputMediaAnimationBase): assert input_media_animation.parse_mode == self.parse_mode assert input_media_animation.caption_entities == tuple(self.caption_entities) assert isinstance(input_media_animation.thumbnail, InputFile) - assert input_media_animation.thumb is input_media_animation.thumbnail assert input_media_animation.has_spoiler == self.has_spoiler - def test_thumb_property_deprecation_warning(self, recwarn): - input_media_animation = InputMediaAnimation(self.media, thumb=object()) - assert input_media_animation.thumb is input_media_animation.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_caption_entities_always_tuple(self): input_media_animation = InputMediaAnimation(self.media) assert input_media_animation.caption_entities == () @@ -351,14 +329,6 @@ class TestInputMediaAnimationWithoutRequest(TestInputMediaAnimationBase): assert input_media_animation.media == data_file("telegram.mp4").as_uri() assert input_media_animation.thumbnail == data_file("telegram.jpg").as_uri() - def test_with_local_files_throws_exception_with_different_thumb_and_thumbnail(self): - with pytest.raises(ValueError, match="You passed different entities as 'thumb' and "): - InputMediaAnimation( - data_file("telegram.mp4"), - thumbnail=data_file("telegram.jpg"), - thumb=data_file("telegram_no_standard_header.jpg"), - ) - class TestInputMediaAudioBase: type_ = "audio" @@ -388,12 +358,6 @@ class TestInputMediaAudioWithoutRequest(TestInputMediaAudioBase): assert input_media_audio.parse_mode == self.parse_mode assert input_media_audio.caption_entities == tuple(self.caption_entities) assert isinstance(input_media_audio.thumbnail, InputFile) - assert input_media_audio.thumb is input_media_audio.thumbnail - - def test_thumb_property_deprecation_warning(self, recwarn): - input_media_audio = InputMediaAudio(self.media, thumb=object()) - assert input_media_audio.thumb is input_media_audio.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) def test_caption_entities_always_tuple(self): input_media_audio = InputMediaAudio(self.media) @@ -436,14 +400,6 @@ class TestInputMediaAudioWithoutRequest(TestInputMediaAudioBase): assert input_media_audio.media == data_file("telegram.mp4").as_uri() assert input_media_audio.thumbnail == data_file("telegram.jpg").as_uri() - def test_with_local_files_throws_exception_with_different_thumb_and_thumbnail(self): - with pytest.raises(ValueError, match="You passed different entities as 'thumb' and "): - InputMediaAudio( - data_file("telegram.mp4"), - thumbnail=data_file("telegram.jpg"), - thumb=data_file("telegram_no_standard_header.jpg"), - ) - class TestInputMediaDocumentBase: type_ = "document" @@ -472,12 +428,6 @@ class TestInputMediaDocumentWithoutRequest(TestInputMediaDocumentBase): == self.disable_content_type_detection ) assert isinstance(input_media_document.thumbnail, InputFile) - assert input_media_document.thumb is input_media_document.thumbnail - - def test_thumb_property_deprecation_warning(self, recwarn): - input_media_document = InputMediaDocument(self.media, thumb=object()) - assert input_media_document.thumb is input_media_document.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) def test_caption_entities_always_tuple(self): input_media_document = InputMediaDocument(self.media) @@ -518,14 +468,6 @@ class TestInputMediaDocumentWithoutRequest(TestInputMediaDocumentBase): assert input_media_document.media == data_file("telegram.mp4").as_uri() assert input_media_document.thumbnail == data_file("telegram.jpg").as_uri() - def test_with_local_files_throws_exception_with_different_thumb_and_thumbnail(self): - with pytest.raises(ValueError, match="You passed different entities as 'thumb' and "): - InputMediaDocument( - data_file("telegram.mp4"), - thumbnail=data_file("telegram.jpg"), - thumb=data_file("telegram_no_standard_header.jpg"), - ) - @pytest.fixture(scope="module") def media_group(photo, thumb): # noqa: F811 diff --git a/tests/_files/test_sticker.py b/tests/_files/test_sticker.py index c29d33d9b..c6318255e 100644 --- a/tests/_files/test_sticker.py +++ b/tests/_files/test_sticker.py @@ -38,13 +38,11 @@ from telegram import ( from telegram.constants import StickerFormat from telegram.error import BadRequest, TelegramError from telegram.request import RequestData -from telegram.warnings import PTBDeprecationWarning from tests.auxil.bot_method_checks import ( check_defaults_handling, check_shortcut_call, check_shortcut_signature, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.files import data_file from tests.auxil.slots import mro_slots @@ -150,20 +148,6 @@ class TestStickerWithoutRequest(TestStickerBase): # we need to be a premium TG user to send a premium sticker, so the below is not tested # assert sticker.premium_animation == self.premium_animation - def test_thumb_property_deprecation_warning(self, recwarn): - sticker = Sticker( - file_id="id", - file_unique_id="unique_id", - width=1, - height=1, - thumb=object(), - is_animated=False, - is_video=False, - type=Sticker.REGULAR, - ) - assert sticker.thumb is sticker.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_to_dict(self, sticker): sticker_dict = sticker.to_dict() @@ -548,19 +532,6 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'" assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot" - def test_thumb_property_deprecation_warning(self, recwarn): - sticker_set = StickerSet( - name=self.name, - title=self.title, - is_animated=self.is_animated, - stickers=self.stickers, - is_video=self.is_video, - sticker_type=self.sticker_type, - thumb=object(), - ) - assert sticker_set.thumb is sticker_set.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_de_json(self, bot, sticker): name = f"test_by_{bot.username}" json_dict = { @@ -637,34 +608,6 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): assert a != e assert hash(a) != hash(e) - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_upload_sticker_file_warning( - self, bot, raw_bot, monkeypatch, chat_id, recwarn, bot_class - ): - async def make_assertion(*args, **kwargs): - return {"file_id": "file_id", "file_unique_id": "file_unique_id"} - - bot = raw_bot if bot_class == "Bot" else bot - monkeypatch.setattr(bot, "_post", make_assertion) - - await bot.upload_sticker_file(chat_id, "png_sticker_file_id") - assert len(recwarn) == 1 - assert "Since Bot API 6.6, the parameter" in str(recwarn[0].message) - assert recwarn[0].category is PTBDeprecationWarning - assert recwarn[0].filename == __file__ - - async def test_upload_sticker_file_missing_required_args(self, bot, chat_id): - with pytest.raises(TypeError, match="are required, please pass them as well"): - await bot.upload_sticker_file(chat_id) - with pytest.raises(TypeError, match="are required, please pass them as well"): - await bot.upload_sticker_file(chat_id, sticker="something") - - async def test_upload_sticker_file_mutually_exclusive(self, bot, chat_id): - with pytest.raises(TypeError, match="mutually exclusive with the deprecated parameter"): - await bot.upload_sticker_file( - chat_id, "png_sticker_file_id", sticker="s", sticker_format="static" - ) - @pytest.mark.parametrize("local_mode", [True, False]) async def test_upload_sticker_file_local_files( self, monkeypatch, bot, chat_id, local_mode, recwarn @@ -678,101 +621,39 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): async def make_assertion(_, data, *args, **kwargs): nonlocal test_flag - if local_mode: - test_flag = ( - data.get("png_sticker") == expected or data.get("sticker") == expected - ) - else: - test_flag = isinstance(data.get("png_sticker"), InputFile) or isinstance( - data.get("sticker"), InputFile - ) + test_flag = ( + data.get("sticker") == expected + if local_mode + else isinstance(data.get("sticker"), InputFile) + ) monkeypatch.setattr(bot, "_post", make_assertion) await bot.upload_sticker_file(chat_id, sticker=file, sticker_format="static") assert test_flag - # Now test with the deprecated parameters - test_flag = False - await bot.upload_sticker_file(chat_id, file) - assert test_flag - - warnings = [w for w in recwarn if w.category is not ResourceWarning] - assert len(warnings) == 1 - assert warnings[0].category is PTBDeprecationWarning - assert warnings[0].filename == __file__ - assert str(warnings[0].message).startswith( - "Since Bot API 6.6, the parameter `png_sticker` for " - ) finally: bot._local_mode = False - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_create_new_sticker_set_warning( - self, bot, raw_bot, bot_class, monkeypatch, chat_id, recwarn - ): - async def make_assertion(*args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - monkeypatch.setattr(bot, "_post", make_assertion) - - await bot.create_new_sticker_set(chat_id, "name", "title", "some_str_emoji") - assert len(recwarn) == 1 - assert "Since Bot API 6.6, the parameters" in str(recwarn[0].message) - assert recwarn[0].category is PTBDeprecationWarning - assert recwarn[0].filename == __file__ - - async def test_create_new_sticker_set_missing_required_args(self, bot, chat_id): - with pytest.raises(TypeError, match="are required, please pass them as well"): - await bot.create_new_sticker_set(chat_id, "name", "title") - with pytest.raises(TypeError, match="are required, please pass them as well"): - await bot.create_new_sticker_set(chat_id, "name", "title", stickers=[]) - - async def test_create_new_sticker_set_mutually_exclusive(self, bot, chat_id): - with pytest.raises(TypeError, match="mutually exclusive with the deprecated parameters"): - await bot.create_new_sticker_set( - chat_id, "name", "title", "some_str_emoji", stickers=["s"], tgs_sticker="some_tgs" - ) - @pytest.mark.parametrize("local_mode", [True, False]) async def test_create_new_sticker_set_local_files( - self, monkeypatch, bot, chat_id, local_mode, recwarn + self, + monkeypatch, + bot, + chat_id, + local_mode, ): monkeypatch.setattr(bot, "_local_mode", local_mode) # For just test that the correct paths are passed as we have no local bot API set up test_flag = False file = data_file("telegram.jpg") + # always assumed to be local mode because we don't have access to local_mode setting + # within InputFile expected = file.as_uri() async def make_assertion(_, data, *args, **kwargs): nonlocal test_flag - if data.get("stickers"): # because we don't have access to local_mode setting - test_flag = data.get("stickers")[0].sticker == expected - elif local_mode: - test_flag = ( - data.get("png_sticker") == expected - and data.get("tgs_sticker") == expected - and data.get("webm_sticker") == expected - ) - else: - test_flag = ( - isinstance(data.get("png_sticker"), InputFile) - and isinstance(data.get("tgs_sticker"), InputFile) - and isinstance(data.get("webm_sticker"), InputFile) - ) + test_flag = data.get("stickers")[0].sticker == expected monkeypatch.setattr(bot, "_post", make_assertion) - await bot.create_new_sticker_set( - chat_id, - "name", - "title", - "emoji", - png_sticker=file, - tgs_sticker=file, - webm_sticker=file, - ) - assert test_flag - assert len(recwarn) in (1, 2) # The second one is an unclosed file warning - test_flag = False await bot.create_new_sticker_set( chat_id, "name", @@ -782,28 +663,8 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): ) assert test_flag - warnings = [w for w in recwarn if w.category is not ResourceWarning] - assert len(warnings) == 1 - assert warnings[0].category is PTBDeprecationWarning - assert warnings[0].filename == __file__ - assert str(warnings[0].message).startswith("Since Bot API 6.6, the parameters") - assert "for `create_new_sticker_set` are deprecated" in str(warnings[0].message) - - async def test_create_new_sticker_all_params( - self, monkeypatch, bot, chat_id, mask_position, recwarn - ): - async def make_assertion_old_params(_, data, *args, **kwargs): - assert data["user_id"] == chat_id - assert data["name"] == "name" - assert data["title"] == "title" - assert data["emojis"] == "emoji" - assert data["mask_position"] == mask_position - assert data["png_sticker"] == "wow.png" - assert data["tgs_sticker"] == "wow.tgs" - assert data["webm_sticker"] == "wow.webm" - assert data["sticker_type"] == Sticker.MASK - - async def make_assertion_new_params(_, data, *args, **kwargs): + async def test_create_new_sticker_all_params(self, monkeypatch, bot, chat_id, mask_position): + async def make_assertion(_, data, *args, **kwargs): assert data["user_id"] == chat_id assert data["name"] == "name" assert data["title"] == "title" @@ -811,26 +672,7 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): assert data["sticker_format"] == "static" assert data["needs_repainting"] is True - monkeypatch.setattr(bot, "_post", make_assertion_old_params) - await bot.create_new_sticker_set( - chat_id, - "name", - "title", - "emoji", - mask_position=mask_position, - png_sticker="wow.png", - tgs_sticker="wow.tgs", - webm_sticker="wow.webm", - sticker_type=Sticker.MASK, - ) - assert len(recwarn) == 1 - assert recwarn[0].filename == __file__, "wrong stacklevel" - assert recwarn[0].category is PTBDeprecationWarning - assert str(recwarn[0].message).startswith("Since Bot API 6.6, the parameters") - assert "for `create_new_sticker_set` are deprecated" in str(recwarn[0].message) - - recwarn.clear() - monkeypatch.setattr(bot, "_post", make_assertion_new_params) + monkeypatch.setattr(bot, "_post", make_assertion) await bot.create_new_sticker_set( chat_id, "name", @@ -839,78 +681,27 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): sticker_format=StickerFormat.STATIC, needs_repainting=True, ) - assert len(recwarn) == 0 - - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_add_sticker_to_set_warning( - self, bot, raw_bot, monkeypatch, bot_class, chat_id, recwarn - ): - async def make_assertion(*args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - monkeypatch.setattr(bot, "_post", make_assertion) - - await bot.add_sticker_to_set(chat_id, "name", "emoji", "fake_file_id") - assert len(recwarn) == 1 - assert "Since Bot API 6.6, the parameters" in str(recwarn[0].message) - assert recwarn[0].category is PTBDeprecationWarning - assert recwarn[0].filename == __file__ - - async def test_add_sticker_to_set_missing_required_arg(self, bot, chat_id): - with pytest.raises(TypeError, match="The parameter `sticker` is a required"): - await bot.add_sticker_to_set(chat_id, "name") - - async def test_add_sticker_to_set_mutually_exclusive(self, bot, chat_id): - with pytest.raises(TypeError, match="mutually exclusive with the deprecated parameters"): - await bot.add_sticker_to_set(chat_id, "name", "emojis", sticker="something") @pytest.mark.parametrize("local_mode", [True, False]) - async def test_add_sticker_to_set_local_files( - self, monkeypatch, bot, chat_id, local_mode, recwarn - ): + async def test_add_sticker_to_set_local_files(self, monkeypatch, bot, chat_id, local_mode): monkeypatch.setattr(bot, "_local_mode", local_mode) # For just test that the correct paths are passed as we have no local bot API set up test_flag = False file = data_file("telegram.jpg") + # always assumed to be local mode because we don't have access to local_mode setting + # within InputFile expected = file.as_uri() async def make_assertion(_, data, *args, **kwargs): nonlocal test_flag - if data.get("sticker"): # because we don't have access to local_mode setting - test_flag = data.get("sticker").sticker == expected - elif local_mode: - test_flag = ( - data.get("png_sticker") == expected and data.get("tgs_sticker") == expected - ) - else: - test_flag = isinstance(data.get("png_sticker"), InputFile) and isinstance( - data.get("tgs_sticker"), InputFile - ) + test_flag = data.get("sticker").sticker == expected monkeypatch.setattr(bot, "_post", make_assertion) - await bot.add_sticker_to_set( - chat_id, - "name", - "emoji", - png_sticker=file, - tgs_sticker=file, - ) - assert test_flag - assert len(recwarn) in (1, 2) # The second one is an unclosed file warning - test_flag = False await bot.add_sticker_to_set( chat_id, "name", sticker=InputSticker(sticker=file, emoji_list=["this"]) ) assert test_flag - warnings = [w for w in recwarn if w.category is not ResourceWarning] - assert len(warnings) == 1 - assert warnings[0].category is PTBDeprecationWarning - assert warnings[0].filename == __file__ - assert str(warnings[0].message).startswith("Since Bot API 6.6, the parameters") - assert "for `add_sticker_to_set` are deprecated" in str(warnings[0].message) - @pytest.mark.parametrize("local_mode", [True, False]) async def test_set_sticker_set_thumbnail_local_files( self, monkeypatch, bot, chat_id, local_mode @@ -935,27 +726,6 @@ class TestStickerSetWithoutRequest(TestStickerSetBase): finally: bot._local_mode = False - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_set_sticker_set_thumb_deprecation_warning( - self, monkeypatch, bot, raw_bot, recwarn, bot_class - ): - bot = bot if bot_class == "ExtBot" else raw_bot - - async def _post(*args, **kwargs): - return True - - monkeypatch.setattr(bot, "_post", _post) - await bot.set_sticker_set_thumb("name", "user_id", "thumb") - - assert len(recwarn) == 1 - assert recwarn[0].category is PTBDeprecationWarning - assert "renamed the method 'setStickerSetThumb' to 'setStickerSetThumbnail'" in str( - recwarn[0].message - ) - - assert recwarn[0].filename == __file__, "incorrect stacklevel!" - recwarn.clear() - async def test_get_file_instance_method(self, monkeypatch, sticker): async def make_assertion(*_, **kwargs): return kwargs["file_id"] == sticker.file_id diff --git a/tests/_files/test_video.py b/tests/_files/test_video.py index 233d04b3c..b2ec10981 100644 --- a/tests/_files/test_video.py +++ b/tests/_files/test_video.py @@ -31,10 +31,6 @@ from tests.auxil.bot_method_checks import ( check_shortcut_call, check_shortcut_signature, ) -from tests.auxil.deprecations import ( - check_thumb_deprecation_warning_for_method_args, - check_thumb_deprecation_warnings_for_args_and_attrs, -) from tests.auxil.files import data_file from tests.auxil.slots import mro_slots @@ -95,18 +91,6 @@ class TestVideoWithoutRequest(TestVideoBase): assert video.file_size == self.file_size assert video.mime_type == self.mime_type - def test_thumb_property_deprecation_warning(self, recwarn): - video = Video( - self.video_file_id, - self.video_file_unique_id, - self.width, - self.height, - self.duration, - thumb=object(), - ) - assert video.thumb is video.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_de_json(self, bot): json_dict = { "file_id": self.video_file_id, @@ -174,19 +158,6 @@ class TestVideoWithoutRequest(TestVideoBase): monkeypatch.setattr(bot.request, "post", make_assertion) assert await bot.send_video(chat_id, video=video) - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_send_video_thumb_deprecation_warning( - self, recwarn, monkeypatch, bot_class, bot, raw_bot, chat_id, video - ): - async def make_assertion(url, request_data: RequestData, *args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - - monkeypatch.setattr(bot.request, "post", make_assertion) - await bot.send_video(chat_id, video, thumb="thumb") - check_thumb_deprecation_warning_for_method_args(recwarn, __file__) - async def test_send_video_custom_filename(self, bot, chat_id, video_file, monkeypatch): async def make_assertion(url, request_data: RequestData, *args, **kwargs): return next(iter(request_data.multipart_data.values()))[0] == "custom_filename" @@ -219,15 +190,6 @@ class TestVideoWithoutRequest(TestVideoBase): finally: bot._local_mode = False - async def test_send_video_with_local_files_throws_exception_with_different_thumb_and_thumbnail( - self, bot, chat_id - ): - file = data_file("telegram.jpg") - different_file = data_file("telegram_no_standard_header.jpg") - - with pytest.raises(ValueError, match="different entities as 'thumb' and 'thumbnail'"): - await bot.send_video(chat_id, file, thumbnail=file, thumb=different_file) - async def test_get_file_instance_method(self, monkeypatch, video): async def make_assertion(*_, **kwargs): return kwargs["file_id"] == video.file_id diff --git a/tests/_files/test_videonote.py b/tests/_files/test_videonote.py index 48945a338..b931678d8 100644 --- a/tests/_files/test_videonote.py +++ b/tests/_files/test_videonote.py @@ -30,10 +30,6 @@ from tests.auxil.bot_method_checks import ( check_shortcut_call, check_shortcut_signature, ) -from tests.auxil.deprecations import ( - check_thumb_deprecation_warning_for_method_args, - check_thumb_deprecation_warnings_for_args_and_attrs, -) from tests.auxil.files import data_file from tests.auxil.slots import mro_slots @@ -87,13 +83,6 @@ class TestVideoNoteWithoutRequest(TestVideoNoteBase): assert video_note.duration == self.duration assert video_note.file_size == self.file_size - def test_thumb_property_deprecation_warning(self, recwarn): - video_note = VideoNote( - file_id="id", file_unique_id="unique_id", length=1, duration=1, thumb=object() - ) - assert video_note.thumb is video_note.thumbnail - check_thumb_deprecation_warnings_for_args_and_attrs(recwarn, __file__) - def test_de_json(self, bot): json_dict = { "file_id": self.videonote_file_id, @@ -152,19 +141,6 @@ class TestVideoNoteWithoutRequest(TestVideoNoteBase): monkeypatch.setattr(bot.request, "post", make_assertion) assert await bot.send_video_note(chat_id, video_note=video_note) - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_send_video_note_thumb_deprecation_warning( - self, recwarn, monkeypatch, bot_class, bot, raw_bot, chat_id, video_note - ): - async def make_assertion(url, request_data: RequestData, *args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - - monkeypatch.setattr(bot.request, "post", make_assertion) - await bot.send_video_note(chat_id, video_note, thumb="thumb") - check_thumb_deprecation_warning_for_method_args(recwarn, __file__) - async def test_send_video_note_custom_filename( self, bot, chat_id, video_note_file, monkeypatch ): @@ -201,15 +177,6 @@ class TestVideoNoteWithoutRequest(TestVideoNoteBase): finally: bot._local_mode = False - async def test_send_videonote_local_files_throws_exception_with_different_thumb_and_thumbnail( - self, bot, chat_id - ): - file = data_file("telegram.jpg") - different_file = data_file("telegram_no_standard_header.jpg") - - with pytest.raises(ValueError, match="different entities as 'thumb' and 'thumbnail'"): - await bot.send_video_note(chat_id, file, thumbnail=file, thumb=different_file) - async def test_get_file_instance_method(self, monkeypatch, video_note): async def make_assertion(*_, **kwargs): return kwargs["file_id"] == video_note.file_id diff --git a/tests/_inline/test_inlinequeryresultarticle.py b/tests/_inline/test_inlinequeryresultarticle.py index c74ffe457..6c30d88ae 100644 --- a/tests/_inline/test_inlinequeryresultarticle.py +++ b/tests/_inline/test_inlinequeryresultarticle.py @@ -26,7 +26,6 @@ from telegram import ( InlineQueryResultAudio, InputTextMessageContent, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -83,120 +82,6 @@ class TestInlineQueryResultArticleWithoutRequest(TestInlineQueryResultArticleBas assert inline_query_result_article.thumbnail_height == self.thumbnail_height assert inline_query_result_article.thumbnail_width == self.thumbnail_width - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_article = InlineQueryResultArticle( - TestInlineQueryResultArticleBase.id_, - TestInlineQueryResultArticleBase.title, - input_message_content=TestInlineQueryResultArticleBase.input_message_content, - reply_markup=TestInlineQueryResultArticleBase.reply_markup, - url=TestInlineQueryResultArticleBase.url, - hide_url=TestInlineQueryResultArticleBase.hide_url, - description=TestInlineQueryResultArticleBase.description, - thumb_url=TestInlineQueryResultArticleBase.thumbnail_url, # deprecated arg - thumbnail_height=TestInlineQueryResultArticleBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultArticleBase.thumbnail_width, - ) - assert inline_query_result_article.thumb_url == inline_query_result_article.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_url", new_name="thumbnail_url" - ) - - def test_thumb_height_property_deprecation_warning(self, recwarn): - inline_query_result_article = InlineQueryResultArticle( - TestInlineQueryResultArticleBase.id_, - TestInlineQueryResultArticleBase.title, - input_message_content=TestInlineQueryResultArticleBase.input_message_content, - reply_markup=TestInlineQueryResultArticleBase.reply_markup, - url=TestInlineQueryResultArticleBase.url, - hide_url=TestInlineQueryResultArticleBase.hide_url, - description=TestInlineQueryResultArticleBase.description, - thumbnail_url=TestInlineQueryResultArticleBase.thumbnail_url, - thumb_height=TestInlineQueryResultArticleBase.thumbnail_height, # deprecated arg - thumbnail_width=TestInlineQueryResultArticleBase.thumbnail_width, - ) - assert ( - inline_query_result_article.thumb_height - == inline_query_result_article.thumbnail_height - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_height", new_name="thumbnail_height" - ) - - def test_thumb_width_property_deprecation_warning(self, recwarn): - inline_query_result_article = InlineQueryResultArticle( - TestInlineQueryResultArticleBase.id_, - TestInlineQueryResultArticleBase.title, - input_message_content=TestInlineQueryResultArticleBase.input_message_content, - reply_markup=TestInlineQueryResultArticleBase.reply_markup, - url=TestInlineQueryResultArticleBase.url, - hide_url=TestInlineQueryResultArticleBase.hide_url, - description=TestInlineQueryResultArticleBase.description, - thumbnail_url=TestInlineQueryResultArticleBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultArticleBase.thumbnail_height, - thumb_width=TestInlineQueryResultArticleBase.thumbnail_width, # deprecated arg - ) - assert ( - inline_query_result_article.thumb_width == inline_query_result_article.thumbnail_width - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_width", new_name="thumbnail_width" - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_url' and 'thumbnail_url'", - ): - InlineQueryResultArticle( - TestInlineQueryResultArticleBase.id_, - TestInlineQueryResultArticleBase.title, - input_message_content=TestInlineQueryResultArticleBase.input_message_content, - reply_markup=TestInlineQueryResultArticleBase.reply_markup, - url=TestInlineQueryResultArticleBase.url, - hide_url=TestInlineQueryResultArticleBase.hide_url, - description=TestInlineQueryResultArticleBase.description, - thumbnail_url=TestInlineQueryResultArticleBase.thumbnail_url, - thumb_url="some other url", - thumbnail_height=TestInlineQueryResultArticleBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultArticleBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_height(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_height' and 'thumbnail_height'", - ): - InlineQueryResultArticle( - TestInlineQueryResultArticleBase.id_, - TestInlineQueryResultArticleBase.title, - input_message_content=TestInlineQueryResultArticleBase.input_message_content, - reply_markup=TestInlineQueryResultArticleBase.reply_markup, - url=TestInlineQueryResultArticleBase.url, - hide_url=TestInlineQueryResultArticleBase.hide_url, - description=TestInlineQueryResultArticleBase.description, - thumbnail_height=TestInlineQueryResultArticleBase.thumbnail_height, - thumb_height=TestInlineQueryResultArticleBase.thumbnail_height + 1, - thumbnail_width=TestInlineQueryResultArticleBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_width(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_width' and 'thumbnail_width'", - ): - InlineQueryResultArticle( - TestInlineQueryResultArticleBase.id_, - TestInlineQueryResultArticleBase.title, - input_message_content=TestInlineQueryResultArticleBase.input_message_content, - reply_markup=TestInlineQueryResultArticleBase.reply_markup, - url=TestInlineQueryResultArticleBase.url, - hide_url=TestInlineQueryResultArticleBase.hide_url, - description=TestInlineQueryResultArticleBase.description, - thumbnail_height=TestInlineQueryResultArticleBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultArticleBase.thumbnail_width, - thumb_width=TestInlineQueryResultArticleBase.thumbnail_width + 1, - ) - def test_to_dict(self, inline_query_result_article): inline_query_result_article_dict = inline_query_result_article.to_dict() diff --git a/tests/_inline/test_inlinequeryresultcontact.py b/tests/_inline/test_inlinequeryresultcontact.py index 9720cabd0..f231e163b 100644 --- a/tests/_inline/test_inlinequeryresultcontact.py +++ b/tests/_inline/test_inlinequeryresultcontact.py @@ -25,7 +25,6 @@ from telegram import ( InlineQueryResultVoice, InputTextMessageContent, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -79,116 +78,6 @@ class TestInlineQueryResultContactWithoutRequest(TestInlineQueryResultContactBas ) assert inline_query_result_contact.reply_markup.to_dict() == self.reply_markup.to_dict() - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_contact = InlineQueryResultContact( - TestInlineQueryResultContactBase.id_, - TestInlineQueryResultContactBase.phone_number, - TestInlineQueryResultContactBase.first_name, - last_name=TestInlineQueryResultContactBase.last_name, - input_message_content=TestInlineQueryResultContactBase.input_message_content, - reply_markup=TestInlineQueryResultContactBase.reply_markup, - thumb_url=TestInlineQueryResultContactBase.thumbnail_url, # deprecated arg - thumbnail_height=TestInlineQueryResultContactBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultContactBase.thumbnail_width, - ) - assert inline_query_result_contact.thumb_url == inline_query_result_contact.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_url", new_name="thumbnail_url" - ) - - def test_thumb_height_property_deprecation_warning(self, recwarn): - inline_query_result_contact = InlineQueryResultContact( - TestInlineQueryResultContactBase.id_, - TestInlineQueryResultContactBase.phone_number, - TestInlineQueryResultContactBase.first_name, - last_name=TestInlineQueryResultContactBase.last_name, - input_message_content=TestInlineQueryResultContactBase.input_message_content, - reply_markup=TestInlineQueryResultContactBase.reply_markup, - thumbnail_url=TestInlineQueryResultContactBase.thumbnail_url, - thumb_height=TestInlineQueryResultContactBase.thumbnail_height, # deprecated arg - thumbnail_width=TestInlineQueryResultContactBase.thumbnail_width, - ) - assert ( - inline_query_result_contact.thumb_height - == inline_query_result_contact.thumbnail_height - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_height", new_name="thumbnail_height" - ) - - def test_thumb_width_property_deprecation_warning(self, recwarn): - inline_query_result_contact = InlineQueryResultContact( - TestInlineQueryResultContactBase.id_, - TestInlineQueryResultContactBase.phone_number, - TestInlineQueryResultContactBase.first_name, - last_name=TestInlineQueryResultContactBase.last_name, - input_message_content=TestInlineQueryResultContactBase.input_message_content, - reply_markup=TestInlineQueryResultContactBase.reply_markup, - thumbnail_url=TestInlineQueryResultContactBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultContactBase.thumbnail_height, - thumb_width=TestInlineQueryResultContactBase.thumbnail_width, # deprecated arg - ) - assert ( - inline_query_result_contact.thumb_width == inline_query_result_contact.thumbnail_width - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_width", new_name="thumbnail_width" - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_url' and 'thumbnail_url'", - ): - InlineQueryResultContact( - TestInlineQueryResultContactBase.id_, - TestInlineQueryResultContactBase.phone_number, - TestInlineQueryResultContactBase.first_name, - last_name=TestInlineQueryResultContactBase.last_name, - input_message_content=TestInlineQueryResultContactBase.input_message_content, - reply_markup=TestInlineQueryResultContactBase.reply_markup, - thumbnail_url=TestInlineQueryResultContactBase.thumbnail_url, - thumb_url="some other url", - thumbnail_height=TestInlineQueryResultContactBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultContactBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_height(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_height' and 'thumbnail_height'", - ): - InlineQueryResultContact( - TestInlineQueryResultContactBase.id_, - TestInlineQueryResultContactBase.phone_number, - TestInlineQueryResultContactBase.first_name, - last_name=TestInlineQueryResultContactBase.last_name, - input_message_content=TestInlineQueryResultContactBase.input_message_content, - reply_markup=TestInlineQueryResultContactBase.reply_markup, - thumbnail_url=TestInlineQueryResultContactBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultContactBase.thumbnail_height, - thumb_height=TestInlineQueryResultContactBase.thumbnail_height + 1, - thumbnail_width=TestInlineQueryResultContactBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_width(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_width' and 'thumbnail_width'", - ): - InlineQueryResultContact( - TestInlineQueryResultContactBase.id_, - TestInlineQueryResultContactBase.phone_number, - TestInlineQueryResultContactBase.first_name, - last_name=TestInlineQueryResultContactBase.last_name, - input_message_content=TestInlineQueryResultContactBase.input_message_content, - reply_markup=TestInlineQueryResultContactBase.reply_markup, - thumbnail_url=TestInlineQueryResultContactBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultContactBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultContactBase.thumbnail_width, - thumb_width=TestInlineQueryResultContactBase.thumbnail_width + 1, - ) - def test_to_dict(self, inline_query_result_contact): inline_query_result_contact_dict = inline_query_result_contact.to_dict() diff --git a/tests/_inline/test_inlinequeryresultdocument.py b/tests/_inline/test_inlinequeryresultdocument.py index dc727ed39..ea7b8c30a 100644 --- a/tests/_inline/test_inlinequeryresultdocument.py +++ b/tests/_inline/test_inlinequeryresultdocument.py @@ -26,7 +26,6 @@ from telegram import ( InputTextMessageContent, MessageEntity, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -92,141 +91,6 @@ class TestInlineQueryResultDocumentWithoutRequest(TestInlineQueryResultDocumentB ) assert inline_query_result_document.reply_markup.to_dict() == self.reply_markup.to_dict() - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_document = InlineQueryResultDocument( - TestInlineQueryResultDocumentBase.id_, - TestInlineQueryResultDocumentBase.document_url, - TestInlineQueryResultDocumentBase.title, - TestInlineQueryResultDocumentBase.mime_type, - caption=TestInlineQueryResultDocumentBase.caption, - parse_mode=TestInlineQueryResultDocumentBase.parse_mode, - caption_entities=TestInlineQueryResultDocumentBase.caption_entities, - description=TestInlineQueryResultDocumentBase.description, - input_message_content=TestInlineQueryResultDocumentBase.input_message_content, - reply_markup=TestInlineQueryResultDocumentBase.reply_markup, - thumb_url=TestInlineQueryResultDocumentBase.thumbnail_url, # deprecated arg - thumbnail_height=TestInlineQueryResultDocumentBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultDocumentBase.thumbnail_width, - ) - assert inline_query_result_document.thumb_url == inline_query_result_document.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_url", new_name="thumbnail_url" - ) - - def test_thumb_height_property_deprecation_warning(self, recwarn): - inline_query_result_document = InlineQueryResultDocument( - TestInlineQueryResultDocumentBase.id_, - TestInlineQueryResultDocumentBase.document_url, - TestInlineQueryResultDocumentBase.title, - TestInlineQueryResultDocumentBase.mime_type, - caption=TestInlineQueryResultDocumentBase.caption, - parse_mode=TestInlineQueryResultDocumentBase.parse_mode, - caption_entities=TestInlineQueryResultDocumentBase.caption_entities, - description=TestInlineQueryResultDocumentBase.description, - input_message_content=TestInlineQueryResultDocumentBase.input_message_content, - reply_markup=TestInlineQueryResultDocumentBase.reply_markup, - thumbnail_url=TestInlineQueryResultDocumentBase.thumbnail_url, - thumb_height=TestInlineQueryResultDocumentBase.thumbnail_height, # deprecated arg - thumbnail_width=TestInlineQueryResultDocumentBase.thumbnail_width, - ) - assert ( - inline_query_result_document.thumb_height - == inline_query_result_document.thumbnail_height - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_height", new_name="thumbnail_height" - ) - - def test_thumb_width_property_deprecation_warning(self, recwarn): - inline_query_result_document = InlineQueryResultDocument( - TestInlineQueryResultDocumentBase.id_, - TestInlineQueryResultDocumentBase.document_url, - TestInlineQueryResultDocumentBase.title, - TestInlineQueryResultDocumentBase.mime_type, - caption=TestInlineQueryResultDocumentBase.caption, - parse_mode=TestInlineQueryResultDocumentBase.parse_mode, - caption_entities=TestInlineQueryResultDocumentBase.caption_entities, - description=TestInlineQueryResultDocumentBase.description, - input_message_content=TestInlineQueryResultDocumentBase.input_message_content, - reply_markup=TestInlineQueryResultDocumentBase.reply_markup, - thumbnail_url=TestInlineQueryResultDocumentBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultDocumentBase.thumbnail_height, - thumb_width=TestInlineQueryResultDocumentBase.thumbnail_width, # deprecated arg - ) - assert ( - inline_query_result_document.thumb_width - == inline_query_result_document.thumbnail_width - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_width", new_name="thumbnail_width" - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_url' and 'thumbnail_url'", - ): - InlineQueryResultDocument( - TestInlineQueryResultDocumentBase.id_, - TestInlineQueryResultDocumentBase.document_url, - TestInlineQueryResultDocumentBase.title, - TestInlineQueryResultDocumentBase.mime_type, - caption=TestInlineQueryResultDocumentBase.caption, - parse_mode=TestInlineQueryResultDocumentBase.parse_mode, - caption_entities=TestInlineQueryResultDocumentBase.caption_entities, - description=TestInlineQueryResultDocumentBase.description, - input_message_content=TestInlineQueryResultDocumentBase.input_message_content, - reply_markup=TestInlineQueryResultDocumentBase.reply_markup, - thumbnail_url=TestInlineQueryResultDocumentBase.thumbnail_url, - thumb_url="some other url", - thumbnail_height=TestInlineQueryResultDocumentBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultDocumentBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_height(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_height' and 'thumbnail_height'", - ): - InlineQueryResultDocument( - TestInlineQueryResultDocumentBase.id_, - TestInlineQueryResultDocumentBase.document_url, - TestInlineQueryResultDocumentBase.title, - TestInlineQueryResultDocumentBase.mime_type, - caption=TestInlineQueryResultDocumentBase.caption, - parse_mode=TestInlineQueryResultDocumentBase.parse_mode, - caption_entities=TestInlineQueryResultDocumentBase.caption_entities, - description=TestInlineQueryResultDocumentBase.description, - input_message_content=TestInlineQueryResultDocumentBase.input_message_content, - reply_markup=TestInlineQueryResultDocumentBase.reply_markup, - thumbnail_url=TestInlineQueryResultDocumentBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultDocumentBase.thumbnail_height, - thumb_height=TestInlineQueryResultDocumentBase.thumbnail_height + 1, - thumbnail_width=TestInlineQueryResultDocumentBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_width(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_width' and 'thumbnail_width'", - ): - InlineQueryResultDocument( - TestInlineQueryResultDocumentBase.id_, - TestInlineQueryResultDocumentBase.document_url, - TestInlineQueryResultDocumentBase.title, - TestInlineQueryResultDocumentBase.mime_type, - caption=TestInlineQueryResultDocumentBase.caption, - parse_mode=TestInlineQueryResultDocumentBase.parse_mode, - caption_entities=TestInlineQueryResultDocumentBase.caption_entities, - description=TestInlineQueryResultDocumentBase.description, - input_message_content=TestInlineQueryResultDocumentBase.input_message_content, - reply_markup=TestInlineQueryResultDocumentBase.reply_markup, - thumbnail_url=TestInlineQueryResultDocumentBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultDocumentBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultDocumentBase.thumbnail_width, - thumb_width=TestInlineQueryResultDocumentBase.thumbnail_width + 1, - ) - def test_caption_entities_always_tuple(self): result = InlineQueryResultDocument(self.id_, self.document_url, self.title, self.mime_type) assert result.caption_entities == () diff --git a/tests/_inline/test_inlinequeryresultgif.py b/tests/_inline/test_inlinequeryresultgif.py index 7d3545af7..43da73962 100644 --- a/tests/_inline/test_inlinequeryresultgif.py +++ b/tests/_inline/test_inlinequeryresultgif.py @@ -26,7 +26,6 @@ from telegram import ( InputTextMessageContent, MessageEntity, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -96,141 +95,6 @@ class TestInlineQueryResultGifWithoutRequest(TestInlineQueryResultGifBase): ) assert inline_query_result_gif.reply_markup.to_dict() == self.reply_markup.to_dict() - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_gif = InlineQueryResultGif( - TestInlineQueryResultGifBase.id_, - TestInlineQueryResultGifBase.gif_url, - TestInlineQueryResultGifBase.thumbnail_url, - gif_width=TestInlineQueryResultGifBase.gif_width, - gif_height=TestInlineQueryResultGifBase.gif_height, - gif_duration=TestInlineQueryResultGifBase.gif_duration, - title=TestInlineQueryResultGifBase.title, - caption=TestInlineQueryResultGifBase.caption, - parse_mode=TestInlineQueryResultGifBase.parse_mode, - caption_entities=TestInlineQueryResultGifBase.caption_entities, - input_message_content=TestInlineQueryResultGifBase.input_message_content, - reply_markup=TestInlineQueryResultGifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultGifBase.thumbnail_mime_type, - thumb_url=TestInlineQueryResultGifBase.thumbnail_url, # deprecated arg - ) - assert inline_query_result_gif.thumb_url == inline_query_result_gif.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_thumb_mime_type_property_deprecation_warning(self, recwarn): - inline_query_result_gif = InlineQueryResultGif( - TestInlineQueryResultGifBase.id_, - TestInlineQueryResultGifBase.gif_url, - TestInlineQueryResultGifBase.thumbnail_url, - gif_width=TestInlineQueryResultGifBase.gif_width, - gif_height=TestInlineQueryResultGifBase.gif_height, - gif_duration=TestInlineQueryResultGifBase.gif_duration, - title=TestInlineQueryResultGifBase.title, - caption=TestInlineQueryResultGifBase.caption, - parse_mode=TestInlineQueryResultGifBase.parse_mode, - caption_entities=TestInlineQueryResultGifBase.caption_entities, - input_message_content=TestInlineQueryResultGifBase.input_message_content, - reply_markup=TestInlineQueryResultGifBase.reply_markup, - thumb_mime_type=TestInlineQueryResultGifBase.thumbnail_mime_type, # deprecated arg - ) - assert ( - inline_query_result_gif.thumb_mime_type == inline_query_result_gif.thumbnail_mime_type - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_mime_type", new_name="thumbnail_mime_type" - ) - - def test_thumb_url_issues_warning_and_works_without_positional_arg(self, recwarn): - inline_query_result_gif = InlineQueryResultGif( - TestInlineQueryResultGifBase.id_, - TestInlineQueryResultGifBase.gif_url, - # positional argument thumbnail_url should be here, but it's not - gif_width=TestInlineQueryResultGifBase.gif_width, - gif_height=TestInlineQueryResultGifBase.gif_height, - gif_duration=TestInlineQueryResultGifBase.gif_duration, - title=TestInlineQueryResultGifBase.title, - caption=TestInlineQueryResultGifBase.caption, - parse_mode=TestInlineQueryResultGifBase.parse_mode, - caption_entities=TestInlineQueryResultGifBase.caption_entities, - input_message_content=TestInlineQueryResultGifBase.input_message_content, - reply_markup=TestInlineQueryResultGifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultGifBase.thumbnail_mime_type, - thumb_url=TestInlineQueryResultGifBase.thumbnail_url, # deprecated arg - ) - - assert inline_query_result_gif.thumb_url == inline_query_result_gif.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_init_throws_error_without_thumbnail_url_and_thumb_url(self): - with pytest.raises(ValueError, match="You must pass either"): - InlineQueryResultGif( - TestInlineQueryResultGifBase.id_, - TestInlineQueryResultGifBase.gif_url, - # no thumbnail_url or thumb_url - gif_width=TestInlineQueryResultGifBase.gif_width, - gif_height=TestInlineQueryResultGifBase.gif_height, - gif_duration=TestInlineQueryResultGifBase.gif_duration, - title=TestInlineQueryResultGifBase.title, - caption=TestInlineQueryResultGifBase.caption, - parse_mode=TestInlineQueryResultGifBase.parse_mode, - caption_entities=TestInlineQueryResultGifBase.caption_entities, - input_message_content=TestInlineQueryResultGifBase.input_message_content, - reply_markup=TestInlineQueryResultGifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultGifBase.thumbnail_mime_type, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_url' and 'thumbnail_url'" - ): - InlineQueryResultGif( - TestInlineQueryResultGifBase.id_, - TestInlineQueryResultGifBase.gif_url, - TestInlineQueryResultGifBase.thumbnail_url, - gif_width=TestInlineQueryResultGifBase.gif_width, - gif_height=TestInlineQueryResultGifBase.gif_height, - gif_duration=TestInlineQueryResultGifBase.gif_duration, - title=TestInlineQueryResultGifBase.title, - caption=TestInlineQueryResultGifBase.caption, - parse_mode=TestInlineQueryResultGifBase.parse_mode, - caption_entities=TestInlineQueryResultGifBase.caption_entities, - input_message_content=TestInlineQueryResultGifBase.input_message_content, - reply_markup=TestInlineQueryResultGifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultGifBase.thumbnail_mime_type, - thumb_url="some other url", - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_mime_type(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_mime_type' and 'thumbnail_mime_type'", - ): - InlineQueryResultGif( - TestInlineQueryResultGifBase.id_, - TestInlineQueryResultGifBase.gif_url, - TestInlineQueryResultGifBase.thumbnail_url, - gif_width=TestInlineQueryResultGifBase.gif_width, - gif_height=TestInlineQueryResultGifBase.gif_height, - gif_duration=TestInlineQueryResultGifBase.gif_duration, - title=TestInlineQueryResultGifBase.title, - caption=TestInlineQueryResultGifBase.caption, - parse_mode=TestInlineQueryResultGifBase.parse_mode, - caption_entities=TestInlineQueryResultGifBase.caption_entities, - input_message_content=TestInlineQueryResultGifBase.input_message_content, - reply_markup=TestInlineQueryResultGifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultGifBase.thumbnail_mime_type, - thumb_mime_type="video/mp4", - ) - def test_to_dict(self, inline_query_result_gif): inline_query_result_gif_dict = inline_query_result_gif.to_dict() diff --git a/tests/_inline/test_inlinequeryresultlocation.py b/tests/_inline/test_inlinequeryresultlocation.py index 7a94f3ef5..79c4532a3 100644 --- a/tests/_inline/test_inlinequeryresultlocation.py +++ b/tests/_inline/test_inlinequeryresultlocation.py @@ -25,7 +25,6 @@ from telegram import ( InlineQueryResultVoice, InputTextMessageContent, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -91,138 +90,6 @@ class TestInlineQueryResultLocationWithoutRequest(TestInlineQueryResultLocationB assert inline_query_result_location.horizontal_accuracy == self.horizontal_accuracy assert inline_query_result_location.proximity_alert_radius == self.proximity_alert_radius - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_location = InlineQueryResultLocation( - TestInlineQueryResultLocationBase.id_, - TestInlineQueryResultLocationBase.latitude, - TestInlineQueryResultLocationBase.longitude, - TestInlineQueryResultLocationBase.title, - live_period=TestInlineQueryResultLocationBase.live_period, - input_message_content=TestInlineQueryResultLocationBase.input_message_content, - reply_markup=TestInlineQueryResultLocationBase.reply_markup, - horizontal_accuracy=TestInlineQueryResultLocationBase.horizontal_accuracy, - heading=TestInlineQueryResultLocationBase.heading, - proximity_alert_radius=TestInlineQueryResultLocationBase.proximity_alert_radius, - thumb_url=TestInlineQueryResultLocationBase.thumbnail_url, # deprecated arg - thumbnail_height=TestInlineQueryResultLocationBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultLocationBase.thumbnail_width, - ) - assert inline_query_result_location.thumb_url == inline_query_result_location.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_url", new_name="thumbnail_url" - ) - - def test_thumb_height_property_deprecation_warning(self, recwarn): - inline_query_result_location = InlineQueryResultLocation( - TestInlineQueryResultLocationBase.id_, - TestInlineQueryResultLocationBase.latitude, - TestInlineQueryResultLocationBase.longitude, - TestInlineQueryResultLocationBase.title, - live_period=TestInlineQueryResultLocationBase.live_period, - input_message_content=TestInlineQueryResultLocationBase.input_message_content, - reply_markup=TestInlineQueryResultLocationBase.reply_markup, - horizontal_accuracy=TestInlineQueryResultLocationBase.horizontal_accuracy, - heading=TestInlineQueryResultLocationBase.heading, - proximity_alert_radius=TestInlineQueryResultLocationBase.proximity_alert_radius, - thumbnail_url=TestInlineQueryResultLocationBase.thumbnail_url, - thumb_height=TestInlineQueryResultLocationBase.thumbnail_height, # deprecated arg - thumbnail_width=TestInlineQueryResultLocationBase.thumbnail_width, - ) - assert ( - inline_query_result_location.thumb_height - == inline_query_result_location.thumbnail_height - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_height", new_name="thumbnail_height" - ) - - def test_thumb_width_property_deprecation_warning(self, recwarn): - inline_query_result_location = InlineQueryResultLocation( - TestInlineQueryResultLocationBase.id_, - TestInlineQueryResultLocationBase.latitude, - TestInlineQueryResultLocationBase.longitude, - TestInlineQueryResultLocationBase.title, - live_period=TestInlineQueryResultLocationBase.live_period, - input_message_content=TestInlineQueryResultLocationBase.input_message_content, - reply_markup=TestInlineQueryResultLocationBase.reply_markup, - horizontal_accuracy=TestInlineQueryResultLocationBase.horizontal_accuracy, - heading=TestInlineQueryResultLocationBase.heading, - proximity_alert_radius=TestInlineQueryResultLocationBase.proximity_alert_radius, - thumbnail_url=TestInlineQueryResultLocationBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultLocationBase.thumbnail_height, - thumb_width=TestInlineQueryResultLocationBase.thumbnail_width, # deprecated arg - ) - assert ( - inline_query_result_location.thumb_width - == inline_query_result_location.thumbnail_width - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_width", new_name="thumbnail_width" - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_url' and 'thumbnail_url'" - ): - InlineQueryResultLocation( - TestInlineQueryResultLocationBase.id_, - TestInlineQueryResultLocationBase.latitude, - TestInlineQueryResultLocationBase.longitude, - TestInlineQueryResultLocationBase.title, - live_period=TestInlineQueryResultLocationBase.live_period, - input_message_content=TestInlineQueryResultLocationBase.input_message_content, - reply_markup=TestInlineQueryResultLocationBase.reply_markup, - horizontal_accuracy=TestInlineQueryResultLocationBase.horizontal_accuracy, - heading=TestInlineQueryResultLocationBase.heading, - proximity_alert_radius=TestInlineQueryResultLocationBase.proximity_alert_radius, - thumbnail_url=TestInlineQueryResultLocationBase.thumbnail_url, - thumb_url="some other url", - thumbnail_height=TestInlineQueryResultLocationBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultLocationBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_height(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_height' and 'thumbnail_height'" - ): - InlineQueryResultLocation( - TestInlineQueryResultLocationBase.id_, - TestInlineQueryResultLocationBase.latitude, - TestInlineQueryResultLocationBase.longitude, - TestInlineQueryResultLocationBase.title, - live_period=TestInlineQueryResultLocationBase.live_period, - input_message_content=TestInlineQueryResultLocationBase.input_message_content, - reply_markup=TestInlineQueryResultLocationBase.reply_markup, - horizontal_accuracy=TestInlineQueryResultLocationBase.horizontal_accuracy, - heading=TestInlineQueryResultLocationBase.heading, - proximity_alert_radius=TestInlineQueryResultLocationBase.proximity_alert_radius, - thumbnail_url=TestInlineQueryResultLocationBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultLocationBase.thumbnail_height, - thumb_height=TestInlineQueryResultLocationBase.thumbnail_height + 1, - thumbnail_width=TestInlineQueryResultLocationBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_width(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_width' and 'thumbnail_width'" - ): - InlineQueryResultLocation( - TestInlineQueryResultLocationBase.id_, - TestInlineQueryResultLocationBase.latitude, - TestInlineQueryResultLocationBase.longitude, - TestInlineQueryResultLocationBase.title, - live_period=TestInlineQueryResultLocationBase.live_period, - input_message_content=TestInlineQueryResultLocationBase.input_message_content, - reply_markup=TestInlineQueryResultLocationBase.reply_markup, - horizontal_accuracy=TestInlineQueryResultLocationBase.horizontal_accuracy, - heading=TestInlineQueryResultLocationBase.heading, - proximity_alert_radius=TestInlineQueryResultLocationBase.proximity_alert_radius, - thumbnail_url=TestInlineQueryResultLocationBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultLocationBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultLocationBase.thumbnail_width, - thumb_width=TestInlineQueryResultLocationBase.thumbnail_width + 1, - ) - def test_to_dict(self, inline_query_result_location): inline_query_result_location_dict = inline_query_result_location.to_dict() diff --git a/tests/_inline/test_inlinequeryresultmpeg4gif.py b/tests/_inline/test_inlinequeryresultmpeg4gif.py index 7a340a046..4dd5e6e81 100644 --- a/tests/_inline/test_inlinequeryresultmpeg4gif.py +++ b/tests/_inline/test_inlinequeryresultmpeg4gif.py @@ -26,7 +26,6 @@ from telegram import ( InputTextMessageContent, MessageEntity, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -96,146 +95,6 @@ class TestInlineQueryResultMpeg4GifWithoutRequest(TestInlineQueryResultMpeg4GifB result = InlineQueryResultMpeg4Gif(self.id_, self.mpeg4_url, self.thumbnail_url) assert result.caption_entities == () - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_mpeg4_gif = InlineQueryResultMpeg4Gif( - TestInlineQueryResultMpeg4GifBase.id_, - TestInlineQueryResultMpeg4GifBase.mpeg4_url, - TestInlineQueryResultMpeg4GifBase.thumbnail_url, - mpeg4_width=TestInlineQueryResultMpeg4GifBase.mpeg4_width, - mpeg4_height=TestInlineQueryResultMpeg4GifBase.mpeg4_height, - mpeg4_duration=TestInlineQueryResultMpeg4GifBase.mpeg4_duration, - title=TestInlineQueryResultMpeg4GifBase.title, - caption=TestInlineQueryResultMpeg4GifBase.caption, - parse_mode=TestInlineQueryResultMpeg4GifBase.parse_mode, - caption_entities=TestInlineQueryResultMpeg4GifBase.caption_entities, - input_message_content=TestInlineQueryResultMpeg4GifBase.input_message_content, - reply_markup=TestInlineQueryResultMpeg4GifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultMpeg4GifBase.thumbnail_mime_type, - thumb_url=TestInlineQueryResultMpeg4GifBase.thumbnail_url, # deprecated arg - ) - assert ( - inline_query_result_mpeg4_gif.thumb_url == inline_query_result_mpeg4_gif.thumbnail_url - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_thumb_mime_type_property_deprecation_warning(self, recwarn): - inline_query_result_mpeg4_gif = InlineQueryResultMpeg4Gif( - TestInlineQueryResultMpeg4GifBase.id_, - TestInlineQueryResultMpeg4GifBase.mpeg4_url, - TestInlineQueryResultMpeg4GifBase.thumbnail_url, - mpeg4_width=TestInlineQueryResultMpeg4GifBase.mpeg4_width, - mpeg4_height=TestInlineQueryResultMpeg4GifBase.mpeg4_height, - mpeg4_duration=TestInlineQueryResultMpeg4GifBase.mpeg4_duration, - title=TestInlineQueryResultMpeg4GifBase.title, - caption=TestInlineQueryResultMpeg4GifBase.caption, - parse_mode=TestInlineQueryResultMpeg4GifBase.parse_mode, - caption_entities=TestInlineQueryResultMpeg4GifBase.caption_entities, - input_message_content=TestInlineQueryResultMpeg4GifBase.input_message_content, - reply_markup=TestInlineQueryResultMpeg4GifBase.reply_markup, - thumb_mime_type=TestInlineQueryResultMpeg4GifBase.thumbnail_mime_type, # deprecated - ) - assert ( - inline_query_result_mpeg4_gif.thumb_mime_type - == inline_query_result_mpeg4_gif.thumbnail_mime_type - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_mime_type", new_name="thumbnail_mime_type" - ) - - def test_thumb_url_issues_warning_and_works_without_positional_arg(self, recwarn): - inline_query_result_mpeg4_gif = InlineQueryResultMpeg4Gif( - TestInlineQueryResultMpeg4GifBase.id_, - TestInlineQueryResultMpeg4GifBase.mpeg4_url, - # positional argument thumbnail_url should be here, but it's not - mpeg4_width=TestInlineQueryResultMpeg4GifBase.mpeg4_width, - mpeg4_height=TestInlineQueryResultMpeg4GifBase.mpeg4_height, - mpeg4_duration=TestInlineQueryResultMpeg4GifBase.mpeg4_duration, - title=TestInlineQueryResultMpeg4GifBase.title, - caption=TestInlineQueryResultMpeg4GifBase.caption, - parse_mode=TestInlineQueryResultMpeg4GifBase.parse_mode, - caption_entities=TestInlineQueryResultMpeg4GifBase.caption_entities, - input_message_content=TestInlineQueryResultMpeg4GifBase.input_message_content, - reply_markup=TestInlineQueryResultMpeg4GifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultMpeg4GifBase.thumbnail_mime_type, - thumb_url=TestInlineQueryResultMpeg4GifBase.thumbnail_url, # deprecated arg - ) - - assert ( - inline_query_result_mpeg4_gif.thumb_url == inline_query_result_mpeg4_gif.thumbnail_url - ) - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_init_throws_error_without_thumbnail_url_and_thumb_url(self): - with pytest.raises(ValueError, match="You must pass either"): - InlineQueryResultMpeg4Gif( - TestInlineQueryResultMpeg4GifBase.id_, - TestInlineQueryResultMpeg4GifBase.mpeg4_url, - # no thumbnail_url or thumb_url - mpeg4_width=TestInlineQueryResultMpeg4GifBase.mpeg4_width, - mpeg4_height=TestInlineQueryResultMpeg4GifBase.mpeg4_height, - mpeg4_duration=TestInlineQueryResultMpeg4GifBase.mpeg4_duration, - title=TestInlineQueryResultMpeg4GifBase.title, - caption=TestInlineQueryResultMpeg4GifBase.caption, - parse_mode=TestInlineQueryResultMpeg4GifBase.parse_mode, - caption_entities=TestInlineQueryResultMpeg4GifBase.caption_entities, - input_message_content=TestInlineQueryResultMpeg4GifBase.input_message_content, - reply_markup=TestInlineQueryResultMpeg4GifBase.reply_markup, - thumb_mime_type=TestInlineQueryResultMpeg4GifBase.thumbnail_mime_type, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_url' and 'thumbnail_url'" - ): - InlineQueryResultMpeg4Gif( - TestInlineQueryResultMpeg4GifBase.id_, - TestInlineQueryResultMpeg4GifBase.mpeg4_url, - TestInlineQueryResultMpeg4GifBase.thumbnail_url, - mpeg4_width=TestInlineQueryResultMpeg4GifBase.mpeg4_width, - mpeg4_height=TestInlineQueryResultMpeg4GifBase.mpeg4_height, - mpeg4_duration=TestInlineQueryResultMpeg4GifBase.mpeg4_duration, - title=TestInlineQueryResultMpeg4GifBase.title, - caption=TestInlineQueryResultMpeg4GifBase.caption, - parse_mode=TestInlineQueryResultMpeg4GifBase.parse_mode, - caption_entities=TestInlineQueryResultMpeg4GifBase.caption_entities, - input_message_content=TestInlineQueryResultMpeg4GifBase.input_message_content, - reply_markup=TestInlineQueryResultMpeg4GifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultMpeg4GifBase.thumbnail_mime_type, - thumb_url="some other URL", - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_mime_type(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_mime_type' and 'thumbnail_mime_type'", - ): - InlineQueryResultMpeg4Gif( - TestInlineQueryResultMpeg4GifBase.id_, - TestInlineQueryResultMpeg4GifBase.mpeg4_url, - TestInlineQueryResultMpeg4GifBase.thumbnail_url, - mpeg4_width=TestInlineQueryResultMpeg4GifBase.mpeg4_width, - mpeg4_height=TestInlineQueryResultMpeg4GifBase.mpeg4_height, - mpeg4_duration=TestInlineQueryResultMpeg4GifBase.mpeg4_duration, - title=TestInlineQueryResultMpeg4GifBase.title, - caption=TestInlineQueryResultMpeg4GifBase.caption, - parse_mode=TestInlineQueryResultMpeg4GifBase.parse_mode, - caption_entities=TestInlineQueryResultMpeg4GifBase.caption_entities, - input_message_content=TestInlineQueryResultMpeg4GifBase.input_message_content, - reply_markup=TestInlineQueryResultMpeg4GifBase.reply_markup, - thumbnail_mime_type=TestInlineQueryResultMpeg4GifBase.thumbnail_mime_type, - thumb_mime_type="video/mp4", - ) - def test_to_dict(self, inline_query_result_mpeg4_gif): inline_query_result_mpeg4_gif_dict = inline_query_result_mpeg4_gif.to_dict() diff --git a/tests/_inline/test_inlinequeryresultphoto.py b/tests/_inline/test_inlinequeryresultphoto.py index d10b15fa3..8d86123ff 100644 --- a/tests/_inline/test_inlinequeryresultphoto.py +++ b/tests/_inline/test_inlinequeryresultphoto.py @@ -26,7 +26,6 @@ from telegram import ( InputTextMessageContent, MessageEntity, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -94,92 +93,6 @@ class TestInlineQueryResultPhotoWithoutRequest(TestInlineQueryResultPhotoBase): result = InlineQueryResultPhoto(self.id_, self.photo_url, self.thumbnail_url) assert result.caption_entities == () - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_photo = InlineQueryResultPhoto( - TestInlineQueryResultPhotoBase.id_, - TestInlineQueryResultPhotoBase.photo_url, - TestInlineQueryResultPhotoBase.thumbnail_url, - photo_width=TestInlineQueryResultPhotoBase.photo_width, - photo_height=TestInlineQueryResultPhotoBase.photo_height, - title=TestInlineQueryResultPhotoBase.title, - description=TestInlineQueryResultPhotoBase.description, - caption=TestInlineQueryResultPhotoBase.caption, - parse_mode=TestInlineQueryResultPhotoBase.parse_mode, - caption_entities=TestInlineQueryResultPhotoBase.caption_entities, - input_message_content=TestInlineQueryResultPhotoBase.input_message_content, - reply_markup=TestInlineQueryResultPhotoBase.reply_markup, - thumb_url=TestInlineQueryResultPhotoBase.thumbnail_url, # deprecated arg - ) - assert inline_query_result_photo.thumb_url == inline_query_result_photo.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_thumb_url_issues_warning_and_works_without_positional_arg(self, recwarn): - inline_query_result_photo = InlineQueryResultPhoto( - TestInlineQueryResultPhotoBase.id_, - TestInlineQueryResultPhotoBase.photo_url, - # positional argument thumbnail_url should be here, but it's not - photo_width=TestInlineQueryResultPhotoBase.photo_width, - photo_height=TestInlineQueryResultPhotoBase.photo_height, - title=TestInlineQueryResultPhotoBase.title, - description=TestInlineQueryResultPhotoBase.description, - caption=TestInlineQueryResultPhotoBase.caption, - parse_mode=TestInlineQueryResultPhotoBase.parse_mode, - caption_entities=TestInlineQueryResultPhotoBase.caption_entities, - input_message_content=TestInlineQueryResultPhotoBase.input_message_content, - reply_markup=TestInlineQueryResultPhotoBase.reply_markup, - thumb_url=TestInlineQueryResultPhotoBase.thumbnail_url, # deprecated arg - ) - assert inline_query_result_photo.thumb_url == inline_query_result_photo.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_init_throws_error_without_thumbnail_url_and_thumb_url(self): - with pytest.raises(ValueError, match="You must pass either"): - InlineQueryResultPhoto( - TestInlineQueryResultPhotoBase.id_, - TestInlineQueryResultPhotoBase.photo_url, - # no thumbnail_url or thumb_url - photo_width=TestInlineQueryResultPhotoBase.photo_width, - photo_height=TestInlineQueryResultPhotoBase.photo_height, - title=TestInlineQueryResultPhotoBase.title, - description=TestInlineQueryResultPhotoBase.description, - caption=TestInlineQueryResultPhotoBase.caption, - parse_mode=TestInlineQueryResultPhotoBase.parse_mode, - caption_entities=TestInlineQueryResultPhotoBase.caption_entities, - input_message_content=TestInlineQueryResultPhotoBase.input_message_content, - reply_markup=TestInlineQueryResultPhotoBase.reply_markup, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_url' and 'thumbnail_url'", - ): - InlineQueryResultPhoto( - TestInlineQueryResultPhotoBase.id_, - TestInlineQueryResultPhotoBase.photo_url, - TestInlineQueryResultPhotoBase.thumbnail_url, - photo_width=TestInlineQueryResultPhotoBase.photo_width, - photo_height=TestInlineQueryResultPhotoBase.photo_height, - title=TestInlineQueryResultPhotoBase.title, - description=TestInlineQueryResultPhotoBase.description, - caption=TestInlineQueryResultPhotoBase.caption, - parse_mode=TestInlineQueryResultPhotoBase.parse_mode, - caption_entities=TestInlineQueryResultPhotoBase.caption_entities, - input_message_content=TestInlineQueryResultPhotoBase.input_message_content, - reply_markup=TestInlineQueryResultPhotoBase.reply_markup, - thumb_url="some other url", - ) - def test_to_dict(self, inline_query_result_photo): inline_query_result_photo_dict = inline_query_result_photo.to_dict() diff --git a/tests/_inline/test_inlinequeryresultvenue.py b/tests/_inline/test_inlinequeryresultvenue.py index ee456cf10..69a1e4a68 100644 --- a/tests/_inline/test_inlinequeryresultvenue.py +++ b/tests/_inline/test_inlinequeryresultvenue.py @@ -25,7 +25,6 @@ from telegram import ( InlineQueryResultVoice, InputTextMessageContent, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -94,138 +93,6 @@ class TestInlineQueryResultVenueWithoutRequest(TestInlineQueryResultVenueBase): ) assert inline_query_result_venue.reply_markup.to_dict() == self.reply_markup.to_dict() - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_venue = InlineQueryResultVenue( - TestInlineQueryResultVenueBase.id_, - TestInlineQueryResultVenueBase.latitude, - TestInlineQueryResultVenueBase.longitude, - TestInlineQueryResultVenueBase.title, - TestInlineQueryResultVenueBase.address, - foursquare_id=TestInlineQueryResultVenueBase.foursquare_id, - foursquare_type=TestInlineQueryResultVenueBase.foursquare_type, - input_message_content=TestInlineQueryResultVenueBase.input_message_content, - reply_markup=TestInlineQueryResultVenueBase.reply_markup, - google_place_id=TestInlineQueryResultVenueBase.google_place_id, - google_place_type=TestInlineQueryResultVenueBase.google_place_type, - thumb_url=TestInlineQueryResultVenueBase.thumbnail_url, # deprecated arg - thumbnail_height=TestInlineQueryResultVenueBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultVenueBase.thumbnail_width, - ) - assert inline_query_result_venue.thumb_url == inline_query_result_venue.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_url", new_name="thumbnail_url" - ) - - def test_thumb_height_property_deprecation_warning(self, recwarn): - inline_query_result_venue = InlineQueryResultVenue( - TestInlineQueryResultVenueBase.id_, - TestInlineQueryResultVenueBase.latitude, - TestInlineQueryResultVenueBase.longitude, - TestInlineQueryResultVenueBase.title, - TestInlineQueryResultVenueBase.address, - foursquare_id=TestInlineQueryResultVenueBase.foursquare_id, - foursquare_type=TestInlineQueryResultVenueBase.foursquare_type, - input_message_content=TestInlineQueryResultVenueBase.input_message_content, - reply_markup=TestInlineQueryResultVenueBase.reply_markup, - google_place_id=TestInlineQueryResultVenueBase.google_place_id, - google_place_type=TestInlineQueryResultVenueBase.google_place_type, - thumbnail_url=TestInlineQueryResultVenueBase.thumbnail_url, - thumb_height=TestInlineQueryResultVenueBase.thumbnail_height, # deprecated arg - thumbnail_width=TestInlineQueryResultVenueBase.thumbnail_width, - ) - assert inline_query_result_venue.thumb_height == inline_query_result_venue.thumbnail_height - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_height", new_name="thumbnail_height" - ) - - def test_thumb_width_property_deprecation_warning(self, recwarn): - inline_query_result_venue = InlineQueryResultVenue( - TestInlineQueryResultVenueBase.id_, - TestInlineQueryResultVenueBase.latitude, - TestInlineQueryResultVenueBase.longitude, - TestInlineQueryResultVenueBase.title, - TestInlineQueryResultVenueBase.address, - foursquare_id=TestInlineQueryResultVenueBase.foursquare_id, - foursquare_type=TestInlineQueryResultVenueBase.foursquare_type, - input_message_content=TestInlineQueryResultVenueBase.input_message_content, - reply_markup=TestInlineQueryResultVenueBase.reply_markup, - google_place_id=TestInlineQueryResultVenueBase.google_place_id, - google_place_type=TestInlineQueryResultVenueBase.google_place_type, - thumbnail_url=TestInlineQueryResultVenueBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultVenueBase.thumbnail_height, - thumb_width=TestInlineQueryResultVenueBase.thumbnail_width, # deprecated arg - ) - assert inline_query_result_venue.thumb_width == inline_query_result_venue.thumbnail_width - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, __file__, deprecated_name="thumb_width", new_name="thumbnail_width" - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_url' and 'thumbnail_url'" - ): - InlineQueryResultVenue( - TestInlineQueryResultVenueBase.id_, - TestInlineQueryResultVenueBase.latitude, - TestInlineQueryResultVenueBase.longitude, - TestInlineQueryResultVenueBase.title, - TestInlineQueryResultVenueBase.address, - foursquare_id=TestInlineQueryResultVenueBase.foursquare_id, - foursquare_type=TestInlineQueryResultVenueBase.foursquare_type, - input_message_content=TestInlineQueryResultVenueBase.input_message_content, - reply_markup=TestInlineQueryResultVenueBase.reply_markup, - google_place_id=TestInlineQueryResultVenueBase.google_place_id, - google_place_type=TestInlineQueryResultVenueBase.google_place_type, - thumbnail_url=TestInlineQueryResultVenueBase.thumbnail_url, - thumb_url="some other url", - thumbnail_height=TestInlineQueryResultVenueBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultVenueBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_height(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_height' and 'thumbnail_height'" - ): - InlineQueryResultVenue( - TestInlineQueryResultVenueBase.id_, - TestInlineQueryResultVenueBase.latitude, - TestInlineQueryResultVenueBase.longitude, - TestInlineQueryResultVenueBase.title, - TestInlineQueryResultVenueBase.address, - foursquare_id=TestInlineQueryResultVenueBase.foursquare_id, - foursquare_type=TestInlineQueryResultVenueBase.foursquare_type, - input_message_content=TestInlineQueryResultVenueBase.input_message_content, - reply_markup=TestInlineQueryResultVenueBase.reply_markup, - google_place_id=TestInlineQueryResultVenueBase.google_place_id, - google_place_type=TestInlineQueryResultVenueBase.google_place_type, - thumbnail_url=TestInlineQueryResultVenueBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultVenueBase.thumbnail_height, - thumb_height=TestInlineQueryResultVenueBase.thumbnail_height + 1, - thumbnail_width=TestInlineQueryResultVenueBase.thumbnail_width, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_width(self): - with pytest.raises( - ValueError, match="different entities as 'thumb_width' and 'thumbnail_width'" - ): - InlineQueryResultVenue( - TestInlineQueryResultVenueBase.id_, - TestInlineQueryResultVenueBase.latitude, - TestInlineQueryResultVenueBase.longitude, - TestInlineQueryResultVenueBase.title, - TestInlineQueryResultVenueBase.address, - foursquare_id=TestInlineQueryResultVenueBase.foursquare_id, - foursquare_type=TestInlineQueryResultVenueBase.foursquare_type, - input_message_content=TestInlineQueryResultVenueBase.input_message_content, - reply_markup=TestInlineQueryResultVenueBase.reply_markup, - google_place_id=TestInlineQueryResultVenueBase.google_place_id, - google_place_type=TestInlineQueryResultVenueBase.google_place_type, - thumbnail_url=TestInlineQueryResultVenueBase.thumbnail_url, - thumbnail_height=TestInlineQueryResultVenueBase.thumbnail_height, - thumbnail_width=TestInlineQueryResultVenueBase.thumbnail_width, - thumb_width=TestInlineQueryResultVenueBase.thumbnail_width + 1, - ) - def test_to_dict(self, inline_query_result_venue): inline_query_result_venue_dict = inline_query_result_venue.to_dict() diff --git a/tests/_inline/test_inlinequeryresultvideo.py b/tests/_inline/test_inlinequeryresultvideo.py index e34eb348c..dc2a08c77 100644 --- a/tests/_inline/test_inlinequeryresultvideo.py +++ b/tests/_inline/test_inlinequeryresultvideo.py @@ -26,7 +26,6 @@ from telegram import ( InputTextMessageContent, MessageEntity, ) -from tests.auxil.deprecations import check_thumb_deprecation_warnings_for_args_and_attrs from tests.auxil.slots import mro_slots @@ -101,145 +100,6 @@ class TestInlineQueryResultVideoWithoutRequest(TestInlineQueryResultVideoBase): ) assert video.caption_entities == () - def test_thumb_url_property_deprecation_warning(self, recwarn): - inline_query_result_video = InlineQueryResultVideo( - TestInlineQueryResultVideoBase.id_, - TestInlineQueryResultVideoBase.video_url, - TestInlineQueryResultVideoBase.mime_type, - TestInlineQueryResultVideoBase.thumbnail_url, - TestInlineQueryResultVideoBase.title, - video_width=TestInlineQueryResultVideoBase.video_width, - video_height=TestInlineQueryResultVideoBase.video_height, - video_duration=TestInlineQueryResultVideoBase.video_duration, - caption=TestInlineQueryResultVideoBase.caption, - parse_mode=TestInlineQueryResultVideoBase.parse_mode, - caption_entities=TestInlineQueryResultVideoBase.caption_entities, - description=TestInlineQueryResultVideoBase.description, - input_message_content=TestInlineQueryResultVideoBase.input_message_content, - reply_markup=TestInlineQueryResultVideoBase.reply_markup, - thumb_url=TestInlineQueryResultVideoBase.thumbnail_url, # deprecated arg - ) - assert inline_query_result_video.thumb_url == inline_query_result_video.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_thumb_url_issues_warning_and_works_without_positional_arg(self, recwarn): - inline_query_result_video = InlineQueryResultVideo( - TestInlineQueryResultVideoBase.id_, - TestInlineQueryResultVideoBase.video_url, - TestInlineQueryResultVideoBase.mime_type, - # Positional argument thumbnail_url should be here, but it's not. Code works fine. - # If user deletes thumb_url from positional arguments and replaces it with a keyword - # argument while keeping `title` as a positional argument, the code will break. - # But it should break, given the fact that the user now passes fewer positional - # arguments than they are expected to. - title=TestInlineQueryResultVideoBase.title, - video_width=TestInlineQueryResultVideoBase.video_width, - video_height=TestInlineQueryResultVideoBase.video_height, - video_duration=TestInlineQueryResultVideoBase.video_duration, - caption=TestInlineQueryResultVideoBase.caption, - parse_mode=TestInlineQueryResultVideoBase.parse_mode, - caption_entities=TestInlineQueryResultVideoBase.caption_entities, - description=TestInlineQueryResultVideoBase.description, - input_message_content=TestInlineQueryResultVideoBase.input_message_content, - reply_markup=TestInlineQueryResultVideoBase.reply_markup, - thumb_url=TestInlineQueryResultVideoBase.thumbnail_url, # deprecated arg - ) - assert inline_query_result_video.thumb_url == inline_query_result_video.thumbnail_url - check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn, - __file__, - deprecated_name="thumb_url", - new_name="thumbnail_url", - ) - - def test_init_throws_error_without_thumbnail_url_and_thumb_url(self): - with pytest.raises(ValueError, match="You must pass either"): - InlineQueryResultVideo( - TestInlineQueryResultVideoBase.id_, - TestInlineQueryResultVideoBase.video_url, - TestInlineQueryResultVideoBase.mime_type, - # no thumbnail_url, no thumb_url - # see note in previous test on `title` being keyword argument here - title=TestInlineQueryResultVideoBase.title, - video_width=TestInlineQueryResultVideoBase.video_width, - video_height=TestInlineQueryResultVideoBase.video_height, - video_duration=TestInlineQueryResultVideoBase.video_duration, - caption=TestInlineQueryResultVideoBase.caption, - parse_mode=TestInlineQueryResultVideoBase.parse_mode, - caption_entities=TestInlineQueryResultVideoBase.caption_entities, - description=TestInlineQueryResultVideoBase.description, - input_message_content=TestInlineQueryResultVideoBase.input_message_content, - reply_markup=TestInlineQueryResultVideoBase.reply_markup, - ) - - def test_throws_type_error_with_title_not_passed_or_is_none(self): - # this test is needed because we had to make argument title optional in declaration of - # __init__() while it is not optional. This had to be done to deal with renaming of - # thumb_url. Hence, we have to enforce `title` being required by checking it. - with pytest.raises(TypeError, match="missing a required argument"): - InlineQueryResultVideo( - TestInlineQueryResultVideoBase.id_, - TestInlineQueryResultVideoBase.video_url, - TestInlineQueryResultVideoBase.mime_type, - TestInlineQueryResultVideoBase.thumbnail_url, - # title is missing - video_width=TestInlineQueryResultVideoBase.video_width, - video_height=TestInlineQueryResultVideoBase.video_height, - video_duration=TestInlineQueryResultVideoBase.video_duration, - caption=TestInlineQueryResultVideoBase.caption, - parse_mode=TestInlineQueryResultVideoBase.parse_mode, - caption_entities=TestInlineQueryResultVideoBase.caption_entities, - description=TestInlineQueryResultVideoBase.description, - input_message_content=TestInlineQueryResultVideoBase.input_message_content, - reply_markup=TestInlineQueryResultVideoBase.reply_markup, - ) - - with pytest.raises(TypeError, match="missing a required argument"): - InlineQueryResultVideo( - TestInlineQueryResultVideoBase.id_, - TestInlineQueryResultVideoBase.video_url, - TestInlineQueryResultVideoBase.mime_type, - TestInlineQueryResultVideoBase.thumbnail_url, - title=None, # the declaration of __init__ allows it, but we don't. - video_width=TestInlineQueryResultVideoBase.video_width, - video_height=TestInlineQueryResultVideoBase.video_height, - video_duration=TestInlineQueryResultVideoBase.video_duration, - caption=TestInlineQueryResultVideoBase.caption, - parse_mode=TestInlineQueryResultVideoBase.parse_mode, - caption_entities=TestInlineQueryResultVideoBase.caption_entities, - description=TestInlineQueryResultVideoBase.description, - input_message_content=TestInlineQueryResultVideoBase.input_message_content, - reply_markup=TestInlineQueryResultVideoBase.reply_markup, - ) - - def test_throws_value_error_with_different_deprecated_and_new_arg_thumb_url(self): - with pytest.raises( - ValueError, - match="different entities as 'thumb_url' and 'thumbnail_url'", - ): - InlineQueryResultVideo( - TestInlineQueryResultVideoBase.id_, - TestInlineQueryResultVideoBase.video_url, - TestInlineQueryResultVideoBase.mime_type, - TestInlineQueryResultVideoBase.thumbnail_url, - TestInlineQueryResultVideoBase.title, - video_width=TestInlineQueryResultVideoBase.video_width, - video_height=TestInlineQueryResultVideoBase.video_height, - video_duration=TestInlineQueryResultVideoBase.video_duration, - caption=TestInlineQueryResultVideoBase.caption, - parse_mode=TestInlineQueryResultVideoBase.parse_mode, - caption_entities=TestInlineQueryResultVideoBase.caption_entities, - description=TestInlineQueryResultVideoBase.description, - input_message_content=TestInlineQueryResultVideoBase.input_message_content, - reply_markup=TestInlineQueryResultVideoBase.reply_markup, - thumb_url="some other url", - ) - def test_to_dict(self, inline_query_result_video): inline_query_result_video_dict = inline_query_result_video.to_dict() diff --git a/tests/auxil/deprecations.py b/tests/auxil/deprecations.py deleted file mode 100644 index 00f5aa9c8..000000000 --- a/tests/auxil/deprecations.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -# A library that provides a Python interface to the Telegram Bot API -# Copyright (C) 2015-2023 -# Leandro Toledo de Souza -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser Public License for more details. -# -# You should have received a copy of the GNU Lesser Public License -# along with this program. If not, see [http://www.gnu.org/licenses/]. - -from _pytest.recwarn import WarningsRecorder - -from telegram.warnings import PTBDeprecationWarning - - -def check_thumb_deprecation_warnings_for_args_and_attrs( - recwarn: WarningsRecorder, - calling_file: str, - deprecated_name: str = "thumb", - new_name: str = "thumbnail", - expected_recwarn_length: int = 2, -) -> bool: - """Check that the correct deprecation warnings are issued. This includes - - * a warning for using the deprecated `thumb...` argument - * a warning for using the deprecated `thumb...` attribute - - Args: - recwarn: pytest's recwarn fixture. - calling_file: The file that called this function. - deprecated_name: Name of deprecated argument/attribute to check in the warning text. - new_name: Name of new argument/attribute to check in the warning text. - expected_recwarn_length: expected number of warnings issued. - - Returns: - True if the correct deprecation warnings were raised, False otherwise. - - Raises: - AssertionError: If the correct deprecation warnings were not raised. - """ - names = ( - ("argument", "attribute") - if expected_recwarn_length == 2 - else ("argument", "argument", "attribute") - ) - actual_recwarn_length = len(recwarn) - assert actual_recwarn_length == expected_recwarn_length, ( - f"expected recwarn length {expected_recwarn_length}, actual length {actual_recwarn_length}" - f". Contents: {[item.message for item in recwarn.list]}" - ) - for i in range(expected_recwarn_length): - assert issubclass(recwarn[i].category, PTBDeprecationWarning) - assert f"{names[i]} '{deprecated_name}' to '{new_name}'" in str(recwarn[i].message), ( - f'Warning issued by file {recwarn[i].filename} ("{recwarn[i].message}") ' - "does not contain expected phrase: " - f"\"{names[i]} '{deprecated_name}' to '{new_name}'\"" - ) - - assert recwarn[i].filename == calling_file, ( - f'Warning for {names[i]} ("{recwarn[i].message}") was issued by file ' - f"{recwarn[i].filename}, expected {calling_file}" - ) - - return True - - -def check_thumb_deprecation_warning_for_method_args( - recwarn: WarningsRecorder, - calling_file: str, - deprecated_name: str = "thumb", - new_name: str = "thumbnail", -): - """Similar as `check_thumb_deprecation_warnings_for_args_and_attrs`, but for bot methods.""" - assert len(recwarn) == 1 - assert recwarn[0].category is PTBDeprecationWarning - assert recwarn[0].filename == calling_file - assert f"argument '{deprecated_name}' to '{new_name}'" in str(recwarn[0].message) diff --git a/tests/docs/admonition_inserter.py b/tests/docs/admonition_inserter.py index c135cbfd1..2ef684ffe 100644 --- a/tests/docs/admonition_inserter.py +++ b/tests/docs/admonition_inserter.py @@ -147,8 +147,8 @@ class TestAdmonitionInserter: ), ( "use_in", - telegram.MaskPosition, - ":meth:`telegram.Bot.add_sticker_to_set`", # optional + telegram.InlineKeyboardMarkup, + ":meth:`telegram.Bot.send_message`", # optional ), ( "use_in", diff --git a/tests/test_bot.py b/tests/test_bot.py index 4a89037dc..232c9aae1 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -78,7 +78,7 @@ from telegram.error import BadRequest, InvalidToken, NetworkError from telegram.ext import ExtBot, InvalidCallbackData from telegram.helpers import escape_markdown from telegram.request import BaseRequest, HTTPXRequest, RequestData -from telegram.warnings import PTBDeprecationWarning, PTBUserWarning +from telegram.warnings import PTBUserWarning from tests.auxil.bot_method_checks import check_defaults_handling from tests.auxil.ci_bots import FALLBACKS from tests.auxil.envvars import GITHUB_ACTION, TEST_WITH_OPT_DEPS @@ -657,7 +657,7 @@ class TestBotWithoutRequest: ) # TODO: Needs improvement. We need incoming inline query to test answer. - @pytest.mark.parametrize("button_type", ["start", "web_app", "backward_compat"]) + @pytest.mark.parametrize("button_type", ["start", "web_app"]) async def test_answer_inline_query(self, monkeypatch, bot, raw_bot, button_type): # For now just test that our internals pass the correct data async def make_assertion(url, request_data: RequestData, *args, **kwargs): @@ -692,7 +692,7 @@ class TestBotWithoutRequest: "is_personal": True, } - if button_type in ["start", "backward_compat"]: + if button_type == "start": button_dict = {"text": "button_text", "start_parameter": "start_parameter"} else: button_dict = { @@ -741,10 +741,6 @@ class TestBotWithoutRequest: cache_time=300, is_personal=True, next_offset="42", - switch_pm_text="button_text" if button_type == "backward_compat" else None, - switch_pm_parameter="start_parameter" - if button_type == "backward_compat" - else None, button=button, ) @@ -766,43 +762,6 @@ class TestBotWithoutRequest: monkeypatch.delattr(bot.request, "post") - @pytest.mark.parametrize("bot_class", ["Bot", "ExtBot"]) - async def test_answer_inline_query_deprecated_args( - self, monkeypatch, recwarn, bot_class, bot, raw_bot - ): - async def mock_post(*args, **kwargs): - return True - - bot = raw_bot if bot_class == "Bot" else bot - - monkeypatch.setattr(bot.request, "post", mock_post) - - with pytest.raises( - TypeError, match="6.7, the parameter `button is mutually exclusive to the deprecated" - ): - await bot.answer_inline_query( - inline_query_id="123", - results=[], - button=True, - switch_pm_text="text", - switch_pm_parameter="param", - ) - - recwarn.clear() - assert await bot.answer_inline_query( - inline_query_id="123", - results=[], - switch_pm_text="text", - switch_pm_parameter="parameter", - ) - assert len(recwarn) == 1 - assert recwarn[-1].category is PTBDeprecationWarning - assert str(recwarn[-1].message).startswith( - "Since Bot API 6.7, the parameters `switch_pm_text` and `switch_pm_parameter` are " - "deprecated" - ) - assert recwarn[-1].filename == __file__, "stacklevel is incorrect!" - async def test_answer_inline_query_no_default_parse_mode(self, monkeypatch, bot): async def make_assertion(url, request_data: RequestData, *args, **kwargs): return request_data.parameters == { diff --git a/tests/test_chatmember.py b/tests/test_chatmember.py index 265ac2a95..fa49d2ce2 100644 --- a/tests/test_chatmember.py +++ b/tests/test_chatmember.py @@ -106,7 +106,6 @@ def chat_member_restricted(): CMDefaults.can_invite_users, CMDefaults.can_pin_messages, CMDefaults.can_send_messages, - CMDefaults.can_send_media_messages, CMDefaults.can_send_polls, CMDefaults.can_send_other_messages, CMDefaults.can_add_web_page_previews, @@ -260,6 +259,14 @@ class TestChatMemberTypesWithoutRequest: for slot in chat_member_type.__slots__: # additional verification for the optional args assert getattr(chat_member_type, slot) == chat_member_dict[slot] + def test_chat_member_restricted_api_kwargs(self, chat_member_type): + json_dict = make_json_dict(chat_member_restricted()) + json_dict["can_send_media_messages"] = "can_send_media_messages" + chat_member_restricted_instance = ChatMember.de_json(json_dict, None) + assert chat_member_restricted_instance.api_kwargs == { + "can_send_media_messages": "can_send_media_messages", + } + def test_equality(self, chat_member_type): a = ChatMember(status="status", user=CMDefaults.user) b = ChatMember(status="status", user=CMDefaults.user) diff --git a/tests/test_chatpermissions.py b/tests/test_chatpermissions.py index e5b9563c2..9ba3df5bd 100644 --- a/tests/test_chatpermissions.py +++ b/tests/test_chatpermissions.py @@ -20,7 +20,6 @@ import pytest from telegram import ChatPermissions, User -from telegram.warnings import PTBDeprecationWarning from tests.auxil.slots import mro_slots @@ -28,7 +27,6 @@ from tests.auxil.slots import mro_slots def chat_permissions(): return ChatPermissions( can_send_messages=True, - can_send_media_messages=True, can_send_polls=True, can_send_other_messages=True, can_add_web_page_previews=True, @@ -47,7 +45,6 @@ def chat_permissions(): class TestChatPermissionsBase: can_send_messages = True - can_send_media_messages = True can_send_polls = True can_send_other_messages = False can_add_web_page_previews = False @@ -73,7 +70,7 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): def test_de_json(self, bot): json_dict = { "can_send_messages": self.can_send_messages, - "can_send_media_messages": self.can_send_media_messages, + "can_send_media_messages": "can_send_media_messages", "can_send_polls": self.can_send_polls, "can_send_other_messages": self.can_send_other_messages, "can_add_web_page_previews": self.can_add_web_page_previews, @@ -88,10 +85,9 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): "can_send_voice_notes": self.can_send_voice_notes, } permissions = ChatPermissions.de_json(json_dict, bot) - assert permissions.api_kwargs == {} + assert permissions.api_kwargs == {"can_send_media_messages": "can_send_media_messages"} assert permissions.can_send_messages == self.can_send_messages - assert permissions.can_send_media_messages == self.can_send_media_messages assert permissions.can_send_polls == self.can_send_polls assert permissions.can_send_other_messages == self.can_send_other_messages assert permissions.can_add_web_page_previews == self.can_add_web_page_previews @@ -111,9 +107,6 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): assert isinstance(permissions_dict, dict) assert permissions_dict["can_send_messages"] == chat_permissions.can_send_messages - assert ( - permissions_dict["can_send_media_messages"] == chat_permissions.can_send_media_messages - ) assert permissions_dict["can_send_polls"] == chat_permissions.can_send_polls assert ( permissions_dict["can_send_other_messages"] == chat_permissions.can_send_other_messages @@ -136,7 +129,6 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): def test_equality(self): a = ChatPermissions( can_send_messages=True, - can_send_media_messages=True, can_send_polls=True, can_send_other_messages=False, ) @@ -144,18 +136,26 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): can_send_polls=True, can_send_other_messages=False, can_send_messages=True, - can_send_media_messages=True, ) c = ChatPermissions( can_send_messages=False, - can_send_media_messages=True, can_send_polls=True, can_send_other_messages=False, ) d = User(123, "", False) e = ChatPermissions( can_send_messages=True, - can_send_media_messages=True, + can_send_polls=True, + can_send_other_messages=False, + can_send_audios=True, + can_send_documents=True, + can_send_photos=True, + can_send_videos=True, + can_send_video_notes=True, + can_send_voice_notes=True, + ) + f = ChatPermissions( + can_send_messages=True, can_send_polls=True, can_send_other_messages=False, can_send_audios=True, @@ -176,9 +176,11 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): assert a != d assert hash(a) != hash(d) - # we expect this to be true since we don't compare these in V20 - assert a == e - assert hash(a) == hash(e) + assert a != e + assert hash(a) != hash(e) + + assert e == f + assert hash(e) == hash(f) def test_all_permissions(self): f = ChatPermissions() @@ -203,14 +205,3 @@ class TestChatPermissionsWithoutRequest(TestChatPermissionsBase): assert t[key] is False # and as a finisher, make sure the default is different. assert f != t - - def test_equality_warning(self, recwarn, chat_permissions): - recwarn.clear() - assert chat_permissions == ChatPermissions.all_permissions() - - assert str(recwarn[0].message) == ( - "In v21, granular media settings will be considered as well when comparing" - " ChatPermissions instances." - ) - assert recwarn[0].category is PTBDeprecationWarning - assert recwarn[0].filename == __file__, "wrong stacklevel" diff --git a/tests/test_forum.py b/tests/test_forum.py index 656ad8259..d367fc9c9 100644 --- a/tests/test_forum.py +++ b/tests/test_forum.py @@ -186,15 +186,15 @@ class TestForumMethodsWithRequest: assert not first_sticker.is_video assert first_sticker.set_name == "Topics" assert first_sticker.type == Sticker.CUSTOM_EMOJI - assert first_sticker.thumb.width == 128 - assert first_sticker.thumb.height == 128 + assert first_sticker.thumbnail.width == 128 + assert first_sticker.thumbnail.height == 128 # The following data of first item returned has changed in the past already, # so check sizes loosely and ID's only by length of string - assert first_sticker.thumb.file_size in range(2000, 7000) + assert first_sticker.thumbnail.file_size in range(2000, 7000) assert first_sticker.file_size in range(20000, 70000) assert len(first_sticker.custom_emoji_id) == 19 - assert len(first_sticker.thumb.file_unique_id) == 16 + assert len(first_sticker.thumbnail.file_unique_id) == 16 assert len(first_sticker.file_unique_id) == 15 async def test_edit_forum_topic(self, emoji_id, forum_group_id, bot, real_topic): diff --git a/tests/test_keyboardbutton.py b/tests/test_keyboardbutton.py index a1f2f7466..a18ca4ccd 100644 --- a/tests/test_keyboardbutton.py +++ b/tests/test_keyboardbutton.py @@ -26,7 +26,6 @@ from telegram import ( KeyboardButtonRequestUser, WebAppInfo, ) -from telegram.warnings import PTBDeprecationWarning from tests.auxil.slots import mro_slots @@ -117,6 +116,12 @@ class TestKeyboardButtonWithoutRequest(TestKeyboardButtonBase): request_chat=KeyboardButtonRequestChat(1, False), request_user=KeyboardButtonRequestUser(2), ) + g = KeyboardButton( + "test", + request_contact=True, + request_chat=KeyboardButtonRequestChat(1, False), + request_user=KeyboardButtonRequestUser(2), + ) assert a == b assert hash(a) == hash(b) @@ -130,17 +135,8 @@ class TestKeyboardButtonWithoutRequest(TestKeyboardButtonBase): assert a != e assert hash(a) != hash(e) - # we expect this to be true since we don't compare these in V20 - assert a == f - assert hash(a) == hash(f) + assert a != f + assert hash(a) != hash(f) - def test_equality_warning(self, recwarn, keyboard_button): - recwarn.clear() - assert keyboard_button == keyboard_button # noqa: PLR0124 - - assert str(recwarn[0].message) == ( - "In v21, `request_user` and `request_chat` will be considered as well when comparing" - " KeyboardButton instances." - ) - assert recwarn[0].category is PTBDeprecationWarning - assert recwarn[0].filename == __file__, "wrong stacklevel" + assert f == g + assert hash(f) == hash(g) diff --git a/tests/test_message.py b/tests/test_message.py index 0bcdc3a35..9fbc36bc8 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -60,7 +60,6 @@ from telegram import ( from telegram._utils.datetime import UTC from telegram.constants import ChatAction, ParseMode from telegram.ext import Defaults -from telegram.warnings import PTBDeprecationWarning from tests._passport.test_passport import RAW_PASSPORT_DATA from tests.auxil.bot_method_checks import ( check_defaults_handling, @@ -648,7 +647,6 @@ class TestMessageWithoutRequest(TestMessageBase): ) def test_text_custom_emoji_md_v1(self, type_, recwarn): text = "Look a custom emoji: 😎" - expected = "Look a custom emoji: 😎" emoji_entity = MessageEntity( type=MessageEntity.CUSTOM_EMOJI, offset=21, @@ -663,14 +661,8 @@ class TestMessageWithoutRequest(TestMessageBase): text=text, entities=[emoji_entity], ) - assert expected == getattr(message, type_) - - assert len(recwarn) == 1 - assert recwarn[0].category is PTBDeprecationWarning - assert str(recwarn[0].message).startswith( - "Custom emoji entities are not supported for Markdown version 1" - ) - assert recwarn[0].filename == __file__ + with pytest.raises(ValueError, match="Custom emoji entities are not supported for"): + getattr(message, type_) @pytest.mark.parametrize( "type_", @@ -845,7 +837,6 @@ class TestMessageWithoutRequest(TestMessageBase): ) def test_caption_custom_emoji_md_v1(self, type_, recwarn): caption = "Look a custom emoji: 😎" - expected = "Look a custom emoji: 😎" emoji_entity = MessageEntity( type=MessageEntity.CUSTOM_EMOJI, offset=21, @@ -860,14 +851,8 @@ class TestMessageWithoutRequest(TestMessageBase): caption=caption, caption_entities=[emoji_entity], ) - assert expected == getattr(message, type_) - - assert len(recwarn) == 1 - assert recwarn[0].category is PTBDeprecationWarning - assert str(recwarn[0].message).startswith( - "Custom emoji entities are not supported for Markdown version 1" - ) - assert recwarn[0].filename == __file__ + with pytest.raises(ValueError, match="Custom emoji entities are not supported for"): + getattr(message, type_) @pytest.mark.parametrize( "type_", diff --git a/tests/test_official.py b/tests/test_official.py index f959705cc..f39a8ec12 100644 --- a/tests/test_official.py +++ b/tests/test_official.py @@ -108,13 +108,6 @@ IGNORED_PARAM_REQUIREMENTS = { "send_venue": {"latitude", "longitude", "title", "address"}, "send_contact": {"phone_number", "first_name"}, # ----> - # These are optional for now for backwards compatibility - # <---- - "InlineQueryResult(Article|Photo|Gif|Mpeg4Gif|Video|Document|Location|Venue)": { - "thumbnail_url", - }, - "InlineQueryResultVideo": {"title"}, - # ----> } @@ -123,39 +116,7 @@ def ignored_param_requirements(object_name) -> Set[str]: # Arguments that are optional arguments for now for backwards compatibility -BACKWARDS_COMPAT_KWARGS = { - "create_new_sticker_set": { - "stickers", - "sticker_format", - "emojis", - "png_sticker", - "tgs_sticker", - "mask_position", - "webm_sticker", - }, - "add_sticker_to_set": { - "sticker", - "tgs_sticker", - "png_sticker", - "webm_sticker", - "mask_position", - "emojis", - }, - "upload_sticker_file": {"sticker", "sticker_format", "png_sticker"}, - "send_(animation|audio|document|video(_note)?)": {"thumb"}, - "(Animation|Audio|Document|Photo|Sticker(Set)?|Video|VideoNote|Voice)": {"thumb"}, - "InputMedia(Animation|Audio|Document|Video)": {"thumb"}, - "Chat(MemberRestricted|Permissions)": {"can_send_media_messages"}, - "InlineQueryResult(Article|Contact|Document|Location|Venue)": { - "thumb_height", - "thumb_width", - }, - "InlineQueryResult(Article|Photo|Gif|Mpeg4Gif|Video|Contact|Document|Location|Venue)": { - "thumb_url", - }, - "InlineQueryResult(Game|Gif|Mpeg4Gif)": {"thumb_mime_type"}, - "answer_inline_query": {"switch_pm_text", "switch_pm_parameter"}, -} +BACKWARDS_COMPAT_KWARGS = {} def backwards_compat_kwargs(object_name: str) -> Set[str]: