reply_text and making mypy happy · python-telegram-bot/python-telegram-bot · Discussion #5073 · GitHub
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
-
Heading
-
Bold
-
Italic
-
Quote
-
Code
-
Link
-
Numbered list
-
Unordered list
-
Task list
-
Attach files
-
Mention
-
Reference
👍
1
reacted with thumbs up emoji
👎
1
reacted with thumbs down emoji
😄
1
reacted with laugh emoji
🎉
1
reacted with hooray emoji
😕
1
reacted with confused emoji
❤️
1
reacted with heart emoji
🚀
1
reacted with rocket emoji
👀
1
reacted with eyes emoji
Footer
You can’t perform that action at this time.
Uh oh!
There was an error while loading. Please reload this page.
{{title}}
Uh oh!
There was an error while loading. Please reload this page.
-
Consider a pretty standard command callback function:
mypy will complain about this as message can vary depending on different calling contexts:
error: Item "None" of "Message | None" has no attribute "reply_text" [union-attr]
To keep mypy happy I've taken to using this pattern in all my callbacks:
But its kind of annoying repeating this everywhere, and moreoever, none of the code examples seem bother with this. I know mypy isn't the be-all-end-all, but I'm curious about this discrepancy.
Beta Was this translation helpful? Give feedback.