mirror of
https://github.com/home-assistant/core.git
synced 2025-11-16 14:30:22 +00:00
Add TypeVar default for FlowResult (#112345)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from http import HTTPStatus
|
||||
from typing import Any
|
||||
from typing import Any, Generic
|
||||
|
||||
from aiohttp import web
|
||||
from typing_extensions import TypeVar
|
||||
import voluptuous as vol
|
||||
import voluptuous_serialize
|
||||
|
||||
@@ -14,11 +15,17 @@ from homeassistant.components.http.data_validator import RequestDataValidator
|
||||
|
||||
from . import config_validation as cv
|
||||
|
||||
_FlowManagerT = TypeVar(
|
||||
"_FlowManagerT",
|
||||
bound=data_entry_flow.FlowManager[Any],
|
||||
default=data_entry_flow.FlowManager,
|
||||
)
|
||||
|
||||
class _BaseFlowManagerView(HomeAssistantView):
|
||||
|
||||
class _BaseFlowManagerView(HomeAssistantView, Generic[_FlowManagerT]):
|
||||
"""Foundation for flow manager views."""
|
||||
|
||||
def __init__(self, flow_mgr: data_entry_flow.BaseFlowManager) -> None:
|
||||
def __init__(self, flow_mgr: _FlowManagerT) -> None:
|
||||
"""Initialize the flow manager index view."""
|
||||
self._flow_mgr = flow_mgr
|
||||
|
||||
@@ -48,7 +55,7 @@ class _BaseFlowManagerView(HomeAssistantView):
|
||||
return data
|
||||
|
||||
|
||||
class FlowManagerIndexView(_BaseFlowManagerView):
|
||||
class FlowManagerIndexView(_BaseFlowManagerView[_FlowManagerT]):
|
||||
"""View to create config flows."""
|
||||
|
||||
@RequestDataValidator(
|
||||
@@ -96,7 +103,7 @@ class FlowManagerIndexView(_BaseFlowManagerView):
|
||||
return {"show_advanced_options": data["show_advanced_options"]}
|
||||
|
||||
|
||||
class FlowManagerResourceView(_BaseFlowManagerView):
|
||||
class FlowManagerResourceView(_BaseFlowManagerView[_FlowManagerT]):
|
||||
"""View to interact with the flow manager."""
|
||||
|
||||
async def get(self, request: web.Request, /, flow_id: str) -> web.Response:
|
||||
|
||||
Reference in New Issue
Block a user