Skip to content

Commit 75f96b7

Browse files
committed
Remove Functionality Deprecated in v20.x (#4671)
1 parent 451c662 commit 75f96b7

36 files changed

Lines changed: 357 additions & 1014 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
breaking = """This release removes all functionality that was deprecated in v20.x. This is in line with our :ref:`stability policy <stability-policy>`.
2+
This includes the following changes:
3+
4+
- Removed ``filters.CHAT`` (all messages have an associated chat) and ``filters.StatusUpdate.USER_SHARED`` (use ``filters.StatusUpdate.USERS_SHARED`` instead).
5+
- Removed ``Defaults.disable_web_page_preview`` and ``Defaults.quote``. Use ``Defaults.link_preview_options`` and ``Defaults.do_quote`` instead.
6+
- Removed ``ApplicationBuilder.(get_updates_)proxy_url`` and ``HTTPXRequest.proxy_url``. Use ``ApplicationBuilder.(get_updates_)proxy`` and ``HTTPXRequest.proxy`` instead.
7+
- Removed the ``*_timeout`` arguments of ``Application.run_polling`` and ``Updater.start_webhook``. Instead, specify the values via ``ApplicationBuilder.get_updates_*_timeout``.
8+
- Removed ``constants.InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH``. Use ``constants.InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTH`` instead.
9+
- Removed the argument ``quote`` of ``Message.reply_*``. Use ``do_quote`` instead.
10+
- Removed the superfluous ``EncryptedPassportElement.credentials`` without replacement.
11+
- Changed attribute value of ``PassportFile.file_date`` from :obj:`int` to :class:`datetime.datetime`. Make sure to adjust your code accordingly.
12+
- Changed the attribute value of ``PassportElementErrors.file_hashes`` from :obj:`list` to :obj:`tuple`. Make sure to adjust your code accordingly.
13+
- Make ``BaseRequest.read_timeout`` an abstract property. If you subclass ``BaseRequest``, you need to implement this property.
14+
- The default value for ``write_timeout`` now defaults to ``DEFAULT_NONE`` also for bot methods that send media. Previously, it was ``20``. If you subclass ``BaseRequest``, make sure to use your desired write timeout if ``RequestData.multipart_data`` is set.
15+
"""
16+
[[pull_requests]]
17+
uid = "4671"
18+
author_uid = "Bibo-Joshi"
19+
closes_threads = ["4659"]

docs/auxil/kwargs_insertion.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,29 @@
4747
"",
4848
]
4949

50-
media_write_timeout_deprecation_methods = [
51-
"send_photo",
50+
media_write_timeout_change_methods = [
51+
"add_sticker_to_set",
52+
"create_new_sticker_set",
53+
"send_animation",
5254
"send_audio",
5355
"send_document",
56+
"send_media_group",
57+
"send_photo",
5458
"send_sticker",
5559
"send_video",
5660
"send_video_note",
57-
"send_animation",
5861
"send_voice",
59-
"send_media_group",
6062
"set_chat_photo",
6163
"upload_sticker_file",
62-
"add_sticker_to_set",
63-
"create_new_sticker_set",
6464
]
65-
media_write_timeout_deprecation = [
65+
media_write_timeout_change = [
6666
" write_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
6767
" :paramref:`telegram.request.BaseRequest.post.write_timeout`. By default, ``20`` "
6868
" seconds are used as write timeout."
6969
"",
7070
"",
71-
" .. deprecated:: 20.7",
72-
" In future versions, the default value will be changed to "
71+
" .. versionchanged:: NEXT.VERSION",
72+
" The default value changed to "
7373
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
7474
"",
7575
"",

docs/auxil/sphinx_hooks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
find_insert_pos_for_kwargs,
3333
get_updates_read_timeout_addition,
3434
keyword_args,
35-
media_write_timeout_deprecation,
36-
media_write_timeout_deprecation_methods,
35+
media_write_timeout_change,
36+
media_write_timeout_change_methods,
3737
)
3838
from docs.auxil.link_code import LINE_NUMBERS
3939

@@ -116,9 +116,9 @@ def autodoc_process_docstring(
116116

117117
if (
118118
"post.write_timeout`. Defaults to" in to_insert
119-
and method_name in media_write_timeout_deprecation_methods
119+
and method_name in media_write_timeout_change_methods
120120
):
121-
effective_insert: list[str] = media_write_timeout_deprecation
121+
effective_insert: list[str] = media_write_timeout_change
122122
elif get_updates and to_insert.lstrip().startswith("read_timeout"):
123123
effective_insert = [to_insert, *get_updates_read_timeout_addition]
124124
else:

docs/source/stability_policy.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _stability-policy:
2+
13
Stability Policy
24
================
35

telegram/_bot.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
from telegram.request import BaseRequest, RequestData
113113
from telegram.request._httpxrequest import HTTPXRequest
114114
from telegram.request._requestparameter import RequestParameter
115-
from telegram.warnings import PTBDeprecationWarning, PTBUserWarning
115+
from telegram.warnings import PTBUserWarning
116116

117117
if TYPE_CHECKING:
118118
from telegram import (
@@ -4581,19 +4581,7 @@ async def get_updates(
45814581
if not isinstance(read_timeout, DefaultValue):
45824582
arg_read_timeout: float = read_timeout or 0
45834583
else:
4584-
try:
4585-
arg_read_timeout = self._request[0].read_timeout or 0
4586-
except NotImplementedError:
4587-
arg_read_timeout = 2
4588-
self._warn(
4589-
PTBDeprecationWarning(
4590-
"20.7",
4591-
f"The class {self._request[0].__class__.__name__} does not override "
4592-
"the property `read_timeout`. Overriding this property will be mandatory "
4593-
"in future versions. Using 2 seconds as fallback.",
4594-
),
4595-
stacklevel=2,
4596-
)
4584+
arg_read_timeout = self._request[0].read_timeout or 0
45974585

45984586
# Ideally we'd use an aggressive read timeout for the polling. However,
45994587
# * Short polling should return within 2 seconds.

telegram/_inline/inlinequery.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class InlineQuery(TelegramObject):
6262
``auto_pagination``. Use a named argument for those,
6363
and notice that some positional arguments changed position as a result.
6464
65+
.. versionchanged:: NEXT.VERSION
66+
Removed constants ``MIN_START_PARAMETER_LENGTH`` and ``MAX_START_PARAMETER_LENGTH``.
67+
Use :attr:`telegram.constants.InlineQueryResultsButtonLimit.MIN_START_PARAMETER_LENGTH` and
68+
:attr:`telegram.constants.InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTH`
69+
instead.
70+
6571
Args:
6672
id (:obj:`str`): Unique identifier for this query.
6773
from_user (:class:`telegram.User`): Sender.
@@ -202,16 +208,6 @@ async def answer(
202208
203209
.. versionadded:: 13.2
204210
"""
205-
MIN_SWITCH_PM_TEXT_LENGTH: Final[int] = constants.InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH
206-
""":const:`telegram.constants.InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH`
207-
208-
.. versionadded:: 20.0
209-
"""
210-
MAX_SWITCH_PM_TEXT_LENGTH: Final[int] = constants.InlineQueryLimit.MAX_SWITCH_PM_TEXT_LENGTH
211-
""":const:`telegram.constants.InlineQueryLimit.MAX_SWITCH_PM_TEXT_LENGTH`
212-
213-
.. versionadded:: 20.0
214-
"""
215211
MAX_OFFSET_LENGTH: Final[int] = constants.InlineQueryLimit.MAX_OFFSET_LENGTH
216212
""":const:`telegram.constants.InlineQueryLimit.MAX_OFFSET_LENGTH`
217213

telegram/_inline/inlinequeryresultsbutton.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ class InlineQueryResultsButton(TelegramObject):
4747
inside the Web App.
4848
start_parameter (:obj:`str`, optional): Deep-linking parameter for the
4949
:guilabel:`/start` message sent to the bot when user presses the switch button.
50-
:tg-const:`telegram.InlineQuery.MIN_SWITCH_PM_TEXT_LENGTH`-
51-
:tg-const:`telegram.InlineQuery.MAX_SWITCH_PM_TEXT_LENGTH` characters,
52-
only ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed.
50+
:tg-const:`telegram.constants.InlineQueryResultsButtonLimit.MIN_START_PARAMETER_LENGTH`
51+
-
52+
:tg-const:`telegram.constants.InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTH`
53+
characters, only ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed.
5354
5455
Example:
5556
An inline bot that sends YouTube videos can ask the user to connect the bot to
@@ -67,10 +68,10 @@ class InlineQueryResultsButton(TelegramObject):
6768
user presses the button. The Web App will be able to switch back to the inline mode
6869
using the method ``web_app_switch_inline_query`` inside the Web App.
6970
start_parameter (:obj:`str`): Optional. Deep-linking parameter for the
70-
:guilabel:`/start` message sent to the bot when user presses the switch button.
71-
:tg-const:`telegram.InlineQuery.MIN_SWITCH_PM_TEXT_LENGTH`-
72-
:tg-const:`telegram.InlineQuery.MAX_SWITCH_PM_TEXT_LENGTH` characters,
73-
only ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed.
71+
:tg-const:`telegram.constants.InlineQueryResultsButtonLimit.MIN_START_PARAMETER_LENGTH`
72+
-
73+
:tg-const:`telegram.constants.InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTH`
74+
characters, only ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed.
7475
7576
"""
7677

0 commit comments

Comments
 (0)