[ty] Include the specialization of a generic TypedDict as part of its display (#22174)
## Summary This is the easy bit of https://github.com/astral-sh/ty/issues/2190 ## Test Plan mdtests updated
This commit is contained in:
@@ -144,7 +144,7 @@ class Dict[T](TypedDict):
|
||||
|
||||
type DictInt = Dict[int]
|
||||
|
||||
# error: [non-subscriptable] "Cannot subscript non-generic type alias: `Dict` is already specialized"
|
||||
# error: [non-subscriptable] "Cannot subscript non-generic type alias: `Dict[int]` is already specialized"
|
||||
def _(x: DictInt[int]):
|
||||
reveal_type(x) # revealed: Unknown
|
||||
|
||||
|
||||
@@ -1446,7 +1446,7 @@ class TaggedData(TypedDict, Generic[T]):
|
||||
p1: TaggedData[int] = {"data": 42, "tag": "number"}
|
||||
p2: TaggedData[str] = {"data": "Hello", "tag": "text"}
|
||||
|
||||
# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData`: value of type `Literal["not a number"]`"
|
||||
# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData[int]`: value of type `Literal["not a number"]`"
|
||||
p3: TaggedData[int] = {"data": "not a number", "tag": "number"}
|
||||
|
||||
class Items(TypedDict, Generic[T]):
|
||||
@@ -1488,7 +1488,7 @@ class TaggedData[T](TypedDict):
|
||||
p1: TaggedData[int] = {"data": 42, "tag": "number"}
|
||||
p2: TaggedData[str] = {"data": "Hello", "tag": "text"}
|
||||
|
||||
# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData`: value of type `Literal["not a number"]`"
|
||||
# error: [invalid-argument-type] "Invalid argument to key "data" with declared type `int` on TypedDict `TaggedData[int]`: value of type `Literal["not a number"]`"
|
||||
p3: TaggedData[int] = {"data": "not a number", "tag": "number"}
|
||||
|
||||
class Items[T](TypedDict):
|
||||
|
||||
Reference in New Issue
Block a user