Skip to content

Fix incorrect tag resolution in _get_class_flags with diamond inheritance#511

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

Fix incorrect tag resolution in _get_class_flags with diamond inheritance#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")

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
@WHOIM1205 WHOIM1205 changed the title fix: use __dict__ lookup in _get_class_flags to fix diamond inheritan… Fix incorrect tag resolution in _get_class_flags with diamond inheritance Mar 7, 2026
…ce tag corruption

Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
@WHOIM1205 WHOIM1205 force-pushed the fix-diamond-inheritance-tag-corruption branch from cfce7a1 to e568cc7 Compare March 7, 2026 23:20
@WHOIM1205
Copy link
Contributor Author

WHOIM1205 commented Mar 7, 2026

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

thanks for the feedback
i removed the ai style comment from the fix and updated the issue title. please let me know if anything else should be adjusted.

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.48%. Comparing base (306958d) to head (e568cc7).
⚠️ Report is 186 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #511      +/-   ##
==========================================
- Coverage   85.07%   83.48%   -1.60%     
==========================================
  Files          45       52       +7     
  Lines        3015     3905     +890     
==========================================
+ Hits         2565     3260     +695     
- Misses        450      645     +195     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@WHOIM1205
Copy link
Contributor Author

@fkiraly is there anything i can change

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