Skip to content

Commit

Permalink
[red-knot] Understand type[Unknown] (#15409)
Browse files Browse the repository at this point in the history
## Summary

Follow-up to #15194.

## Test Plan

Markdown tests.
  • Loading branch information
InSyncWithFoo authored Jan 10, 2025
1 parent c82932e commit 232fbc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}
Expand Down

0 comments on commit 232fbc1

Please sign in to comment.