Skip to content

fix: use __dict__ lookup in _get_class_flags to fix diamond inheritan…#511

Open
WHOIM1205 wants to merge 1 commit intosktime:mainfrom
WHOIM1205:fix-diamond-inheritance-tag-corruption
Open

fix: use __dict__ lookup in _get_class_flags to fix diamond inheritan…#511
WHOIM1205 wants to merge 1 commit intosktime:mainfrom
WHOIM1205:fix-diamond-inheritance-tag-corruption

Conversation

@WHOIM1205
Copy link
Contributor

@WHOIM1205 WHOIM1205 commented Mar 3, 2026

Fix incorrect tag/config resolution in diamond inheritance

Summary

_FlagManager._get_class_flags currently uses hasattr and getattr when iterating over the class MRO.
Because getattr follows Python's full attribute lookup chain, classes that do not define _tags (or _config) themselves may still return values inherited from ancestors.

In diamond inheritance scenarios this can re-apply ancestor flags later in the merge order and overwrite overrides coming from mixins.

Example

class A(BaseObject):
    _tags = {"handles_missing_data": False}

class MissingDataMixin(A):
    _tags = {"handles_missing_data": True}

class MyBase(A):
    pass

class Concrete(MyBase, MissingDataMixin):
    _tags = {"custom_flag": True}

Concrete().get_tag("handles_missing_data")

…ce tag corruption

Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
Copy link
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I assume an AI caught this.

Can you please make sure to:

  • remove the AI generated comment and leave the old comment there
  • fix the issue title

@fkiraly fkiraly added the bug Something isn't working label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants