-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix schema typing #309
Fix schema typing #309
Conversation
schema_type() is a class method to determine the default type to be used when instantiating that schema class. It's not to be used to determine the type of an actual schema.
This really is a problem, since it would break Cornice in an incompatible way with previous versions. We might need to find a better mechanism to decide if we should apply the validation. For instance, it might make sense to be able to override this with a property of the passed schema, or pass a callable that should be called. |
I don't understand. Here's the definition of a MappingSchema in colander:
It's just a
Without this change, it's impossible to use a (maybe the confusion lies with my changes to the tests... the tests pass with or without my changes. The changes are just to make things clearer and more consistent.) Additionally, colander has the "feature" of allowing you to do the following:
So, testing if a class is an instance of a |
Thanks for working on this fix! I actually misread "now" with "not", sorry about that. This fix will break cornice because the test isn't done in the same way. I know at least about one application that relies on the So, here are a few things we should add to the this PR before merging:
|
The issue is, though, is example:
In the above example, Also,
So... anything using I'll see what I can do about tests... |
Okay, the call to |
- modified test_imperative_colander_schema to call validate_colander_schema which fails under old code - modified test_only_mapping_is_accepted to try using a MappingSchema with the type changed to a Sequence which is accepted by validate_colander_schema but shouldn't be.
Okay, I think this covers it... |
Would you like me to make a note in CHANGES? Is there anything else missing on this PR? |
/me summons our very own colander expert @leplatrem for a review :) |
I don't see anything wrong, and agree with @tisdall comments! it's indeed cleaner! |
Merged! Thanks :) |
fixes: #307
Unfortunately I didn't have the time to fully understand the code and try to do duck typing. Right now it uses the
unknown
property that only really exists on theMapping
type. The major thing is a SchemaNode(Mapping()) will now work.