René's URL Explorer Experiment


Title: Try improving CC type hinting by Bibo-Joshi · Pull Request #3023 · python-telegram-bot/python-telegram-bot · GitHub

Open Graph Title: Try improving CC type hinting by Bibo-Joshi · Pull Request #3023 · python-telegram-bot/python-telegram-bot

X Title: Try improving CC type hinting by Bibo-Joshi · Pull Request #3023 · python-telegram-bot/python-telegram-bot

Description: Effectively just uses a bit of Any to get a best effort result. What we'd like to do is to infer the type of CC.job_queue from the Application. However, this is problematic, as the app has a type for the used (sub)class of CallbackContext itself. in particular, when speciyinf a subclass with ContextTypes, we'd like to somehow say CallbackContext[ExtBot, dict, dict, dict, TypeVar('JQ')] + App[…, JobQueue] = CC[…, JobQueue]. Similar things happen on CC.__init__/from_*. I don't see how this can be achieved with the current status of the typing module, as neither CCT = TypeVar('CCT', bound=CallbackContext) def foo(arg: CCT[BT, UD, CD, BD, JQ]): pass nor something like def foo(arg: CCT) -> CCT.JQ: pass are currently supported. Hence, CallbackContext.job_queue stays annotated as Optional[JobQueue]. @harshil21 if you can test if pyright works with this as well, that would be nice. We can then maybe merge into #3017 and then merge both together into master. Example snippet of what I've tested with mypy: from telegram.ext import ApplicationBuilder, ContextTypes, CallbackContext, ExtBot class CustomContext(CallbackContext[ExtBot, int, dict, dict]): pass context_types = ContextTypes(user_data=int, context=CustomContext) app = ( ApplicationBuilder() .token("123456048:AAGpuiaeuiaeuiaeuiaev76jqr45aA") .context_types(context_types) .job_queue(None) .build() ) reveal_type(app) reveal_type(app.context_types) context = CallbackContext(application=app) reveal_type(context) reveal_type(context.job_queue) reveal_type(CallbackContext.from_update(1, app)) reveal_type(CustomContext.from_update(1, app))

Open Graph Description: Effectively just uses a bit of Any to get a best effort result. What we'd like to do is to infer the type of CC.job_queue from the Application. However, this is problematic, as the app has a ty...

X Description: Effectively just uses a bit of Any to get a best effort result. What we'd like to do is to infer the type of CC.job_queue from the Application. However, this is problematic, as the app has ...

Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/pull/3023

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7b436fda-ef06-2406-85fd-29c0fc5a16d3
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDCC2:2A98A:11021CE:15619C8:6B02569B
html-safe-nonce3f355dd4baa289624209f8c13c5d1bae17f07262c2cc4bb098c3005a46cfe3a7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0MyOjJBOThBOjExMDIxQ0U6MTU2MTlDODo2QjAyNTY5QiIsInZpc2l0b3JfaWQiOiIyOTI2OTkxMjMxNTgwMDAxOTQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaca53300dd888d4ab3a08128c34630a155ada1d8e24abb840687b88630a9d3060c
hovercard-subject-tagpull_request:934078070
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
twitter:imagehttps://avatars.githubusercontent.com/u/22366557?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/22366557?s=400&v=4
og:image:altEffectively just uses a bit of Any to get a best effort result. What we'd like to do is to infer the type of CC.job_queue from the Application. However, this is problematic, as the app has a ty...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git
octolytics-dimension-user_id16178365
octolytics-dimension-user_loginpython-telegram-bot
octolytics-dimension-repository_id38696925
octolytics-dimension-repository_nwopython-telegram-bot/python-telegram-bot
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id38696925
octolytics-dimension-repository_network_root_nwopython-telegram-bot/python-telegram-bot
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fpull%2F3023%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fpull%2F3023%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python-telegram-bot%2Fpython-telegram-bot
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
python-telegram-bothttps://github.com/python-telegram-bot
python-telegram-bothttps://github.com/python-telegram-bot/python-telegram-bot
Codehttps://github.com/python-telegram-bot/python-telegram-bot
Issues23 (23)https://github.com/python-telegram-bot/python-telegram-bot/issues
Pull requests19 (19)https://github.com/python-telegram-bot/python-telegram-bot/pulls
Discussionshttps://github.com/python-telegram-bot/python-telegram-bot/discussions
Actionshttps://github.com/python-telegram-bot/python-telegram-bot/actions
Projectshttps://github.com/python-telegram-bot/python-telegram-bot/projects
Wikihttps://github.com/python-telegram-bot/python-telegram-bot/wiki
Security and qualityhttps://github.com/python-telegram-bot/python-telegram-bot/security
Insightshttps://github.com/python-telegram-bot/python-telegram-bot/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fissues%2Fnew%2Fchoose
Bibo-Joshihttps://github.com/Bibo-Joshi
fix-type-hinthttps://github.com/python-telegram-bot/python-telegram-bot/tree/fix-type-hint
cct-inithttps://github.com/python-telegram-bot/python-telegram-bot/tree/cct-init
Conversation 0 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023
Commits 5 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/commits
Checks 0 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/checks
Files changed https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
Try improving CC type hinting https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#top
Show all changes 5 commits https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
b3c7a3b First try on fixing type hinting for CCT Bibo-Joshi May 9, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/commits/b3c7a3b1c376ce95071a880c91aeb332bfbfac74
3bfabfe Merge remote-tracking branch 'origin/fix-type-hint' into cct-init Bibo-Joshi May 10, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/commits/3bfabfe161d385702f11e7cd21462375152a921a
cb295e9 Try improving CC typing a bit Bibo-Joshi May 11, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/commits/cb295e9c59d1ec9b11aa4adb8694d15d2e4f489a
500674a Merge branch 'fix-type-hint' into cct-init Bibo-Joshi May 12, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/commits/500674ad71a26534808955d9f89d5ece2c7ad895
51a187c pre-commit Bibo-Joshi May 12, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/commits/51a187c8c46d4cdba46ecf93672f2b1ca1255833
Clear filters https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files
_callbackcontext.py https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
_contexttypes.py https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-88915b135ce75024c7cf6264cbe495f517c8123e1803744f2e05e0bf54e47f8a
telegram/ext/_callbackcontext.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/51a187c8c46d4cdba46ecf93672f2b1ca1255833/telegram/ext/_callbackcontext.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/{{ revealButtonHref }}
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-5d865f7851b524bc5ec0a59e458efec6129550c09bc806212b550c02d5df646e
telegram/ext/_contexttypes.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-88915b135ce75024c7cf6264cbe495f517c8123e1803744f2e05e0bf54e47f8a
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/51a187c8c46d4cdba46ecf93672f2b1ca1255833/telegram/ext/_contexttypes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/{{ revealButtonHref }}
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-88915b135ce75024c7cf6264cbe495f517c8123e1803744f2e05e0bf54e47f8a
https://github.com/python-telegram-bot/python-telegram-bot/pull/3023/files#diff-88915b135ce75024c7cf6264cbe495f517c8123e1803744f2e05e0bf54e47f8a
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.