Skip to content

[BUG] _get_class_flags dynamically slices the MRO index, permanently dropping tags for Mixins during multiple inheritance #539

@vedant21-oss

Description

@vedant21-oss

Describe the bug
The core component _get_class_flags iterates over reversed(inspect.getmro(cls)[:-2]). The arbitrary [:-2] cut off removes the last two members of the object tree. In multiple-inheritance situations (e.g., class CustomAlgorithm(BaseObject, ArbitraryMixin)), ArbitraryMixin slides against the end index of the MRO. Consequently, its associated _tags and _flags properties get unconditionally deleted out of get_class_flags.

To Reproduce

import inspect
from skbase.base import BaseObject

class MyMixin:
    _tags = {"mixin_tag": "should_be_seen"}

# With multiple inheritance
class MyObj(BaseObject, MyMixin):
    _tags = {"obj_tag": "seen"}

tags = MyObj.get_class_tags()
print("Tags:", tags) # mixin_tag will be missing completely from the output due to the [:-2] slice logic

Expected behavior
Tags defined in all class ancestor mixins should be exposed regardless of multiple inheritance order or length (except for Python's base object which never contains flags).

Proposed Fix
Revert to iterating through the getmro() resolution tree entirely natively while explicitly discarding object rather than generic indices:

for parent_class in reversed(inspect.getmro(cls)):
    if parent_class is object:
        continue
    # ... check hasattr

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions