[ty] Reduce false positives for TypedDict types (#19354)
This commit is contained in:
@@ -245,7 +245,7 @@ class D(TypedDict):
|
||||
td = D(x=1, label="a")
|
||||
td["x"] = 0
|
||||
# TODO: should be Literal[0]
|
||||
reveal_type(td["x"]) # revealed: @Todo(TypedDict)
|
||||
reveal_type(td["x"]) # revealed: @Todo(Support for `TypedDict`)
|
||||
|
||||
# error: [unresolved-reference]
|
||||
does["not"]["exist"] = 0
|
||||
|
||||
@@ -10,8 +10,6 @@ class Person(TypedDict):
|
||||
name: str
|
||||
age: int | None
|
||||
|
||||
# TODO: This should not be an error:
|
||||
# error: [invalid-assignment]
|
||||
alice: Person = {"name": "Alice", "age": 30}
|
||||
|
||||
# Alternative syntax
|
||||
@@ -22,6 +20,6 @@ msg = Message(id=1, content="Hello")
|
||||
# No errors for yet-unsupported features (`closed`):
|
||||
OtherMessage = TypedDict("OtherMessage", {"id": int, "content": str}, closed=True)
|
||||
|
||||
reveal_type(Person.__required_keys__) # revealed: @Todo(TypedDict)
|
||||
reveal_type(Message.__required_keys__) # revealed: @Todo(TypedDict)
|
||||
reveal_type(Person.__required_keys__) # revealed: @Todo(Support for `TypedDict`)
|
||||
reveal_type(Message.__required_keys__) # revealed: @Todo(Support for `TypedDict`)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user