From ce8519c1b1f064ab0e00e18b342803d3124994f6 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 31 Mar 2026 13:29:05 +0200 Subject: [PATCH] Update hassfest conditions, services and triggers plugins to not require field descriptions (#166954) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: AbĂ­lio Costa Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- script/hassfest/conditions.py | 18 ++---------------- script/hassfest/services.py | 15 ++------------- script/hassfest/triggers.py | 18 ++---------------- tests/hassfest/test_conditions.py | 8 ++++++-- tests/hassfest/test_triggers.py | 6 ++++-- 5 files changed, 16 insertions(+), 49 deletions(-) diff --git a/script/hassfest/conditions.py b/script/hassfest/conditions.py index 22449cfd636..6fef91309fd 100644 --- a/script/hassfest/conditions.py +++ b/script/hassfest/conditions.py @@ -231,8 +231,8 @@ def validate_conditions(config: Config, integration: Integration) -> None: # no f"Condition {condition_name} has no description {error_msg_suffix}", ) - # The same check is done for the description in each of the fields of the - # condition schema. + # The same check is done for each of the fields of the condition schema, + # except that we don't enforce that fields have a description. for field_name, field_schema in condition_schema.get("fields", {}).items(): if "fields" in field_schema: # This is a section @@ -249,20 +249,6 @@ def validate_conditions(config: Config, integration: Integration) -> None: # no ), ) - if "description" not in field_schema and integration.core: - try: - strings["conditions"][condition_name]["fields"][field_name][ - "description" - ] - except KeyError: - integration.add_error( - "conditions", - ( - f"Condition {condition_name} has a field {field_name} with no " - f"description {error_msg_suffix}" - ), - ) - if "selector" in field_schema: with contextlib.suppress(KeyError): translation_key = field_schema["selector"]["select"][ diff --git a/script/hassfest/services.py b/script/hassfest/services.py index 723a9ec9278..5e2d3cae587 100644 --- a/script/hassfest/services.py +++ b/script/hassfest/services.py @@ -303,8 +303,8 @@ def validate_services(config: Config, integration: Integration) -> None: # noqa integration, service_name, strings, service_schema ) - # The same check is done for the description in each of the fields of the - # service schema. + # The same check is done for each field in the service schema, + # except that we don't require fields to have a description. for field_name, field_schema in service_schema.get("fields", {}).items(): if "fields" in field_schema: # This is a section @@ -318,17 +318,6 @@ def validate_services(config: Config, integration: Integration) -> None: # noqa f"Service {service_name} has a field {field_name} with no name {error_msg_suffix}", ) - if "description" not in field_schema and integration.core: - try: - strings["services"][service_name]["fields"][field_name][ - "description" - ] - except KeyError: - integration.add_error( - "services", - f"Service {service_name} has a field {field_name} with no description {error_msg_suffix}", - ) - if "selector" in field_schema: with contextlib.suppress(KeyError): translation_key = field_schema["selector"]["select"][ diff --git a/script/hassfest/triggers.py b/script/hassfest/triggers.py index 86e4a475475..87bbb4d8f57 100644 --- a/script/hassfest/triggers.py +++ b/script/hassfest/triggers.py @@ -245,8 +245,8 @@ def validate_triggers(config: Config, integration: Integration) -> None: # noqa f"Trigger {trigger_name} has no description {error_msg_suffix}", ) - # The same check is done for the description in each of the fields of the - # trigger schema. + # The same check is done for each of the fields of the trigger schema, + # except that we don't enforce that fields have a description. for field_name, field_schema in trigger_schema.get("fields", {}).items(): if "fields" in field_schema: # This is a section @@ -263,20 +263,6 @@ def validate_triggers(config: Config, integration: Integration) -> None: # noqa ), ) - if "description" not in field_schema and integration.core: - try: - strings["triggers"][trigger_name]["fields"][field_name][ - "description" - ] - except KeyError: - integration.add_error( - "triggers", - ( - f"Trigger {trigger_name} has a field {field_name} with no " - f"description {error_msg_suffix}" - ), - ) - if "selector" in field_schema: with contextlib.suppress(KeyError): translation_key = field_schema["selector"]["select"][ diff --git a/tests/hassfest/test_conditions.py b/tests/hassfest/test_conditions.py index 12c3682e92d..8cfdf4a0270 100644 --- a/tests/hassfest/test_conditions.py +++ b/tests/hassfest/test_conditions.py @@ -35,6 +35,9 @@ CONDITION_DESCRIPTIONS = { after_offset: selector: time: null + after_offset_no_description: + selector: + time: null """, CONDITION_ICONS_FILENAME: {"conditions": {"_": {"condition": "mdi:flash"}}}, CONDITION_STRINGS_FILENAME: { @@ -48,6 +51,9 @@ CONDITION_DESCRIPTIONS = { "name": "Offset", "description": "The offset.", }, + "after_offset_no_description": { + "name": "Offset", + }, }, } } @@ -105,10 +111,8 @@ CONDITION_DESCRIPTIONS = { "has no name", "has no description", "field after with no name", - "field after with no description", "field after with a selector with a translation key", "field after_offset with no name", - "field after_offset with no description", ], }, } diff --git a/tests/hassfest/test_triggers.py b/tests/hassfest/test_triggers.py index 0bd28fd4e80..e3f43740ed1 100644 --- a/tests/hassfest/test_triggers.py +++ b/tests/hassfest/test_triggers.py @@ -32,6 +32,9 @@ TRIGGER_DESCRIPTIONS = { offset: selector: time: null + offset_no_description: + selector: + time: null """, TRIGGER_ICONS_FILENAME: {"triggers": {"_": {"trigger": "mdi:flash"}}}, TRIGGER_STRINGS_FILENAME: { @@ -42,6 +45,7 @@ TRIGGER_DESCRIPTIONS = { "fields": { "event": {"name": "Event", "description": "The event."}, "offset": {"name": "Offset", "description": "The offset."}, + "offset_no_description": {"name": "Offset"}, }, } } @@ -99,10 +103,8 @@ TRIGGER_DESCRIPTIONS = { "has no name", "has no description", "field event with no name", - "field event with no description", "field event with a selector with a translation key", "field offset with no name", - "field offset with no description", ], }, }