Title: Make the library more strongly typed · Issue #5272 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: Make the library more strongly typed · Issue #5272 · python-telegram-bot/python-telegram-bot
X Title: Make the library more strongly typed · Issue #5272 · python-telegram-bot/python-telegram-bot
Description: I'm writing this down as more of a general issue, I don't have anything concrete or specific to change just yet. Background I was recently playing around with the polars library, and I was surprised by how good the typing is. If there ar...
Open Graph Description: I'm writing this down as more of a general issue, I don't have anything concrete or specific to change just yet. Background I was recently playing around with the polars library, and I was surprise...
X Description: I'm writing this down as more of a general issue, I don't have anything concrete or specific to change just yet. Background I was recently playing around with the polars library, and I was ...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/5272
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make the library more strongly typed","articleBody":"_I'm writing this down as more of a general issue, I don't have anything concrete or specific to change just yet._\n\n### Background\n\nI was recently playing around with the `polars` library, and I was surprised by how good the typing is. If there are any typing errors in your select query for example, the code would certainly fail at runtime. They support a lot of different operations and codepaths and it all works great with the type system (unlike `pandas`). That got me thinking if we can make PTB better typed, so there's more confidence that there's no runtime errors when you run your bot for the first time.\n\n### Potential area of improvement\n\nThe biggest area of improvement I see is definitely the handler (with filters) -> callback interface. For e.g. when opening echobot.py, `ty` gives me a bunch of typing issues in every callback, mostly because we are accessing attributes which could be `None`. We know they would work at runtime because we have a filter which filters them only when they are not `None`. The typing system does not know this.\n\n### Possible Solution?\n\nI remember discussing this a long time ago in the dev chat, and I think at the time we could not resolve it, since it required making the Update class Generic? Or adding a bunch of type casts everywhere.\n\nI wonder if there is now a better solution to this considering all the new typing features of recent python versions (3.11+). I'm still not that well versed in typing to come up with the best solution yet. \n\nThis is a great opportunity for a new contributor to give their ideas on how to fix this. \n\n","author":{"url":"https://github.com/harshil21","@type":"Person","name":"harshil21"},"datePublished":"2026-06-17T21:07:49Z","url":"https://github.com/python-telegram-bot/python-telegram-bot/issues/5272"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8301b991-2f85-1642-ac4f-9ef8c550b53f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B22C:F11F5:1DC32:26838:6B028799 |
| html-safe-nonce | 4b05575e0aa433facf72f4989bbae77f218105fee175d33ee94f19dab855916d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjJDOkYxMUY1OjFEQzMyOjI2ODM4OjZCMDI4Nzk5IiwidmlzaXRvcl9pZCI6IjYxMTEwNzM5NTUyNTMyMjUzNjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 46ca28a49b8d133c12fe28ad60291a51b14ee03a913758fda9c839cdd1cbc19a |
| hovercard-subject-tag | issue:4687076623 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-telegram-bot/python-telegram-bot/5272/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58513daa60825b08c773826f4966349fdfad0250fa4e910a5fc60f1e5b3bba97/python-telegram-bot/python-telegram-bot/issues/5272 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58513daa60825b08c773826f4966349fdfad0250fa4e910a5fc60f1e5b3bba97/python-telegram-bot/python-telegram-bot/issues/5272 |
| og:image:alt | I'm writing this down as more of a general issue, I don't have anything concrete or specific to change just yet. Background I was recently playing around with the polars library, and I was surprise... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | harshil21 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git |
| octolytics-dimension-user_id | 16178365 |
| octolytics-dimension-user_login | python-telegram-bot |
| octolytics-dimension-repository_id | 38696925 |
| octolytics-dimension-repository_nwo | python-telegram-bot/python-telegram-bot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38696925 |
| octolytics-dimension-repository_network_root_nwo | python-telegram-bot/python-telegram-bot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width