Fix packages for schemas without a default (#33045)

This commit is contained in:
Franck Nijhof 2020-03-20 16:17:43 +01:00 committed by GitHub
parent ecbcdee934
commit 661101df08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -77,7 +77,11 @@ PERSON_SCHEMA = vol.Schema(
) )
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
{vol.Optional(DOMAIN): vol.All(cv.ensure_list, cv.remove_falsy, [PERSON_SCHEMA])}, {
vol.Optional(DOMAIN, default=[]): vol.All(
cv.ensure_list, cv.remove_falsy, [PERSON_SCHEMA]
)
},
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )

View File

@ -571,7 +571,9 @@ def _identify_config_schema(module: ModuleType) -> Tuple[Optional[str], Optional
schema = module.CONFIG_SCHEMA.schema[key] # type: ignore schema = module.CONFIG_SCHEMA.schema[key] # type: ignore
if hasattr(key, "default"): if hasattr(key, "default") and not isinstance(
key.default, vol.schema_builder.Undefined
):
default_value = schema(key.default()) default_value = schema(key.default())
if isinstance(default_value, dict): if isinstance(default_value, dict):