Use explicit optional instead of implicit optional in whole project#3692
Use explicit optional instead of implicit optional in whole project#3692Bibo-Joshi merged 9 commits intopython-telegram-bot:masterfrom
Conversation
|
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: |
@Bibo-Joshi Mypy says the following about https://github.com/MiguelX413/IgTgBot/blob/4586c01fb89283eada0b2c1567e2ee67a02d1bd2/formatted_text.py#L35-L81 only without this PR: |
|
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 |
86e9f1f to
40e8b2d
Compare
|
Thanks for the updates! A number of tests fail because the type hints of shortcut messages don't match the type hint in the 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! |
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 If the tests still fail after that, we'll look into this again. |
UPD: I just did some bulk replacing in my IDE, mypy is happy now. |
Bibo-Joshi
left a comment
There was a problem hiding this comment.
LGTM 👍 @harshil21 do you have anything to add?
|
@Bibo-Joshi nope LGTM ✅ |
|
Thank you very much for your contribution @MiguelX413 ! |
Checklist for PRs
.. versionadded:: version,.. versionchanged:: versionor.. deprecated:: versionto 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 delete this passage)
New classes:
self._id_attrsand corresponding documentation__init__acceptsapi_kwargsas kw-onlyAdded new shortcuts:
Chat&Userfor all methods that acceptchat/user_idMessagefor all methods that acceptchat_idandmessage_idMessageshortcuts: Addedquoteargument if methods acceptsreply_to_message_idCallbackQueryfor all methods that accept eitherchat_idandmessage_idorinline_message_idIf relevant:
telegram.constantsand shortcuts to them as class variablesMessage.effective_attachmentConversationHandler_extbot.pybot_methods.rstREADME.rstandREADME_RAW.rst(including the badge), as well astelegram.constants.BOT_API_VERSION_INFOtg.ext.Botfor new methods that either accept areply_markupin some form or have a return type that is/containstelegram.MessageThis was causing mypy to have problems verifying the integrity of my own codebase which depended on this project.