Skip to content

Commit

Permalink
Per review
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jan 8, 2025
1 parent f3932bf commit a90a8fd
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,13 +1403,11 @@ impl<'db> Type<'db> {
let equivalent =
|(first, second): (&Type<'db>, &Type<'db>)| first.is_gradual_equivalent_to(db, *second);

if self == other && !matches!(self, Type::Todo(_)) {
return true;
}

match (self, other) {
(Type::Todo(_), Type::Todo(_)) => false,

(_, _) if self == other => true,

(Type::Any | Type::Unknown, Type::Any | Type::Unknown) => true,

(Type::SubclassOf(first), Type::SubclassOf(second)) => {
Expand Down Expand Up @@ -1443,11 +1441,23 @@ impl<'db> Type<'db> {
}

(Type::Intersection(first), Type::Intersection(second)) => {
let first_positive = first.positive(db).iter().collect::<OrderedTypeSet>();
let first_negative = first.negative(db).iter().collect::<OrderedTypeSet>();
let first_positive = first.positive(db);
let first_negative = first.negative(db);

let second_positive = second.positive(db);
let second_negative = second.negative(db);

if first_positive.len() != second_positive.len()
|| first_negative.len() != second_negative.len()
{
return false;
}

let first_positive = first_positive.iter().collect::<OrderedTypeSet>();
let first_negative = first_negative.iter().collect::<OrderedTypeSet>();

let second_positive = second.positive(db).iter().collect::<OrderedTypeSet>();
let second_negative = second.negative(db).iter().collect::<OrderedTypeSet>();
let second_positive = second_positive.iter().collect::<OrderedTypeSet>();
let second_negative = second_negative.iter().collect::<OrderedTypeSet>();

iter::zip(first_positive, second_positive).all(equivalent)
&& iter::zip(first_negative, second_negative).all(equivalent)
Expand Down

0 comments on commit a90a8fd

Please sign in to comment.