| 32 | |
| 33 | impl PythonType { |
| 34 | pub fn type_equal(&self, other: &Self) -> bool { |
| 35 | match (self, other) { |
| 36 | (PythonType::None, PythonType::None) => true, |
| 37 | (PythonType::Unknown, PythonType::Unknown) => true, |
| 38 | (PythonType::Any, PythonType::Any) => true, |
| 39 | (PythonType::LiteralValue(v1), PythonType::LiteralValue(v2)) => v1 == v2, |
| 40 | (PythonType::MultiValue(m1), PythonType::MultiValue(m2)) => { |
| 41 | if m1.len() != m2.len() { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | for (t1, t2) in m1.iter().zip(m2.iter()) { |
| 46 | if !t1.type_equal(t2) { |
| 47 | return false; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | true |
| 52 | } |
| 53 | (PythonType::Callable(c1), PythonType::Callable(c2)) => c1.type_equal(c2), |
| 54 | (PythonType::Class(c1), PythonType::Class(c2)) => c1.type_equal(c2), |
| 55 | _ => false, |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | #[allow(unused)] |