René's URL Explorer Experiment


Title: Proposal: Support Unpacked `TypeVarTuple` and `tuple` in `Concatenate` · Issue #2332 · python/typing · GitHub

Open Graph Title: Proposal: Support Unpacked `TypeVarTuple` and `tuple` in `Concatenate` · Issue #2332 · python/typing

X Title: Proposal: Support Unpacked `TypeVarTuple` and `tuple` in `Concatenate` · Issue #2332 · python/typing

Description: Abstract PEP 612 introduced ParamSpec and Concatenate to prepend fixed positional parameters to a callable's signature. PEP 646 introduced TypeVarTuple for variadic positional typing in Callable[[*Ts], R]. Because the two PEPs were devel...

Open Graph Description: Abstract PEP 612 introduced ParamSpec and Concatenate to prepend fixed positional parameters to a callable's signature. PEP 646 introduced TypeVarTuple for variadic positional typing in Callable[[*...

X Description: Abstract PEP 612 introduced ParamSpec and Concatenate to prepend fixed positional parameters to a callable's signature. PEP 646 introduced TypeVarTuple for variadic positional typing in Callabl...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Support Unpacked `TypeVarTuple` and `tuple` in `Concatenate`","articleBody":"## Abstract\n\n[PEP 612](https://peps.python.org/pep-0612/) introduced `ParamSpec` and `Concatenate` to prepend fixed positional parameters to a callable's signature. [PEP 646](https://peps.python.org/pep-0646/) introduced `TypeVarTuple` for variadic positional typing in `Callable[[*Ts], R]`. Because the two PEPs were developed independently, the [typing specification](https://typing.python.org/en/latest/spec/generics.html#valid-use-locations) does not allow unpacked types (`*Ts` or `*tuple[...]`) inside `Concatenate`.\n\nThis proposal extends `Concatenate` to accept `unpack_expression`s in its prefix, enabling `Callable[Concatenate[*Ts, P], R]`.\n\n---\n\n## Motivation\n\nHigher-order abstractions like partial application helpers and execution wrappers need to capture an arbitrary number of leading positional arguments while preserving the remaining signature (keyword-only params, defaults, `**kwargs`) via `ParamSpec`. Today, this requires repetitive overload ladders:\n\n```python\nfrom typing import Any, Callable, Concatenate, overload\n\nclass Wrapper[**P, R]:\n    @overload\n    def __init__(self, fn: Callable[P, R]) -> None: ...\n\n    @overload\n    def __init__[G1](\n        self,\n        fn: Callable[Concatenate[G1, P], R],\n        __g1: G1,\n        /,\n    ) -> None: ...\n\n    @overload\n    def __init__[G1, G2](\n        self,\n        fn: Callable[Concatenate[G1, G2, P], R],\n        __g1: G1,\n        __g2: G2,\n        /,\n    ) -> None: ...\n\n    # Must repeat up to arbitrary maximum arity...\n    def __init__(self, fn: Callable[..., R], *args: Any) -> None:\n        self._fn = fn\n        self._args = args\n\n    def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:\n        return self._fn(*self._args, *args, **kwargs)\n```\n\nWith this proposal, the entire ladder collapses to a single generic signature:\n\n```python\nfrom __future__ import annotations\nfrom typing import Callable, Concatenate\n\nclass Wrapper[**P, R, *Ts]:\n    def __init__(self, fn: Callable[Concatenate[*Ts, P], R], *args: *Ts) -> None:\n        self._fn = fn\n        self._args = args\n\n    def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:\n        return self._fn(*self._args, *args, **kwargs)\n\ndef f(a: str, b: int, *, flag: bool = False, x: float) -> bool: ...\n\n# Ts = () -> P = (a: str, b: int, *, flag: bool = ..., x: float)\nw0 = Wrapper(f)\nr0 = w0(\"hello\", 42, x=3.14, flag=True)  # type: bool\n\n# Ts = (str,) -> P = (b: int, *, flag: bool = ..., x: float)\nw1 = Wrapper(f, \"hello\")\nr1 = w1(42, x=3.14)  # type: bool\n\n# Ts = (str, int) -> P = (*, flag: bool = ..., x: float)\nw2 = Wrapper(f, \"hello\", 42)\nr2 = w2(x=3.14)  # type: bool\n```\n\n---\n\n## Specification\n\n### Grammar\n\nUpdate the `Concatenate` grammar in the [typing specification](https://typing.python.org/en/latest/spec/generics.html#valid-use-locations) from:\n\n```\nconcatenate ::= \"Concatenate\" \"[\" type_expression (\",\" type_expression)* \",\" parameter_specification_variable \"]\"\n```\n\nto:\n\n```\nconcatenate_prefix_item ::= type_expression | unpack_expression\nconcatenate ::= \"Concatenate\" \"[\" concatenate_prefix_item (\",\" concatenate_prefix_item)* \",\" parameter_specification_variable \"]\"\n```\n\n### Semantics\n\nExpansion follows existing PEP 646 semantics: when `*Ts` is bound to `tuple[T1, T2, ..., Tn]`, `Concatenate[*Ts, P]` is equivalent to `Concatenate[T1, T2, ..., Tn, P]`. When `*Ts` is bound to `tuple[()]`, `Concatenate[*Ts, P]` simplifies to `P`. Individual type expressions and unpack expressions may be freely combined in the prefix (e.g. `Concatenate[LeadingArg, *Ts, P]`).\n\n---\n\n## Open Question: Splitting Boundary\n\nThe core design question is: **how does a type checker determine the split between the prefix and `ParamSpec P`?**\n\nWhen the prefix length is statically known, splitting is unambiguous. This covers concrete bounded tuples (`Concatenate[*tuple[int, str], P]` — always length 2) and value-anchored `TypeVarTuple`s where a companion `*args: *Ts` pins the length at the call site (the `Wrapper` example above). These are the primary use cases.\n\nAmbiguity arises when the prefix length is *not* statically determined:\n\n**Case A — Unanchored `*Ts`** (no companion `*args: *Ts`):\n```python\nclass TaskRunner[**P, R, *Ts]:\n    def __init__(self, fn: Callable[Concatenate[*Ts, P], R]) -> None: ...\n\ndef compute(user_id: int, query: str, *, timeout: float = 5.0) -> bool: ...\n\n# How many positional params should *Ts capture vs. leave in P?\ntask = TaskRunner(compute)\n```\n\n**Case B — Unbounded tuple (`*tuple[T, ...]`)**:\n```python\ndef strip_leading_ints[**P, R](\n    fn: Callable[Concatenate[*tuple[int, ...], P], R]\n) -> Callable[P, R]: ...\n\ndef example(x: int, y: int, z: int, *, flag: bool = False) -> None: ...\n\n# *tuple[int, ...] could match 0, 1, 2, or 3 leading int parameters.\nwrapped = strip_leading_ints(example)\n```\n\n**Options:**\n\n- **Option 1 — Greedy prefix:** The prefix consumes all matching positional-capable parameters. In Case A, `*Ts = (int, str)` and `P = (*, timeout: float = 5.0)`. In Case B, all 3 ints are consumed, leaving `P = (*, flag: bool = False)`.\n\n- **Option 2 — Restrict to fixed-length prefixes initially:** Require the prefix length to be statically determined (concrete bounded tuples, companion `*args: *Ts`, or explicit specialization). Reject unanchored/unbounded prefixes as ambiguous and defer them to a future extension.\n","author":{"url":"https://github.com/ringohoffman","@type":"Person","name":"ringohoffman"},"datePublished":"2026-08-05T23:41:11Z","url":"https://github.com/python/typing/issues/2332"}

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:f07a240b-a0f1-bc2f-f01c-e173cd6ad112
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBC8C:14BBAC:207A9A:29EF1E:6AFF856B
html-safe-nonce05f25ae004d1b522a835fc20b29f2cb41e9fe22cb54d455f67ddb32920f6d396
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzhDOjE0QkJBQzoyMDdBOUE6MjlFRjFFOjZBRkY4NTZCIiwidmlzaXRvcl9pZCI6IjM5MTczOTk1MzYwMDczNDk2MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac68dcbd467cd603c55a74ffcb4169466684069365a48fc862927c94fa45f2f55d
hovercard-subject-tagissue:5076155860
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/2332/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c3707f48a0fba30f0f620cd3c8deb074940195d4a362bce7d6f1c7d42f8c0ade/python/typing/issues/2332
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c3707f48a0fba30f0f620cd3c8deb074940195d4a362bce7d6f1c7d42f8c0ade/python/typing/issues/2332
og:image:altAbstract PEP 612 introduced ParamSpec and Concatenate to prepend fixed positional parameters to a callable's signature. PEP 646 introduced TypeVarTuple for variadic positional typing in Callable[[*...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameringohoffman
hostnamegithub.com
expected-hostnamegithub.com
None19488db4031f00b04ea79b4c70b5dd32cfa873a8d20b3877f3896b8e2d195946
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
release7952f5285f4ba685d70c4c7540ad3cc9dc9746b8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typing/issues/2332#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F2332
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%2F2332
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/2332
Reloadhttps://github.com/python/typing/issues/2332
Reloadhttps://github.com/python/typing/issues/2332
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/2332
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/2332
Proposal: Support Unpacked TypeVarTuple and tuple in Concatenatehttps://github.com/python/typing/issues/2332#top
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
https://github.com/ringohoffman
ringohoffmanhttps://github.com/ringohoffman
on Aug 5, 2026https://github.com/python/typing/issues/2332#issue-5076155860
PEP 612https://peps.python.org/pep-0612/
PEP 646https://peps.python.org/pep-0646/
typing specificationhttps://typing.python.org/en/latest/spec/generics.html#valid-use-locations
typing specificationhttps://typing.python.org/en/latest/spec/generics.html#valid-use-locations
ringohoffmanhttps://github.com/ringohoffman
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
on Aug 5, 2026https://github.com/python/typing/issues/2332#event-29039398469
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/2332
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/2332
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%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.