Prioritize Optionals based on one level of depth traversal. Close #44, #45. #54
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.
This enables the common pattern in which there's a 'foo' key with a default and we also take arbitrary other, optional str keys.
We turn priority() into a delegating "generic function", like len().
This lays the groundwork to go deeper--with any "flavor", not just Optionals. First, we'd want to refactor Schema.validate() so it constructs actual Schema subclasses all the time rather than handling many cases inline. For sets, for example, it would construct an Iterable, and Iterable.priority() would know how to tunnel one level inside itself to return a compound priority. Then we could prioritize Optional((1, 0)) over Optional((int,)). The behavior of And() and Or() (and iterables) are up for grabs: perhaps go with the priority of the most specific item inside?