Skip to content

validate TypedDict construction via GenericAlias or SubclassOf type #2735

@carljm

Description

@carljm
from typing import TypedDict

class MyGenTD[T](TypedDict):
    a: int
    b: T

class MyTD(TypedDict):
    a: int

MyStrTD = MyGenTD[str]

x = MyStrTD(a="foo")
y = MyTD(a="foo")

def _(ATD: type[MyTD]):
    z = ATD(a="foo")

Today we error only on the construction of x. This is because we only handle ClassLiteral types at https://github.com/astral-sh/ruff/blob/main/crates/ty_python_semantic/src/types/infer/builder.rs#L11757-L11759

We should error on all three of x, y, and z.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions