[red-knot] TypedDict: No errors for introspection dunder attributes (#17677)

## Summary

Do not emit errors when accessing introspection dunder attributes such
as `__required_keys__` on `TypedDict`s.
This commit is contained in:
David Peter 2025-04-28 13:28:43 +02:00 committed by GitHub
parent ceb2bf1168
commit 92f95ff494
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -21,4 +21,7 @@ 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)
```

View file

@ -169,9 +169,7 @@ impl<'db> ClassBase<'db> {
KnownInstanceType::OrderedDict => {
Self::try_from_type(db, KnownClass::OrderedDict.to_class_literal(db))
}
KnownInstanceType::TypedDict => {
Self::try_from_type(db, KnownClass::Dict.to_class_literal(db))
}
KnownInstanceType::TypedDict => Self::try_from_type(db, todo_type!("TypedDict")),
KnownInstanceType::Callable => {
Self::try_from_type(db, todo_type!("Support for Callable as a base class"))
}