Skip to content

Unpacking a typed dictionary into another should transfer defined keys. #1493

@lypwig

Description

@lypwig

Summary

from typing import TypedDict

class MyTypedDict1(TypedDict):
    aaa: int
    bbb: int


class MyTypedDict2(TypedDict):
    aaa: int
    bbb: int
    ccc: int

d1: MyTypedDict1 = {
    "aaa": 1,
    "bbb": 2,
}

d2: MyTypedDict2 = {
    **d1,
    "ccc": 3,
}

Missing required key 'aaa' in TypedDict MyTypedDict2 constructor (missing-typed-dict-key) [Ln 18, Col 20]
Missing required key 'bbb' in TypedDict MyTypedDict2 constructor (missing-typed-dict-key) [Ln 18, Col 20]

https://play.ty.dev/5bf7c51c-fb7d-4a32-8fc3-799f1e014d76

Version

0.0.1a25

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions