Skip to content

Duplicated TypedDict assignability diagnostics #1472

@ibraheemdev

Description

@ibraheemdev

See astral-sh/ruff#21238 (comment). In cases where we may perform multi-inference, or don't have access to the RHS expression, we emit a diagnostic for TypedDict assignability as well as the existing invalid-key diagnostic.

class Person(TypedDict):
    name: str

# error: [invalid-argument-type]
# error: [invalid-argument-type] "Invalid argument to key "name" with declared type `str` on TypedDict `Person`: value of type `None`"
accepts_person({"name": None})

Ideally we could avoid the former.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bidirectional inferenceInference of types that takes into account the context of a declared type or expected typediagnosticsRelated to reporting of diagnostics.typeddict

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions