python / python/typing

(🎁) Allow usage of `TypedDict` as a type, such that it can be used in the `bound` of a `TypeVar`

Open
#1,395 0 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: feature
Dominant language
Python
Stars
1.8k
Forks
302
Avg merge
23h
Merged PRs (30d)
8

Description

from typing import TypedDict, Unpack

class A[ExtraArgs: TypedDict]:
    def do_it(self, **extra: Unpack[ExtraArgs]): ...

class Thing(TypedDict):
    t: int

A[Thing]().do_it(
    t=1,             # no error
    imposter="sus",  # yes error
)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named in the issue; start by locating the project's handling of TypeVar bounds and TypedDict constraints. Done means the shown A[Thing] example accepts t=1 and rejects imposter="sus".

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.