1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-21 12:42:21 +01:00

[config] Use `cv.UNDEFINED instead of adhoc _UNDEF` objects (#8725)

This commit is contained in:
Jesse Hills
2025-05-09 20:18:52 +12:00
committed by GitHub
parent e1732c4945
commit 8399d894c1
12 changed files with 82 additions and 102 deletions

View File

@@ -64,19 +64,17 @@ SELECT_SCHEMA = (
)
)
_UNDEF = object()
def select_schema(
class_: MockObjClass = _UNDEF,
class_: MockObjClass = cv.UNDEFINED,
*,
entity_category: str = _UNDEF,
icon: str = _UNDEF,
entity_category: str = cv.UNDEFINED,
icon: str = cv.UNDEFINED,
):
schema = cv.Schema({})
if class_ is not _UNDEF:
if class_ is not cv.UNDEFINED:
schema = schema.extend({cv.GenerateID(): cv.declare_id(class_)})
if entity_category is not _UNDEF:
if entity_category is not cv.UNDEFINED:
schema = schema.extend(
{
cv.Optional(
@@ -84,7 +82,7 @@ def select_schema(
): cv.entity_category
}
)
if icon is not _UNDEF:
if icon is not cv.UNDEFINED:
schema = schema.extend({cv.Optional(CONF_ICON, default=icon): cv.icon})
return SELECT_SCHEMA.extend(schema)