Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions skbase/base/_tagmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ 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__:
# Use __dict__ lookup instead of hasattr/getattr to avoid
# MRO traversal. getattr would cause classes that don't define
# the flag attribute in their own class body to act as proxies
# for their ancestors, re-injecting already-superseded values
# in diamond inheritance scenarios.
more_flags = parent_class.__dict__[flag_attr_name]
collected_flags.update(more_flags)

return deepcopy(collected_flags)
Expand Down