New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use explicit optional instead of implicit optional in whole project #3692
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. |
There was a problem hiding this comment.
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?
@Bibo-Joshi nope LGTM ✅ |
Thank you very much for your contribution @MiguelX413 ! |
Checklist for PRs
.. versionadded:: version
,.. versionchanged:: version
or.. deprecated:: 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 delete this passage)
New classes:
self._id_attrs
and corresponding documentation__init__
acceptsapi_kwargs
as kw-onlyAdded new shortcuts:
Chat
&User
for all methods that acceptchat/user_id
Message
for all methods that acceptchat_id
andmessage_id
Message
shortcuts: Addedquote
argument if methods acceptsreply_to_message_id
CallbackQuery
for all methods that accept eitherchat_id
andmessage_id
orinline_message_id
If relevant:
telegram.constants
and shortcuts to them as class variablesMessage.effective_attachment
ConversationHandler
_extbot.py
bot_methods.rst
README.rst
andREADME_RAW.rst
(including the badge), as well astelegram.constants.BOT_API_VERSION_INFO
tg.ext.Bot
for new methods that either accept areply_markup
in some form or have a return type that is/containstelegram.Message
This was causing mypy to have problems verifying the integrity of my own codebase which depended on this project.