Skip to content

Cannot construct TypedDict from dict of the same type #2647

@SebbyLaw

Description

@SebbyLaw

Summary

TypedDict constructor does not allow passing dictionary with correct keys or unpacking keys

https://play.ty.dev/864d7b56-f9d7-4e48-9938-54b94efe0b73

from typing import TypedDict


class Data(TypedDict):
    id: int
    name: str
    value: float


def process_data_1(data: Data) -> Data:
    # ...
    return Data(**data)  # error here about required keys


def process_data_2(data: Data) -> Data:
    # ...
    return Data(data)  # error here about required keys

Version

ty 0.0.14 (16597f5 2026-01-26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions