From bc05cc3c6f350b05b325560dcc238dd0d4461835 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 19 Jan 2026 02:22:53 -0600 Subject: [PATCH] [ty] Cache `ClassType::nearest_disjoint_base` (#22065) --- crates/ty_python_semantic/src/types/class.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index 34bdaefbc8..d916de29e1 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -1199,6 +1199,7 @@ impl<'db> ClassType<'db> { /// Return the [`DisjointBase`] that appears first in the MRO of this class. /// /// Returns `None` if this class does not have any disjoint bases in its MRO. + #[salsa::tracked(heap_size=ruff_memory_usage::heap_size)] pub(super) fn nearest_disjoint_base(self, db: &'db dyn Db) -> Option> { self.iter_mro(db) .filter_map(ClassBase::into_class) @@ -6056,7 +6057,7 @@ impl InheritanceCycle { /// `TypeError`s resulting from class definitions. /// /// [PEP 800]: https://peps.python.org/pep-0800/ -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, get_size2::GetSize, salsa::Update)] pub(super) struct DisjointBase<'db> { pub(super) class: ClassLiteral<'db>, pub(super) kind: DisjointBaseKind, @@ -6095,7 +6096,7 @@ impl<'db> DisjointBase<'db> { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, get_size2::GetSize, salsa::Update)] pub(super) enum DisjointBaseKind { /// We know the class is a disjoint base because it's either hardcoded in ty /// or has the `@disjoint_base` decorator.