Skip to content

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

Open

Description

@KotlinIsland
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
)

Activity

  1. changed the title [-](🎁) Allow usage of `TypedDict` as a type, such that it can be used as a bound of a TypeVar[/-] [+](🎁) Allow usage of `TypedDict` as a type, such that it can be used as in `bound` of a `TypeVar`[/+] on Apr 28, 2023
  2. changed the title [-](🎁) Allow usage of `TypedDict` as a type, such that it can be used as in `bound` of a `TypeVar`[/-] [+](🎁) Allow usage of `TypedDict` as a type, such that it can be used in the `bound` of a `TypeVar`[/+] on Apr 28, 2023
  3. Dreamsorcerer commented on Oct 25, 2026

    @Dreamsorcerer

    And also just allow simple things like:

    if is_typeddict(d):
        d.__required_keys__
  4. JelleZijlstra commented on Oct 25, 2026

    @JelleZijlstra
    Member

    You can use an empty, open TypedDict class for this; it's a supertype of every other TypedDict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: featureDiscussions about new features for Python's type annotations

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions