From bde8ecddca5852e752b7014c9da9ac445a6ca33c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 3 Jan 2025 19:04:01 +0000 Subject: [PATCH] [red-knot] Remove unneeded branch in `Type::is_equivalent_to()` (#15242) ## Summary We understand `sys.version_info` branches now! As such, I _believe_ this branch is no longer required; all tests pass without it. I also ran `QUICKCHECK_TESTS=100000 cargo test -p red_knot_python_semantic -- --ignored types::property_tests::stable`, and no tests failed except for the known issue with `Type::is_assignable_to()` (https://github.com/astral-sh/ruff/issues/14899) ## Test Plan See above --- crates/red_knot_python_semantic/src/types.rs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 74b8daa2fc..54075eef7e 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -1010,26 +1010,6 @@ impl<'db> Type<'db> { return false; } - // TODO: The following is a workaround that is required to unify the two different versions - // of `NoneType` and `NoDefaultType` in typeshed. This should not be required anymore once - // we understand `sys.version_info` branches. - if let ( - Type::Instance(InstanceType { class: self_class }), - Type::Instance(InstanceType { - class: target_class, - }), - ) = (self, other) - { - let self_known = self_class.known(db); - if matches!( - self_known, - Some(KnownClass::NoneType | KnownClass::NoDefaultType) - ) && self_known == target_class.known(db) - { - return true; - } - } - // type[object] ≡ type if let ( Type::SubclassOf(SubclassOfType {