Lint
This commit is contained in:
parent
b7607ff472
commit
f6ae054e9f
2 changed files with 12 additions and 5 deletions
|
@ -636,7 +636,9 @@ def key_dependency(key, dependency):
|
|||
# Schemas
|
||||
class HASchema(vol.Schema):
|
||||
"""Schema class that allows us to mark PREVENT_EXTRA errors as warnings."""
|
||||
|
||||
def __call__(self, data):
|
||||
"""Override __call__ to mark PREVENT_EXTRA as warning."""
|
||||
try:
|
||||
return super().__call__(data)
|
||||
except vol.Invalid as orig_err:
|
||||
|
@ -645,6 +647,7 @@ class HASchema(vol.Schema):
|
|||
|
||||
# orig_error is of type vol.MultipleInvalid (see super __call__)
|
||||
assert isinstance(orig_err, vol.MultipleInvalid)
|
||||
# pylint: disable=no-member
|
||||
# If it fails with PREVENT_EXTRA, try with ALLOW_EXTRA
|
||||
self.extra = vol.ALLOW_EXTRA
|
||||
# In case it still fails the following will raise
|
||||
|
@ -675,7 +678,7 @@ class HASchema(vol.Schema):
|
|||
return validated
|
||||
|
||||
def extend(self, schema, required=None, extra=None):
|
||||
"""Extend this schema and convert it to HASchema if necessary"""
|
||||
"""Extend this schema and convert it to HASchema if necessary."""
|
||||
ret = super().extend(schema, required=required, extra=extra)
|
||||
if extra is not None:
|
||||
return ret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue