mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 18:35:13 +00:00
argval: cleanup default values in ArgValidatorDict._validate_impl()
- split the "if" block in two. It's easier to read to only have one condition and to think about them independently. - check "self.all_missing_during_validate" before getting the default value. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
16f1898894
commit
bf9933e482
1 changed files with 7 additions and 7 deletions
|
|
@ -357,16 +357,16 @@ class ArgValidatorDict(ArgValidator):
|
|||
raise ValidationError(e.name, e.error_message)
|
||||
result[setting] = validated_value
|
||||
for (setting, validator) in self.nested.items():
|
||||
if setting in seen_keys or isinstance(validator, ArgValidatorDeprecated):
|
||||
if setting in seen_keys:
|
||||
continue
|
||||
if isinstance(validator, ArgValidatorDeprecated):
|
||||
continue
|
||||
if validator.required:
|
||||
raise ValidationError(name, "missing required key '%s'" % (setting))
|
||||
default_value = validator.get_default_value()
|
||||
if (
|
||||
not self.all_missing_during_validate
|
||||
and default_value is not ArgValidator.MISSING
|
||||
):
|
||||
result[setting] = default_value
|
||||
if not self.all_missing_during_validate:
|
||||
default_value = validator.get_default_value()
|
||||
if default_value is not ArgValidator.MISSING:
|
||||
result[setting] = default_value
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue