Skip to content

TypedDict update() does not accept TypedDict with compatible subset keys #6462

Closed
@yuyangguo42

Description

@yuyangguo42
from mypy_extensions import TypedDict

A = TypedDict(
    'A', {
        'foo': int,
        'bar': int,
    }
)

B = TypedDict(
    'B', {
        'foo': int,
    }
)

a = A({'foo': 1, 'bar': 2})
b = B({'foo': 2})
a.update({'foo': 2})
a.update(b)

Expect this to pass type checking but got this error:

test.py:19: error: Argument 1 to "update" of "TypedDict" has incompatible type "B"; expected "TypedDict({'foo'?: int, 'bar'?: int})"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions