-
Notifications
You must be signed in to change notification settings - Fork 218
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
Added support for default values in Inclusive schemas #382
Conversation
It's a trivial change but I think there should be a test case to ensure that this is automatically tested and continues to behave as expected. |
I did think about that. Right now there is no test case for |
@svisser I created a set of new tests for both |
It seems a useful change to make to me. Given that it's new functionality, I wonder if @alecthomas has an opinion on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor change, thanks!
voluptuous/schema_builder.py
Outdated
@@ -1127,8 +1127,10 @@ class Inclusive(Optional): | |||
True | |||
""" | |||
|
|||
def __init__(self, schema, group_of_inclusion, msg=None, description=None): | |||
def __init__(self, schema, group_of_inclusion, | |||
msg=None, default=UNDEFINED, description=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new parameters at the end to avoid unnecessary breakage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I put them in that order because that is the order used by both Required
and Optional
(which is its parent class) but I'm happy either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed d6e83a6 to address this. Reordering the arguments is the only thing that commit does, so If you decide that consistency with the other classes is more compelling than consistency with the part then feel fee to ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah understood, but still I think avoiding potential breakage is preferable.
This is a trivial implementation of a fix for #381.