Remove catching of AttributeError
in DescriptorWrapper
#624
+2
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
I was cleaning up the type annotations in
DescriptorWrapper.__get__()
:After being puzzled by the code for some time, I realized that the
value = self.descriptor
statement was inherently incompatible with the return type of the method. Also storing the descriptor rather than a value intracker_instance.saved_data
seems unlikely to be correct.Solution
I tried to find out when this exception handler runs, but it turned out it is never executed during unit testing.
Digging deeper, I found that
AbstractModelTrackerTests
was supposed to cover this code, but that test suite was marked asskip
because it had known test failures. Re-enabling it indeed led to 4 failing test cases, all fromModelTrackerTests
. The reason for that was simple though: the test modelTrackedAbstract
used aFieldTracker
rather than aModelTracker
. After fixing that, the test suite passed.There used to be a bug in Django that caused these tests to fail, according to the discussion of #370. That bug was fixed in Django 4.0.
This exception handler was introduced in #367, but subsequent discussion in #370, #381 and #382 suggests that it wasn't the proper solution. As we now have a working test and that test doesn't cause
AttributeError
to be raised, I think it is safe to remove thetry
/except
.Commandments
CHANGES.rst
file to describe the changes, and quote according issue withGH-<issue_number>
.This change should be invisible to end users, as it removes dead code. So I think the ChangeLog and docs steps can be skipped, but if you disagree, let me know and I'll update the PR.