mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
[red-knot] Understand type[Unknown]
(#15409)
## Summary Follow-up to #15194. ## Test Plan Markdown tests.
This commit is contained in:
parent
c82932e580
commit
232fbc1300
2 changed files with 6 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue