From 8e0e1405e8e3564fb93d8c87254be5d1aba0a3a8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 2 May 2021 21:49:51 -0700 Subject: [PATCH] Make hassfest service validation faster (#50003) --- script/hassfest/services.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/script/hassfest/services.py b/script/hassfest/services.py index 9c28962fbad..a5d10f8dda5 100644 --- a/script/hassfest/services.py +++ b/script/hassfest/services.py @@ -65,25 +65,23 @@ def grep_dir(path: pathlib.Path, glob_pattern: str, search_pattern: str) -> bool def validate_services(integration: Integration): """Validate services.""" - # Find if integration uses services - has_services = grep_dir( - integration.path, - "**/*.py", - r"(hass\.services\.(register|async_register))|async_register_entity_service|async_register_admin_service", - ) - - if not has_services: - return - try: data = load_yaml(str(integration.path / "services.yaml")) except FileNotFoundError: - integration.add_error("services", "Registers services but has no services.yaml") + # Find if integration uses services + has_services = grep_dir( + integration.path, + "**/*.py", + r"(hass\.services\.(register|async_register))|async_register_entity_service|async_register_admin_service", + ) + + if has_services: + integration.add_error( + "services", "Registers services but has no services.yaml" + ) return except HomeAssistantError: - integration.add_error( - "services", "Registers services but unable to load services.yaml" - ) + integration.add_error("services", "Unable to load services.yaml") return try: