mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-04 00:55:14 +00:00
[ty] fix infinite recursion bug in is_disjoint_from (#18043)
## Summary I found this bug while working on #18041. The following code leads to infinite recursion. ```python from ty_extensions import is_disjoint_from, static_assert, TypeOf class C: @property def prop(self) -> int: return 1 static_assert(not is_disjoint_from(int, TypeOf[C.prop])) ``` The cause is a trivial missing binding in `is_disjoint_from`. This PR fixes the bug and adds a test case (this is a simple fix and may not require a new test case?). ## Test Plan A new test case is added to `mdtest/type_properties/is_disjoint_from.md`.
This commit is contained in:
parent
797eb70904
commit
6f8f7506b4
2 changed files with 28 additions and 3 deletions
|
|
@ -2101,9 +2101,11 @@ impl<'db> Type<'db> {
|
|||
instance.is_disjoint_from(db, KnownClass::Tuple.to_instance(db))
|
||||
}
|
||||
|
||||
(Type::PropertyInstance(_), _) | (_, Type::PropertyInstance(_)) => KnownClass::Property
|
||||
.to_instance(db)
|
||||
.is_disjoint_from(db, other),
|
||||
(Type::PropertyInstance(_), other) | (other, Type::PropertyInstance(_)) => {
|
||||
KnownClass::Property
|
||||
.to_instance(db)
|
||||
.is_disjoint_from(db, other)
|
||||
}
|
||||
|
||||
(Type::BoundSuper(_), Type::BoundSuper(_)) => !self.is_equivalent_to(db, other),
|
||||
(Type::BoundSuper(_), other) | (other, Type::BoundSuper(_)) => KnownClass::Super
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue