Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop copying parent attributes into child class #330

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RJPercival
Copy link

This avoids breaking the normal MRO for attributes, which searches the class hierarchy for attribute definitions. If attributes are copied onto every class in the hierarchy, the C3 MRO algorithm finds the attribute in a child class even though that class didn't actually define it, which results in surprising attribute values when classes in the hierarchy set the same attribute to different values.

Fixes #329

@RJPercival
Copy link
Author

This is a highly speculative PR to see what fails on CI when this code is removed.

@RJPercival RJPercival marked this pull request as ready for review June 16, 2022 15:17
This avoids breaking the normal MRO for attributes, which searches the class hierarchy for attribute definitions. If attributes are copied onto every class in the hierarchy, the C3 MRO algorithm finds the attribute in a child class even though that class didn't actually define it, which results in surprising attribute values when classes in the hierarchy set the same attribute to different values.
@RJPercival
Copy link
Author

@jezdez, could the workflow get an approval please?

@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Merging #330 (9e8b013) into master (cad6dcb) will decrease coverage by 0.04%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #330      +/-   ##
==========================================
- Coverage   89.98%   89.94%   -0.04%     
==========================================
  Files          25       25              
  Lines        1198     1194       -4     
  Branches      216      213       -3     
==========================================
- Hits         1078     1074       -4     
  Misses         89       89              
  Partials       31       31              
Impacted Files Coverage Δ
configurations/base.py 83.07% <ø> (-0.99%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@RJPercival
Copy link
Author

Seems to have passed the test suite (the failing tests seem to be caused by something else).

@RJPercival
Copy link
Author

RJPercival commented Dec 4, 2023

I think we'd want to tweak this so that the deprecated settings check still looks at inheriting settings, but otherwise it appears that this won't break any functionality. However, it will change the MRO for settings, so users of django-configurations could have setting values change unexpectedly. If we decided to go ahead with this fix, then I think it'd call for a major version bump.

@jezdez, if that's something you'd be happy with, then I'll tweak this PR so that it's ready for review.

@pauloxnet
Copy link
Member

... if that's something you'd be happy with, then I'll tweak this PR so that it's ready for review.

The change seems reasonable to me, can you work on this PR to update it, adding deprecation notes and tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration class breaks MRO
2 participants