mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Improve decorator type annotations [core] (#104826)
This commit is contained in:
parent
46ba62a3c0
commit
2496c275c8
@ -1,7 +1,7 @@
|
||||
"""API for persistent storage for the frontend."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Coroutine
|
||||
from functools import wraps
|
||||
from typing import Any
|
||||
|
||||
@ -50,12 +50,19 @@ async def async_user_store(
|
||||
return store, data[user_id]
|
||||
|
||||
|
||||
def with_store(orig_func: Callable) -> Callable:
|
||||
def with_store(
|
||||
orig_func: Callable[
|
||||
[HomeAssistant, ActiveConnection, dict[str, Any], Store, dict[str, Any]],
|
||||
Coroutine[Any, Any, None],
|
||||
],
|
||||
) -> Callable[
|
||||
[HomeAssistant, ActiveConnection, dict[str, Any]], Coroutine[Any, Any, None]
|
||||
]:
|
||||
"""Decorate function to provide data."""
|
||||
|
||||
@wraps(orig_func)
|
||||
async def with_store_func(
|
||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict
|
||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
|
||||
) -> None:
|
||||
"""Provide user specific data and store to function."""
|
||||
user_id = connection.user.id
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Repairs implementation for supervisor integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Coroutine
|
||||
from types import MethodType
|
||||
from typing import Any
|
||||
|
||||
@ -116,7 +117,12 @@ class SupervisorIssueRepairFlow(RepairsFlow):
|
||||
return self.async_create_entry(data={})
|
||||
|
||||
@staticmethod
|
||||
def _async_step(suggestion: Suggestion) -> Callable:
|
||||
def _async_step(
|
||||
suggestion: Suggestion,
|
||||
) -> Callable[
|
||||
[SupervisorIssueRepairFlow, dict[str, str] | None],
|
||||
Coroutine[Any, Any, FlowResult],
|
||||
]:
|
||||
"""Generate a step handler for a suggestion."""
|
||||
|
||||
async def _async_step(
|
||||
|
@ -331,7 +331,12 @@ class SchemaConfigFlowHandler(config_entries.ConfigFlow, ABC):
|
||||
return cls.options_flow is not None
|
||||
|
||||
@staticmethod
|
||||
def _async_step(step_id: str) -> Callable:
|
||||
def _async_step(
|
||||
step_id: str,
|
||||
) -> Callable[
|
||||
[SchemaConfigFlowHandler, dict[str, Any] | None],
|
||||
Coroutine[Any, Any, FlowResult],
|
||||
]:
|
||||
"""Generate a step handler."""
|
||||
|
||||
async def _async_step(
|
||||
@ -421,7 +426,12 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
||||
setattr(self, "async_setup_preview", async_setup_preview)
|
||||
|
||||
@staticmethod
|
||||
def _async_step(step_id: str) -> Callable:
|
||||
def _async_step(
|
||||
step_id: str,
|
||||
) -> Callable[
|
||||
[SchemaConfigFlowHandler, dict[str, Any] | None],
|
||||
Coroutine[Any, Any, FlowResult],
|
||||
]:
|
||||
"""Generate a step handler."""
|
||||
|
||||
async def _async_step(
|
||||
|
Loading…
x
Reference in New Issue
Block a user