Updates to the poll section in bot API 9.6#5202
Conversation
harshil21
left a comment
There was a problem hiding this comment.
Good work so far! About the deprecated things in this API update, this PR shows how we've done it in the past. Note the comments in the code which says "tags", and the warnings which are raised in the code if something deprecated is used. Can you implement that too?
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
…legram-bot into api-9.6-polls
…d other improvements.
Poolitzer
left a comment
There was a problem hiding this comment.
LGTM but dont we need a test for polloptions?
There was a problem hiding this comment.
Pull request overview
This PR updates the library to match Telegram Bot API 9.6 poll-related changes by extending poll models, adding new poll service-message types, and wiring new poll parameters through bot shortcut methods and filters.
Changes:
- Add new poll-related fields (
description,allows_revoting,correct_option_ids, persistent IDs, etc.) and deprecatecorrect_option_idin favor ofcorrect_option_ids. - Introduce
PollOptionAdded/PollOptionDeletedservice-message objects and add corresponding message types & filters. - Update tests and constants to cover the new/changed poll functionality.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_reply.py | Extends ReplyParameters tests to cover poll_option_id. |
| tests/test_poll.py | Adds coverage for new poll/poll option fields and new poll service-message objects. |
| tests/test_message.py | Extends message fixture/test matrix to include new poll service-message fields. |
| tests/test_constants.py | Updates constant/type-attribute expectations for new message fields. |
| tests/test_bot.py | Adds test ensuring deprecated correct_option_id is mapped to correct_option_ids with a warning. |
| tests/ext/test_filters.py | Adds tests for new filters.StatusUpdate poll-option service messages. |
| src/telegram/ext/filters.py | Adds StatusUpdate.POLL_OPTION_ADDED/DELETED filters and includes them in StatusUpdate.ALL. |
| src/telegram/ext/_extbot.py | Wires new Bot API 9.6 poll parameters through ExtBot.send_poll. |
| src/telegram/constants.py | Adds new MessageType entries and updates poll limits (open period, description length). |
| src/telegram/_utils/types.py | Introduces CorrectOptionIds typing alias for multi-answer quizzes. |
| src/telegram/_user.py | Wires new poll parameters through User.send_poll shortcut. |
| src/telegram/_reply.py | Documents and implements ReplyParameters.poll_option_id; updates entity allow-list wording. |
| src/telegram/_poll.py | Extends PollOption, PollAnswer, Poll; adds PollOptionAdded/Deleted; adds parsing helpers and deprecations. |
| src/telegram/_message.py | Adds new message fields for poll option add/delete service messages and reply-to poll option IDs; wires reply_poll params. |
| src/telegram/_inputchecklist.py | Updates documentation wording re: allowed entities (includes date_time). |
| src/telegram/_chat.py | Wires new poll parameters through Chat.send_poll shortcut. |
| src/telegram/_bot.py | Adds new send_poll parameters and deprecation shim for correct_option_id. |
| src/telegram/init.py | Exposes PollOptionAdded/PollOptionDeleted in the public API. |
| changes/unreleased/5196.7keq7yJhXbMb9RyShLHz4D.toml | Adds PR metadata entry for this change set. |
Poolitzer
left a comment
There was a problem hiding this comment.
LGTM just one remark, and codecov seems to be a valid issue, do you have that in mind?
| @@ -93,6 +93,11 @@ | |||
|
|
|||
| CorrectOptionID: TypeAlias = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # pylint: disable=invalid-name | |||
There was a problem hiding this comment.
should we also deprecate this?
There was a problem hiding this comment.
Yeah good idea. It would be a documentation note only though, having the warning on module attribute access is kinda complicated
There was a problem hiding this comment.
actually this module is private so it's not in the documentation anyway... skipping this entirely then.
4f36bff
into
python-telegram-bot:api-9.6-central
Check-list for PRs
.. versionadded:: NEXT.VERSION,.. versionchanged:: NEXT.VERSION,.. deprecated:: NEXT.VERSIONor ``.. versionremoved:: NEXT.VERSION` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)AUTHORS.rst(optional)__all__sIf the PR contains API changes (otherwise, you can ignore this passage)
Checked the Bot API specific sections of the Stability Policy
Created a PR to remove functionality deprecated in the previous Bot API release (see here)
New Classes
self._id_attrsand corresponding documentation__init__acceptsapi_kwargsas keyword-onlyAdded New Shortcuts
telegram.Chat&telegram.Userfor all methods that acceptchat/user_idtelegram.Messagefor all methods that acceptchat_idandmessage_idtelegram.Messageshortcuts: Addedquoteargument if methods acceptreply_to_message_idtelegram.CallbackQueryfor all methods that accept eitherchat_idandmessage_idorinline_message_idIf Relevant
telegram.constantsand shortcuts to them as class variablestelegram.Message.effective_attachmenttelegram.ext.ConversationHandler_extbot.pybot_methods.rstREADME.rst(including the badge) andtelegram.constants.BOT_API_VERSION_INFOtelegram.ext.ExtBotfor new methods that either accept areply_markupin some form or have a return type that is/containstelegram.Message