Skip to content

Commit

Permalink
[red-knot] `Type::SubclassOf(SubclassOfType { base: ClassBase::Unknow…
Browse files Browse the repository at this point in the history
…n }).to_instance()` should be `Unknown`, not `Any` (astral-sh#15269)
  • Loading branch information
AlexWaygood authored Jan 5, 2025
1 parent f144b96 commit eb82089
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1952,10 +1952,12 @@ impl<'db> Type<'db> {
Type::Unknown => Type::Unknown,
Type::Never => Type::Never,
Type::ClassLiteral(ClassLiteralType { class }) => Type::instance(*class),
Type::SubclassOf(SubclassOfType {
base: ClassBase::Class(class),
}) => Type::instance(*class),
Type::SubclassOf(_) => Type::Any,
Type::SubclassOf(SubclassOfType { base }) => match base {
ClassBase::Class(class) => Type::instance(*class),
ClassBase::Any => Type::Any,
ClassBase::Unknown => Type::Unknown,
ClassBase::Todo(todo) => Type::Todo(*todo),
},
Type::Union(union) => union.map(db, |element| element.to_instance(db)),
Type::Intersection(_) => todo_type!("Type::Intersection.to_instance()"),
// TODO: calling `.to_instance()` on any of these should result in a diagnostic,
Expand Down

0 comments on commit eb82089

Please sign in to comment.