|
17 | 17 | # You should have received a copy of the GNU Lesser Public License |
18 | 18 | # along with this program. If not, see [http://www.gnu.org/licenses/]. |
19 | 19 | """This module contains the class Updater, which tries to make creating Telegram bots intuitive.""" |
| 20 | + |
20 | 21 | import asyncio |
21 | 22 | import contextlib |
22 | 23 | import ssl |
23 | | -from collections.abc import Coroutine |
| 24 | +from collections.abc import Coroutine, Sequence |
24 | 25 | from pathlib import Path |
25 | 26 | from types import TracebackType |
26 | 27 | from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, Union |
@@ -210,7 +211,7 @@ async def start_polling( |
210 | 211 | write_timeout: ODVInput[float] = DEFAULT_NONE, |
211 | 212 | connect_timeout: ODVInput[float] = DEFAULT_NONE, |
212 | 213 | pool_timeout: ODVInput[float] = DEFAULT_NONE, |
213 | | - allowed_updates: Optional[list[str]] = None, |
| 214 | + allowed_updates: Optional[Sequence[str]] = None, |
214 | 215 | drop_pending_updates: Optional[bool] = None, |
215 | 216 | error_callback: Optional[Callable[[TelegramError], None]] = None, |
216 | 217 | ) -> "asyncio.Queue[object]": |
@@ -265,8 +266,11 @@ async def start_polling( |
265 | 266 | Deprecated in favor of setting the timeout via |
266 | 267 | :meth:`telegram.ext.ApplicationBuilder.get_updates_pool_timeout` or |
267 | 268 | :paramref:`telegram.Bot.get_updates_request`. |
268 | | - allowed_updates (list[:obj:`str`], optional): Passed to |
| 269 | + allowed_updates (Sequence[:obj:`str`], optional): Passed to |
269 | 270 | :meth:`telegram.Bot.get_updates`. |
| 271 | +
|
| 272 | + .. versionchanged:: NEXT.VERSION |
| 273 | + Accepts any :class:`collections.abc.Sequence` as input instead of just a list |
270 | 274 | drop_pending_updates (:obj:`bool`, optional): Whether to clean any pending updates on |
271 | 275 | Telegram servers before actually starting to poll. Default is :obj:`False`. |
272 | 276 |
|
@@ -344,7 +348,7 @@ async def _start_polling( |
344 | 348 | pool_timeout: ODVInput[float], |
345 | 349 | bootstrap_retries: int, |
346 | 350 | drop_pending_updates: Optional[bool], |
347 | | - allowed_updates: Optional[list[str]], |
| 351 | + allowed_updates: Optional[Sequence[str]], |
348 | 352 | ready: asyncio.Event, |
349 | 353 | error_callback: Optional[Callable[[TelegramError], None]], |
350 | 354 | ) -> None: |
@@ -457,7 +461,7 @@ async def start_webhook( |
457 | 461 | key: Optional[Union[str, Path]] = None, |
458 | 462 | bootstrap_retries: int = 0, |
459 | 463 | webhook_url: Optional[str] = None, |
460 | | - allowed_updates: Optional[list[str]] = None, |
| 464 | + allowed_updates: Optional[Sequence[str]] = None, |
461 | 465 | drop_pending_updates: Optional[bool] = None, |
462 | 466 | ip_address: Optional[str] = None, |
463 | 467 | max_connections: int = 40, |
@@ -516,8 +520,11 @@ async def start_webhook( |
516 | 520 | Defaults to :obj:`None`. |
517 | 521 |
|
518 | 522 | .. versionadded :: 13.4 |
519 | | - allowed_updates (list[:obj:`str`], optional): Passed to |
| 523 | + allowed_updates (Sequence[:obj:`str`], optional): Passed to |
520 | 524 | :meth:`telegram.Bot.set_webhook`. Defaults to :obj:`None`. |
| 525 | +
|
| 526 | + .. versionchanged:: NEXT.VERSION |
| 527 | + Accepts any :class:`collections.abc.Sequence` as input instead of just a list |
521 | 528 | max_connections (:obj:`int`, optional): Passed to |
522 | 529 | :meth:`telegram.Bot.set_webhook`. Defaults to ``40``. |
523 | 530 |
|
@@ -624,7 +631,7 @@ async def _start_webhook( |
624 | 631 | port: int, |
625 | 632 | url_path: str, |
626 | 633 | bootstrap_retries: int, |
627 | | - allowed_updates: Optional[list[str]], |
| 634 | + allowed_updates: Optional[Sequence[str]], |
628 | 635 | cert: Optional[Union[str, Path]] = None, |
629 | 636 | key: Optional[Union[str, Path]] = None, |
630 | 637 | drop_pending_updates: Optional[bool] = None, |
@@ -767,7 +774,7 @@ async def _bootstrap( |
767 | 774 | self, |
768 | 775 | max_retries: int, |
769 | 776 | webhook_url: Optional[str], |
770 | | - allowed_updates: Optional[list[str]], |
| 777 | + allowed_updates: Optional[Sequence[str]], |
771 | 778 | drop_pending_updates: Optional[bool] = None, |
772 | 779 | cert: Optional[bytes] = None, |
773 | 780 | bootstrap_interval: float = 1, |
|
0 commit comments