mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Minor improvements of service helper (#147079)
This commit is contained in:
parent
6befd065a1
commit
8d8ff011fc
@ -718,7 +718,6 @@ async def async_get_all_descriptions(
|
|||||||
for service_name in services_by_domain
|
for service_name in services_by_domain
|
||||||
}
|
}
|
||||||
# If we have a complete cache, check if it is still valid
|
# If we have a complete cache, check if it is still valid
|
||||||
all_cache: tuple[set[tuple[str, str]], dict[str, dict[str, Any]]] | None
|
|
||||||
if all_cache := hass.data.get(ALL_SERVICE_DESCRIPTIONS_CACHE):
|
if all_cache := hass.data.get(ALL_SERVICE_DESCRIPTIONS_CACHE):
|
||||||
previous_all_services, previous_descriptions_cache = all_cache
|
previous_all_services, previous_descriptions_cache = all_cache
|
||||||
# If the services are the same, we can return the cache
|
# If the services are the same, we can return the cache
|
||||||
@ -744,7 +743,11 @@ async def async_get_all_descriptions(
|
|||||||
continue
|
continue
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
assert isinstance(int_or_exc, Exception)
|
assert isinstance(int_or_exc, Exception)
|
||||||
_LOGGER.error("Failed to load integration: %s", domain, exc_info=int_or_exc)
|
_LOGGER.error(
|
||||||
|
"Failed to load services.yaml for integration: %s",
|
||||||
|
domain,
|
||||||
|
exc_info=int_or_exc,
|
||||||
|
)
|
||||||
|
|
||||||
if integrations:
|
if integrations:
|
||||||
loaded = await hass.async_add_executor_job(
|
loaded = await hass.async_add_executor_job(
|
||||||
@ -772,7 +775,7 @@ async def async_get_all_descriptions(
|
|||||||
# Cache missing descriptions
|
# Cache missing descriptions
|
||||||
domain_yaml = loaded.get(domain) or {}
|
domain_yaml = loaded.get(domain) or {}
|
||||||
# The YAML may be empty for dynamically defined
|
# The YAML may be empty for dynamically defined
|
||||||
# services (ie shell_command) that never call
|
# services (e.g. shell_command) that never call
|
||||||
# service.async_set_service_schema for the dynamic
|
# service.async_set_service_schema for the dynamic
|
||||||
# service
|
# service
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ async def test_async_get_all_descriptions_failing_integration(
|
|||||||
descriptions = await service.async_get_all_descriptions(hass)
|
descriptions = await service.async_get_all_descriptions(hass)
|
||||||
|
|
||||||
assert len(descriptions) == 3
|
assert len(descriptions) == 3
|
||||||
assert "Failed to load integration: logger" in caplog.text
|
assert "Failed to load services.yaml for integration: logger" in caplog.text
|
||||||
|
|
||||||
# Services are empty defaults if the load fails but should
|
# Services are empty defaults if the load fails but should
|
||||||
# not raise
|
# not raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user