Skip to content

Commit 8d8ff01

Browse files
authored
Minor improvements of service helper (home-assistant#147079)
1 parent 6befd06 commit 8d8ff01

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

homeassistant/helpers/service.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,6 @@ async def async_get_all_descriptions(
718718
for service_name in services_by_domain
719719
}
720720
# If we have a complete cache, check if it is still valid
721-
all_cache: tuple[set[tuple[str, str]], dict[str, dict[str, Any]]] | None
722721
if all_cache := hass.data.get(ALL_SERVICE_DESCRIPTIONS_CACHE):
723722
previous_all_services, previous_descriptions_cache = all_cache
724723
# If the services are the same, we can return the cache
@@ -744,7 +743,11 @@ async def async_get_all_descriptions(
744743
continue
745744
if TYPE_CHECKING:
746745
assert isinstance(int_or_exc, Exception)
747-
_LOGGER.error("Failed to load integration: %s", domain, exc_info=int_or_exc)
746+
_LOGGER.error(
747+
"Failed to load services.yaml for integration: %s",
748+
domain,
749+
exc_info=int_or_exc,
750+
)
748751

749752
if integrations:
750753
loaded = await hass.async_add_executor_job(
@@ -772,7 +775,7 @@ async def async_get_all_descriptions(
772775
# Cache missing descriptions
773776
domain_yaml = loaded.get(domain) or {}
774777
# The YAML may be empty for dynamically defined
775-
# services (ie shell_command) that never call
778+
# services (e.g. shell_command) that never call
776779
# service.async_set_service_schema for the dynamic
777780
# service
778781

tests/helpers/test_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ async def wrap_get_translations(
11411141
descriptions = await service.async_get_all_descriptions(hass)
11421142

11431143
assert len(descriptions) == 3
1144-
assert "Failed to load integration: logger" in caplog.text
1144+
assert "Failed to load services.yaml for integration: logger" in caplog.text
11451145

11461146
# Services are empty defaults if the load fails but should
11471147
# not raise

0 commit comments

Comments
 (0)