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
Bugfix group order #3323
Bugfix group order #3323
Conversation
try: | ||
val = value_validator(val) | ||
except ValueError: | ||
errors.append(vol.ValueInvalid('is not a valid value', [key])) |
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.
Should report that [val]
is invalid, right?
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.
No, as it is the path to the value. So actually the 'key' one is not completely correct I guess. But with the patch from @kellerza that doesn't matter anymore so I'll stick with his work.
One comment. Changes look good to me, but I'm not too familiar with the old behavior of groups. |
Proposal for changes here Validating as full entries raises the correct error
otherwise it does not include the group name:
|
Thanks @kellerza, I've merged your changes. I've actually simplified it a bit more. From further inspection of the voluptuous code it seems like they will only report one error at a time . So I decided to do that too. |
Short and simple! Looks like I introduced a linting error though... |
* Add ordered dict config validator * Have group component use ordered dict config validator * Improve config_validation testing * update doc string config_validation.ordered_dict * validate full dict entries * Further simplify ordered_dict validator. * Lint fix
* Add ordered dict config validator * Have group component use ordered dict config validator * Improve config_validation testing * update doc string config_validation.ordered_dict * validate full dict entries * Further simplify ordered_dict validator. * Lint fix
* Add ordered dict config validator * Have group component use ordered dict config validator * Improve config_validation testing * update doc string config_validation.ordered_dict * validate full dict entries * Further simplify ordered_dict validator. * Lint fix
Description:
As part of my PR #3203 to add reloading config to groups I introduced a bug when cleaning up the voluptuous schema validation that broke the group ordering based on their order in the config.
The problem is that passing an ordered dict through a voluptuous dictionary validator will convert it to a normal dictionary. The group component depends on the order from the config to calculate the order of groups so this caused an issue.
This PR adds a new config validator to validate ordered dictionaries while maintaining the order.
I think that we should release this as part of 0.28.1
Example entry for
configuration.yaml
(if applicable):Checklist:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass