From e568cc7772cbce06622c1bd9b272b2612cd61f7d Mon Sep 17 00:00:00 2001 From: WHOIM1205 Date: Sat, 7 Mar 2026 15:20:23 -0800 Subject: [PATCH] fix: use __dict__ lookup in _get_class_flags to fix diamond inheritance tag corruption Signed-off-by: WHOIM1205 --- skbase/base/_tagmanager.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/skbase/base/_tagmanager.py b/skbase/base/_tagmanager.py index 87c2af23..4e1f1fe5 100644 --- a/skbase/base/_tagmanager.py +++ b/skbase/base/_tagmanager.py @@ -35,11 +35,9 @@ class attribute via nested inheritance. NOT overridden by dynamic # We exclude the last two parent classes: sklearn.base.BaseEstimator and # the basic Python object. for parent_class in reversed(inspect.getmro(cls)[:-2]): - if hasattr(parent_class, flag_attr_name): - # Need the if here because mixins might not have _more_flags - # but might do redundant work in estimators - # (i.e. calling more flags on BaseEstimator multiple times) - more_flags = getattr(parent_class, flag_attr_name) + if flag_attr_name in parent_class.__dict__: + # Check own __dict__ to avoid MRO-inherited duplicates + more_flags = parent_class.__dict__[flag_attr_name] collected_flags.update(more_flags) return deepcopy(collected_flags)