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.
Convert the APIObject into a Mapping subclass instead of a dict subclass. The idea here is that we will be able to separate out the underlying dictionary and its schema validation from the use of the APIObject subclasses in the code. I didn't go and convert existing uses and instead tossed in a getattr implementation and a comment, as I didn't want to go too far. However, I think this will make the conversion from voluptuous models to json-schema models a lot nicer, as some of the existing ones are pretty complex and tied to Python data types in a way that json-schema makes it tricky to support. Existing well-behaved code should see no impact, anything relying on writeability of APIObject and its subclasses is probably going to break. Also anything relying on the *args is going to break - I can put that back in but it makes things a tiny bit uglier.
As a bonus, I think this fixes the subclassing / init issue as long as users are careful.
This PR also includes two things we discussed on our call - cleaning up the validation error message and having deep_merge do a deep copy on all its arguments (which in turn makes the rest of APIObject a bit more pleasant).