From 9971831b51f96ad3f1fc5f0307082c39ec5fb2dd Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 30 Dec 2021 21:18:10 +0100 Subject: [PATCH] Improve typing in core service registration (#63005) Co-authored-by: epenet --- homeassistant/core.py | 4 ++-- homeassistant/helpers/entity_component.py | 2 +- homeassistant/helpers/service.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/core.py b/homeassistant/core.py index 819db0b6825..097be448867 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -1330,7 +1330,7 @@ class ServiceRegistry: self, domain: str, service: str, - service_func: Callable, + service_func: Callable[[ServiceCall], Awaitable[None] | None], schema: vol.Schema | None = None, ) -> None: """ @@ -1347,7 +1347,7 @@ class ServiceRegistry: self, domain: str, service: str, - service_func: Callable, + service_func: Callable[[ServiceCall], Awaitable[None] | None], schema: vol.Schema | None = None, ) -> None: """ diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 66d733619d0..6e7e2a6302e 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -198,7 +198,7 @@ class EntityComponent: if isinstance(schema, dict): schema = cv.make_entity_service_schema(schema) - async def handle_service(call: Callable) -> None: + async def handle_service(call: ServiceCall) -> None: """Handle the service.""" await self.hass.helpers.service.entity_service_call( self._platforms.values(), func, call, required_features diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index bbf605e6bff..bad233c006a 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -716,7 +716,7 @@ def async_register_admin_service( hass: HomeAssistant, domain: str, service: str, - service_func: Callable[[ServiceCall], Awaitable | None], + service_func: Callable[[ServiceCall], Awaitable[None] | None], schema: vol.Schema = vol.Schema({}, extra=vol.PREVENT_EXTRA), ) -> None: """Register a service that requires admin access."""