Improve typing in core service registration (#63005)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-30 21:18:10 +01:00 committed by GitHub
parent 1320f27fd7
commit 9971831b51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -1330,7 +1330,7 @@ class ServiceRegistry:
self, self,
domain: str, domain: str,
service: str, service: str,
service_func: Callable, service_func: Callable[[ServiceCall], Awaitable[None] | None],
schema: vol.Schema | None = None, schema: vol.Schema | None = None,
) -> None: ) -> None:
""" """
@ -1347,7 +1347,7 @@ class ServiceRegistry:
self, self,
domain: str, domain: str,
service: str, service: str,
service_func: Callable, service_func: Callable[[ServiceCall], Awaitable[None] | None],
schema: vol.Schema | None = None, schema: vol.Schema | None = None,
) -> None: ) -> None:
""" """

View File

@ -198,7 +198,7 @@ class EntityComponent:
if isinstance(schema, dict): if isinstance(schema, dict):
schema = cv.make_entity_service_schema(schema) schema = cv.make_entity_service_schema(schema)
async def handle_service(call: Callable) -> None: async def handle_service(call: ServiceCall) -> None:
"""Handle the service.""" """Handle the service."""
await self.hass.helpers.service.entity_service_call( await self.hass.helpers.service.entity_service_call(
self._platforms.values(), func, call, required_features self._platforms.values(), func, call, required_features

View File

@ -716,7 +716,7 @@ def async_register_admin_service(
hass: HomeAssistant, hass: HomeAssistant,
domain: str, domain: str,
service: 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), schema: vol.Schema = vol.Schema({}, extra=vol.PREVENT_EXTRA),
) -> None: ) -> None:
"""Register a service that requires admin access.""" """Register a service that requires admin access."""