Skip to content

chore: make the 'P' type var contravariant - #2995

Merged
rwols merged 1 commit into
mainfrom
chore/contravariance
Jul 23, 2026
Merged

chore: make the 'P' type var contravariant#2995
rwols merged 1 commit into
mainfrom
chore/contravariance

Conversation

@rwols

@rwols rwols commented Jul 18, 2026

Copy link
Copy Markdown
Member

(I'm porting some self-contained bits from the feat/asyncio branch so that PR becomes a bit smaller.)

It's used as a type var for function arguments. This will allow for constructs like defining a function foo that takes a union of request types:

def foo(r: Request[A, X] | Request[B, X]) -> X:
...

The foo function takes either an object of type Request[A,X] or an object of type Request[B,X] and in both cases will return an object of type X.

It's used as a type var for function arguments. This will allow for
constructs like defining a function `foo` that takes a union of request types:

def foo(r: Request[A, X] | Request[B, X]) -> X:
    ...

The foo function takes either an object of type `Request[A,X]` or an object
of type `Request[B,X]` and in both cases will return an object of type `X`.
@rwols rwols mentioned this pull request Jul 18, 2026
5 tasks
@rwols
rwols merged commit a65804e into main Jul 23, 2026
9 checks passed
@rwols
rwols deleted the chore/contravariance branch July 23, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants