Simplify cv._make_entity_service_schema (#124046)
This commit is contained in:
parent
69943af68a
commit
f1b7847d1c
1 changed files with 13 additions and 15 deletions
|
@ -1253,21 +1253,19 @@ TARGET_SERVICE_FIELDS = {
|
|||
_HAS_ENTITY_SERVICE_FIELD = has_at_least_one_key(*ENTITY_SERVICE_FIELDS)
|
||||
|
||||
|
||||
def _make_entity_service_schema(schema: dict, extra: int) -> vol.Schema:
|
||||
def _make_entity_service_schema(schema: dict, extra: int) -> VolSchemaType:
|
||||
"""Create an entity service schema."""
|
||||
return vol.Schema(
|
||||
vol.All(
|
||||
vol.Schema(
|
||||
{
|
||||
# The frontend stores data here. Don't use in core.
|
||||
vol.Remove("metadata"): dict,
|
||||
**schema,
|
||||
**ENTITY_SERVICE_FIELDS,
|
||||
},
|
||||
extra=extra,
|
||||
),
|
||||
_HAS_ENTITY_SERVICE_FIELD,
|
||||
)
|
||||
return vol.All(
|
||||
vol.Schema(
|
||||
{
|
||||
# The frontend stores data here. Don't use in core.
|
||||
vol.Remove("metadata"): dict,
|
||||
**schema,
|
||||
**ENTITY_SERVICE_FIELDS,
|
||||
},
|
||||
extra=extra,
|
||||
),
|
||||
_HAS_ENTITY_SERVICE_FIELD,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1276,7 +1274,7 @@ BASE_ENTITY_SCHEMA = _make_entity_service_schema({}, vol.PREVENT_EXTRA)
|
|||
|
||||
def make_entity_service_schema(
|
||||
schema: dict | None, *, extra: int = vol.PREVENT_EXTRA
|
||||
) -> vol.Schema:
|
||||
) -> VolSchemaType:
|
||||
"""Create an entity service schema."""
|
||||
if not schema and extra == vol.PREVENT_EXTRA:
|
||||
# If the schema is empty and we don't allow extra keys, we can return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue