Skip to content

Commit

Permalink
fix other bug surfaced by property tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jan 5, 2025
1 parent e27d203 commit deac0e4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,12 +1194,12 @@ impl<'db> Type<'db> {
ty.bool(db).is_always_true()
}

(Type::SubclassOf(_), _) | (_, Type::SubclassOf(_)) => {
// TODO: Once we have support for final classes, we can determine disjointness in some cases
(Type::SubclassOf(_), other) | (other, Type::SubclassOf(_)) => {
// TODO: Once we have support for final classes, we can determine disjointness in more cases
// here. However, note that it might be better to turn `Type::SubclassOf('FinalClass')` into
// `Type::ClassLiteral('FinalClass')` during construction, instead of adding special cases for
// final classes inside `Type::SubclassOf` everywhere.
false
other.is_disjoint_from(db, KnownClass::Type.to_instance(db))
}

(Type::KnownInstance(known_instance), Type::Instance(InstanceType { class }))
Expand Down Expand Up @@ -4180,6 +4180,7 @@ pub(crate) mod tests {
#[test_case(Ty::SubclassOfBuiltinClass("str"), Ty::LiteralString)]
#[test_case(Ty::AlwaysFalsy, Ty::AlwaysTruthy)]
#[test_case(Ty::Tuple(vec![]), Ty::TypingLiteral)]
#[test_case(Ty::TypingLiteral, Ty::SubclassOfBuiltinClass("object"))]
fn is_disjoint_from(a: Ty, b: Ty) {
let db = setup_db();
let a = a.into_type(&db);
Expand Down

0 comments on commit deac0e4

Please sign in to comment.