Remove Functionality Deprecated Since Bot API 6.5, 6.6 or 6.7 (#3858)

This commit is contained in:
Bibo-Joshi 2023-09-03 14:23:48 +02:00 committed by GitHub
parent 40ab8aadca
commit f9ccf560f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 419 additions and 3569 deletions

View file

@ -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

View file

@ -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 <https://docs.python-telegram-bot.org/en/stable/examples.customwebhookbot.html>`__), 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 <https://docs.python-telegram-bot.org/en/stable/examples.customwebhookbot.html>`__, 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_*``.

File diff suppressed because it is too large Load diff

View file

@ -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,

View file

@ -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

View file

@ -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)

View file

@ -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(

View file

@ -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,
)

View file

@ -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,
)

View file

@ -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,
)

View file

@ -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 <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 <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

View file

@ -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`."""

View file

@ -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,
)

View file

@ -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,
)

View file

@ -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,

View file

@ -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 <examples.inlinebot>`
.. 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

View file

@ -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

View file

@ -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 <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

View file

@ -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 <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

View file

@ -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`

View file

@ -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 <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

View file

@ -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 <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

View file

@ -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

View file

@ -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

View file

@ -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 <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

View file

@ -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`."""

View file

@ -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.

View file

@ -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,

View file

@ -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,
)

View file

@ -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

View file

@ -147,6 +147,9 @@ class ExtBot(Bot, Generic[RLARGS]):
:attr:`bot.callback_data_cache.maxsize <telegram.ext.CallbackDataCache.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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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()

View file

@ -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 == ()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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()

View file

@ -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 <devs@python-telegram-bot.org>
#
# 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)

View file

@ -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",

View file

@ -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 == {

View file

@ -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)

View file

@ -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"

View file

@ -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):

View file

@ -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)

View file

@ -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_",

View file

@ -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]: