Contributor
Checklist for PRs
- Added
.. versionadded:: version,.. versionchanged:: versionor.. deprecated:: versionto the docstrings for user facing changes (for methods/class descriptions, arguments and attributes) - Created new or adapted existing unit tests
- Documented code changes according to the CSI standard
- Added myself alphabetically to
AUTHORS.rst(optional) - Added new classes & modules to the docs and all suitable
__all__s
If the PR contains API changes (otherwise, you can delete this passage)
-
New classes:
- Added
self._id_attrsand corresponding documentation -
__init__acceptsapi_kwargsas kw-only
- Added
-
Added new shortcuts:
- In
Chat&Userfor all methods that acceptchat/user_id - In
Messagefor all methods that acceptchat_idandmessage_id - For new
Messageshortcuts: Addedquoteargument if methods acceptsreply_to_message_id - In
CallbackQueryfor all methods that accept eitherchat_idandmessage_idorinline_message_id
- In
-
If relevant:
- Added new constants at
telegram.constantsand shortcuts to them as class variables - Link new and existing constants in docstrings instead of hard coded number and strings
- Add new message types to
Message.effective_attachment - Added new handlers for new update types
- Add the handlers to the warning loop in the
ConversationHandler
- Add the handlers to the warning loop in the
- Added new filters for new message (sub)types
- Added or updated documentation for the changed class(es) and/or method(s)
- Added the new method(s) to
_extbot.py - Added or updated
bot_methods.rst - Updated the Bot API version number in all places:
README.rstandREADME_RAW.rst(including the badge), as well astelegram.constants.BOT_API_VERSION_INFO - Added logic for arbitrary callback data in
tg.ext.Botfor new methods that either accept areply_markupin some form or have a return type that is/containstelegram.Message
- Added new constants at
This was causing mypy to have problems verifying the integrity of my own codebase which depended on this project.
Member
Hi. Thanks for the PR. Does the current implicit typing have any negative effect on your usage of the python-telegram-bot library? If it does not, then I would like to reject this PR for the reasons discussed in #3367.
Edit:
Ah, I didnt see your comment at the very end. Can you give an example of how exactly the current status affects the type checking of your code base?
Contributor Author
Hi. Thanks for the PR. Does the current implicit typing have any negative effect on your usage of the python-telegram-bot library? If it does not, then I would like to reject this PR for the reasons discussed in #3367.
Edit: Ah, I didnt see your comment at the very end. Can you give an example of how exactly the current status affects the type checking of your code base?
@Bibo-Joshi Mypy says the following about https://github.com/MiguelX413/IgTgBot/blob/4586c01fb89283eada0b2c1567e2ee67a02d1bd2/formatted_text.py#L35-L81 only without this PR:
formatted_text.py:53: error: Argument "url" to "MessageEntity" has incompatible type "Optional[str]"; expected "str" [arg-type]
formatted_text.py:54: error: Argument "user" to "MessageEntity" has incompatible type "Optional[User]"; expected "User" [arg-type]
formatted_text.py:55: error: Argument "language" to "MessageEntity" has incompatible type "Optional[str]"; expected "str" [arg-type]
formatted_text.py:56: error: Argument "custom_emoji_id" to "MessageEntity" has incompatible type "Optional[str]"; expected "str" [arg-type]
formatted_text.py:75: error: Argument "url" to "MessageEntity" has incompatible type "Optional[str]"; expected "str" [arg-type]
formatted_text.py:76: error: Argument "user" to "MessageEntity" has incompatible type "Optional[User]"; expected "User" [arg-type]
formatted_text.py:77: error: Argument "language" to "MessageEntity" has incompatible type "Optional[str]"; expected "str" [arg-type]
formatted_text.py:78: error: Argument "custom_emoji_id" to "MessageEntity" has incompatible type "Optional[str]"; expected "str" [arg-type]
Member
I see. Since there is a user impact then, we should indeed completely drop the implicit optionals in the whole library. For this, the mypy config file needs to be updated and all the function/method signatures need to be updated. I would guess that some regex-replacing + mypy checking will make this a rather straightforward task. @MiguelX413 would you maybe like to extend your PR?
Contributor Author
I see. Since there is a user impact then, we should indeed completely drop the implicit optionals in the whole library. For this, the mypy config file needs to be updated and all the function/method signatures need to be updated. I would guess that some regex-replacing + mypy checking will make this a rather straightforward task. @MiguelX413 would you maybe like to extend your PR?
Sure! @Bibo-Joshi
MiguelX413
changed the title
Improve PEP 848 no_implicit_optional compliance in _messageentity
Use explicit optional instead of implicit optional in whole project
Member
Thanks for the updates! A number of tests fail because the type hints of shortcut messages don't match the type hint in the Bot class (e.g. Message.reply_text doesn't match Bot.send_message). IISC that's due to some classes being importing only if TYPE_CHECKING and the tests can't resolve the forward references. If you need help with addressing this, please do reach out.
On a side note: please avoid force-pushing (at least once you got review comments), since that makes it hard to keep track of what one has already reviewed :)
Contributor Author
Thanks for the updates! A number of tests fail because the type hints of shortcut messages don't match the type hint in the
Botclass (e.g.Message.reply_textdoesn't matchBot.send_message). IISC that's due to some classes being importing onlyif TYPE_CHECKINGand the tests can't resolve the forward references. If you need help with addressing this, please do reach out.On a side note: please avoid force-pushing (at least once you got review comments), since that makes it hard to keep track of what one has already reviewed :)
Noted!
Contributor Author
Thanks for the updates! A number of tests fail because the type hints of shortcut messages don't match the type hint in the Bot class (e.g. Message.reply_text doesn't match Bot.send_message). IISC that's due to some classes being importing only if TYPE_CHECKING and the tests can't resolve the forward references. If you need help with addressing this, please do reach out.
On a side note: please avoid force-pushing (at least once you got review comments), since that makes it hard to keep track of what one has already reviewed :)
I'm not really sure where to start with the testing system tbh @Bibo-Joshi
Member
I'm not really sure where to start with the testing system tbh @Bibo-Joshi
I tried to fix the testing issues. Also, I merged master with some conflict resolution (and fixed implicit optionals in new args of existing methods), but some new methods that were added to our master and were merged without conflicts contain the implicit optionals and you might want to run your script again :)
If the tests still fail after that, we'll look into this again.
Member
I merged
masterwith some conflict resolution (and fixed implicit optionals in new args of existing methods), but some new methods that were added to ourmasterand were merged without conflicts contain the implicit optionals
UPD: I just did some bulk replacing in my IDE, mypy is happy now.
Member
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ๐ @harshil21 do you have anything to add?
Member
Thank you very much for your contribution @MiguelX413 !