Validator: Fix casting record_specific_diffs object to list for json serialization#1275
Open
barbarahui wants to merge 1 commit intomainfrom
Open
Validator: Fix casting record_specific_diffs object to list for json serialization#1275barbarahui wants to merge 1 commit intomainfrom
barbarahui wants to merge 1 commit intomainfrom
Conversation
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.
I'm a bit confused as to what exactly is going on here in terms of what type of object
record_specific_diffsis (prior to any attempts to set its type to list). In case of collection 27566, it seems be an instance ofdict. Theset_encoderfunction clearly expects it to be of typesetorSetOrdered, but I needed to adddictas an option.The other problem was that calling
set_encoder()as part of thejson.dumpscall (by adding thedefault=set_encoderargument) results in theobjbeing of typetype(the type superclass). Callingset_encoderseparately fixes this problem.In reading through the code, it seems to me that
record_specific_diffsis always a dict. However, if we don't explicitly cast it to a list by callingset_encoderon it, then callingjson.dumpson it results in a "TypeError: Object of type type is not JSON serializable" error. So it is somehow both a dict and a type object? I'm deeply confused.If the changes I've made here make sense, then we should probably change the name of the
set_encoderfunction. All I can think of isdiffs_obj_to_list.