[red-knot] Understand type[Unknown] (#15409)

## Summary

Follow-up to #15194.

## Test Plan

Markdown tests.
This commit is contained in:
InSync 2025-01-11 04:25:59 +07:00 committed by GitHub
parent c82932e580
commit 232fbc1300
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -66,14 +66,11 @@ def _(a: Unknown, b: Any):
assert_type(b, Unknown) # fine
def _(a: type[Unknown], b: type[Any]):
# TODO: Should be `type[Unknown]`
reveal_type(a) # revealed: @Todo(unsupported type[X] special form)
# TODO: Should be fine
assert_type(a, type[Any]) # error: [type-assertion-failure]
reveal_type(a) # revealed: type[Unknown]
assert_type(a, type[Any]) # fine
reveal_type(b) # revealed: type[Any]
# TODO: Should be fine
assert_type(b, type[Unknown]) # error: [type-assertion-failure]
assert_type(b, type[Unknown]) # fine
```
## Tuples

View file

@ -5066,6 +5066,9 @@ impl<'db> TypeInferenceBuilder<'db> {
Type::KnownInstance(KnownInstanceType::Any) => {
SubclassOfType::subclass_of_any()
}
Type::KnownInstance(KnownInstanceType::Unknown) => {
SubclassOfType::subclass_of_unknown()
}
_ => todo_type!("unsupported type[X] special form"),
}
}