Call super().add_object() in List, Tuple and Object strategies#95
Open
gaoflow wants to merge 1 commit into
Open
Call super().add_object() in List, Tuple and Object strategies#95gaoflow wants to merge 1 commit into
gaoflow wants to merge 1 commit into
Conversation
The base SchemaStrategy.add_object is a no-op, but cooperative subclasses rely on each strategy's add_object override chaining up through super() so their hooks run. PR wolverdude#79 restored this for Number and PR wolverdude#82 applied it to Enum, but List, Tuple and Object still overrode add_object without calling super(), so a cooperative mixin's add_object was skipped for arrays, tuples and objects. Add the missing super() calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
SchemaStrategy.add_objectis a no-op base method, but cooperative subclassesrely on each strategy's
add_objectoverride chaining up throughsuper().add_object()so their own hooks run. #79 restored this forNumber("added missing super in Number so inheritance would be called") and #82
applied it to the new
Enumstrategy — butList,TupleandObjectstilloverride
add_objectwithout callingsuper().As a result, a cooperative mixin's
add_objectis silently skipped for arrays,tuples and objects, while it runs for numbers and enums:
Fix
Add the missing
super().add_object(obj)call toList,TupleandObject,matching
NumberandEnum. The base method is a no-op, so stock gensonbehavior is unchanged; this only completes the cooperative chain for
subclasses.
Tests
TestAddObjectSuperChainingintest/test_custom.pyrecords objects via acooperative mixin and asserts the hook fires for
List,TupleandObject(with
Numberas the already-fixed control), plus a nestedobject → list → object case verifying the hook fires at every level. The array/
tuple/object tests fail before the change and pass after; full suite: 118
passed.