René's URL Explorer Experiment


Title: Paramspec Mapped Types · Issue #1506 · python/typing · GitHub

Open Graph Title: Paramspec Mapped Types · Issue #1506 · python/typing

X Title: Paramspec Mapped Types · Issue #1506 · python/typing

Description: Apologies if this has already been asked/solved - I can't figure out exactly what this is called so it's very difficult to search for. I'm writing a simple strongly typed dependency system, based on function closures. I have a decorator ...

Open Graph Description: Apologies if this has already been asked/solved - I can't figure out exactly what this is called so it's very difficult to search for. I'm writing a simple strongly typed dependency system, based o...

X Description: Apologies if this has already been asked/solved - I can't figure out exactly what this is called so it's very difficult to search for. I'm writing a simple strongly typed dependency sys...

Opengraph URL: https://github.com/python/typing/issues/1506

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Paramspec Mapped Types","articleBody":"Apologies if this has already been asked/solved - I can't figure out exactly what this is called so it's very difficult to search for.\r\n\r\nI'm writing a simple strongly typed dependency system, based on function closures. I have a decorator function that has this typing:\r\n\r\n```python\r\n# This is a stand-in for a full class implementation that has a __call__ method matching\r\n# Callable[P, Awaitable[R]] - I'm just omitting it for brevity\r\ntype CallableObject[**P, R] = Callable[P, Awaitable[R]]\r\n\r\ndef dependency[**P, R](*args: P.args, **kwargs: P.kwargs) -> Callable[\r\n    [Callable[P, Awaitable[R]] | Callable[P, R]], CallableObject\r\n]:\r\n    ...\r\n```\r\n\r\nThis works to a degree, but, I want to transform the arguments in `P` to also accept functions that return the arguments type or an `Awaitable` of that type. For example:\r\n\r\n```python\r\ndef one() -> int:\r\n    return 1\r\n\r\ndef two() -> int:\r\n    return 2\r\n\r\n@dependency()\r\ndef three(one: int, two: int) -> int:\r\n    return one + two\r\n\r\n# I want the decorated three to have this signature\r\ndef decorated_three(one: int | Callable[..., Awaitable[int] | int], two: int | Callable[..., Awaitable[int] | int]) -> int:\r\n    ...\r\n```\r\n\r\nEssentially, I want to apply a mapping to every arg and kwarg in `P` that transforms it into `P | Callable[..., Awaitable[P] | P]`. Is this possible with the current grammar?\r\n\r\nAs a reference, I wrote an example that does what I'm attempting to do in typescript, where you can unpack what they call \"type tuples\" using the `keyof` syntax to mutate their values:\r\n\r\n```typescript\r\nfunction dependency\u003cP extends unknown[], R>(wrap: (...args: P) => R): (...args: {[V in keyof P]: P[V] | ((...args: any) => P[V] | Promise\u003cP[V]>)}) => R {\r\n    return wrap as any\r\n}\r\n\r\nfunction one(): number { return 1 }\r\n\r\nfunction two(): number { return 2 }\r\n\r\nfunction three(one: number, two: number): number { return one + two }\r\n\r\n// Has type: const decorated_three: (one: number | ((...args: any) => number | Promise\u003cnumber>), two: number | ((...args: any) => number | Promise\u003cnumber>)) => number;\r\nconst decorated_three = dependency(three)\r\n```\r\n([Playground](https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAEwKYAdVjZAngHgAVFUAPKLZAZ0XAGsw4B3MAbQF0AaRAJQD4AFEwBOAQ3QAuRAIB0c0cIDmVKYQCUiALx9eaqbPlKViAN6sAaohhI6qXHGCJC7VRfaIAPtIMyFyqaJguBraTm6eTsJwALYwVKhEbnxqAL4hOjymAFCIuYjCqFAgwkgi4oiiNIG4WSlZWaCQsAiICKgCeohgINEARqjCpvmFxUgAjIh1DeDQ8EhQTHAdUt19A0MFRSWIAEyT9Y2zLVAAFgXtbSs9-cLcC3BXa8KdqzcbI9ttiADUiPf7WQA9IDEAAJSp-XCYKQQBBUKAoVCwsQUZAAfVO530ly613WXgEPj8xmq6VxTwihCisXi+FeA2Sd0WjzeBKJRgCQTJ9MGXipMTiCR5yW5eOEAG4srCwPDEcjRKiMWdUKgtIjMNgsBBcAJMSq1EA) where you can see / verify the typing works as expected)\r\n\r\nApologies for dragging in another type system/language - I'm just looking for the python equivalent (if it exists).\r\n\r\nAppreciate the help in advance. If this is a duplicate, please close it and mark it with the correct issue - I just couldn't find it 😅 \r\n","author":{"url":"https://github.com/cjntaylor","@type":"Person","name":"cjntaylor"},"datePublished":"2023-11-10T18:41:09Z","url":"https://github.com/python/typing/issues/1506"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:488efcff-8e6d-2418-44f6-cd90d2064980
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAFCA:D064:758930:9E4277:6AFF8FD8
html-safe-nonce9a4a945cc8576727b7cdbf4dc2ffbd1d43920a98fb95fe5abd1e0e0aff9fdb61
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkNBOkQwNjQ6NzU4OTMwOjlFNDI3Nzo2QUZGOEZEOCIsInZpc2l0b3JfaWQiOiIyNjEwMjM5Njk1NjAyMjkwNjQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf1f2a078d8868c96e24c58afa17b3aa6022262d73f8f53e66dceb59da4b2dffd
hovercard-subject-tagissue:1988165486
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typing/1506/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f354fb6b514be1a040abf82bc255c2de0e9e7e1047fc7cb5b935ffdcade35ef6/python/typing/issues/1506
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f354fb6b514be1a040abf82bc255c2de0e9e7e1047fc7cb5b935ffdcade35ef6/python/typing/issues/1506
og:image:altApologies if this has already been asked/solved - I can't figure out exactly what this is called so it's very difficult to search for. I'm writing a simple strongly typed dependency system, based o...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecjntaylor
hostnamegithub.com
expected-hostnamegithub.com
None2c75d045e8c84b51e2ac680086a6dd1eeaf2bc15b82137d22ee5106835d6256c
turbo-cache-controlno-preview
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseaa486b0389431f870c0adf9d4758aaff807c2d97
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typing/issues/1506#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F1506
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%2Ftyping%2Fissues%2F1506
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Ftyping
Reloadhttps://github.com/python/typing/issues/1506
Reloadhttps://github.com/python/typing/issues/1506
Reloadhttps://github.com/python/typing/issues/1506
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
https://github.com/python/typing
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/1506
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/1506
Paramspec Mapped Typeshttps://github.com/python/typing/issues/1506#top
topic: otherOther topics not coveredhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20other%22
https://github.com/cjntaylor
cjntaylorhttps://github.com/cjntaylor
on Nov 10, 2023https://github.com/python/typing/issues/1506#issue-1988165486
Playgroundhttps://www.typescriptlang.org/play#code/GYVwdgxgLglg9mABAEwKYAdVjZAngHgAVFUAPKLZAZ0XAGsw4B3MAbQF0AaRAJQD4AFEwBOAQ3QAuRAIB0c0cIDmVKYQCUiALx9eaqbPlKViAN6sAaohhI6qXHGCJC7VRfaIAPtIMyFyqaJguBraTm6eTsJwALYwVKhEbnxqAL4hOjymAFCIuYjCqFAgwkgi4oiiNIG4WSlZWaCQsAiICKgCeohgINEARqjCpvmFxUgAjIh1DeDQ8EhQTHAdUt19A0MFRSWIAEyT9Y2zLVAAFgXtbSs9-cLcC3BXa8KdqzcbI9ttiADUiPf7WQA9IDEAAJSp-XCYKQQBBUKAoVCwsQUZAAfVO530ly613WXgEPj8xmq6VxTwihCisXi+FeA2Sd0WjzeBKJRgCQTJ9MGXipMTiCR5yW5eOEAG4srCwPDEcjRKiMWdUKgtIjMNgsBBcAJMSq1EA
cjntaylorhttps://github.com/cjntaylor
topic: otherOther topics not coveredhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20other%22
on Nov 10, 2023https://github.com/python/typing/issues/1506#event-10928352512
cjntaylorhttps://github.com/cjntaylor
on Nov 10, 2023https://github.com/python/typing/issues/1506#event-10928403844
https://github.com/cjntaylor
cjntaylorhttps://github.com/cjntaylor
on Nov 10, 2023https://github.com/python/typing/issues/1506#issuecomment-1806254800
Mapped Typeshttps://www.typescriptlang.org/docs/handbook/2/mapped-types.html
https://github.com/erictraut
erictrauthttps://github.com/erictraut
on Nov 10, 2023https://github.com/python/typing/issues/1506#issuecomment-1806344547
https://github.com/cjntaylor
cjntaylorhttps://github.com/cjntaylor
on Nov 10, 2023https://github.com/python/typing/issues/1506#issuecomment-1806365141
https://github.com/erictraut
erictrauthttps://github.com/erictraut
on Nov 10, 2023https://github.com/python/typing/issues/1506#issuecomment-1806382867
this discussion threadhttps://github.com/python/typing/discussions/1412#discussioncomment-6200557
https://github.com/oxinabox
oxinaboxhttps://github.com/oxinabox
on Aug 26, 2026https://github.com/python/typing/issues/1506#issuecomment-5420356257
https://peps.python.org/pep-0827https://peps.python.org/pep-0827
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/1506
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/1506
topic: otherOther topics not coveredhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20other%22
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.