Skip to content

gh-148945: add support for bounds on type variable tuples and parameter specifications - #148946

Draft
KotlinIsland wants to merge 1 commit into
python:mainfrom
KotlinIsland:bounds
Draft

gh-148945: add support for bounds on type variable tuples and parameter specifications#148946
KotlinIsland wants to merge 1 commit into
python:mainfrom
KotlinIsland:bounds

Conversation

@KotlinIsland

@KotlinIsland KotlinIsland commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jul 25, 2026
@read-the-docs-community

read-the-docs-community Bot commented Aug 12, 2026

Copy link
Copy Markdown

@KotlinIsland KotlinIsland changed the title gh-148945: add support for bounds on type variable tuples and paramet… gh-148945: add support for bounds on type variable tuples and parameter specifications Aug 12, 2026
…arameter specifications

Type parameter lists now accept a bound on type variable tuples and
parameter specifications, using the same colon syntax already available
for TypeVar:

    def call[*Ts: int, **P: [str]](*args: *Ts, f: Callable[P, int]): ...

A TypeVarTuple bound applies to each type the type variable tuple stands
for and is a star_expression, like its default. A ParamSpec bound is a
parameter list. As with TypeVar bounds, they are lazily evaluated in a
separate annotation scope and are exposed through __bound__ and the
evaluate_bound evaluate function.

The ast.TypeVarTuple and ast.ParamSpec nodes gain a 'bound' field.

Also normalizes ParamSpec('P').__bound__ to None; it was previously
types.NoneType, unlike TypeVar and TypeVarTuple.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant