mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Ensure description_placeholders is always typed (#72716)
This commit is contained in:
parent
db9c586404
commit
627d6f7803
@ -272,7 +272,7 @@ class LoginFlow(data_entry_flow.FlowHandler):
|
|||||||
if not errors:
|
if not errors:
|
||||||
return await self.async_finish(self.credential)
|
return await self.async_finish(self.credential)
|
||||||
|
|
||||||
description_placeholders: dict[str, str | None] = {
|
description_placeholders: dict[str, str] = {
|
||||||
"mfa_module_name": auth_module.name,
|
"mfa_module_name": auth_module.name,
|
||||||
"mfa_module_id": auth_module.id,
|
"mfa_module_id": auth_module.id,
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from homewizard_energy import HomeWizardEnergy
|
from homewizard_energy import HomeWizardEnergy
|
||||||
from homewizard_energy.errors import DisabledError, UnsupportedError
|
from homewizard_energy.errors import DisabledError, UnsupportedError
|
||||||
@ -160,9 +160,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="discovery_confirm",
|
step_id="discovery_confirm",
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
CONF_PRODUCT_TYPE: self.config[CONF_PRODUCT_TYPE],
|
CONF_PRODUCT_TYPE: cast(str, self.config[CONF_PRODUCT_TYPE]),
|
||||||
CONF_SERIAL: self.config[CONF_SERIAL],
|
CONF_SERIAL: cast(str, self.config[CONF_SERIAL]),
|
||||||
CONF_IP_ADDRESS: self.config[CONF_IP_ADDRESS],
|
CONF_IP_ADDRESS: cast(str, self.config[CONF_IP_ADDRESS]),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="select_station",
|
step_id="select_station",
|
||||||
description_placeholders={"stations_count": len(self._stations)},
|
description_placeholders={"stations_count": str(len(self._stations))},
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{vol.Required(CONF_STATIONS): cv.multi_select(self._stations)}
|
{vol.Required(CONF_STATIONS): cv.multi_select(self._stations)}
|
||||||
),
|
),
|
||||||
|
@ -1403,7 +1403,10 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_abort(
|
def async_abort(
|
||||||
self, *, reason: str, description_placeholders: dict | None = None
|
self,
|
||||||
|
*,
|
||||||
|
reason: str,
|
||||||
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> data_entry_flow.FlowResult:
|
) -> data_entry_flow.FlowResult:
|
||||||
"""Abort the config flow."""
|
"""Abort the config flow."""
|
||||||
# Remove reauth notification if no reauth flows are in progress
|
# Remove reauth notification if no reauth flows are in progress
|
||||||
@ -1477,7 +1480,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
|||||||
title: str,
|
title: str,
|
||||||
data: Mapping[str, Any],
|
data: Mapping[str, Any],
|
||||||
description: str | None = None,
|
description: str | None = None,
|
||||||
description_placeholders: dict | None = None,
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
options: Mapping[str, Any] | None = None,
|
options: Mapping[str, Any] | None = None,
|
||||||
) -> data_entry_flow.FlowResult:
|
) -> data_entry_flow.FlowResult:
|
||||||
"""Finish config flow and create a config entry."""
|
"""Finish config flow and create a config entry."""
|
||||||
|
@ -52,7 +52,7 @@ class AbortFlow(FlowError):
|
|||||||
"""Exception to indicate a flow needs to be aborted."""
|
"""Exception to indicate a flow needs to be aborted."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, reason: str, description_placeholders: dict | None = None
|
self, reason: str, description_placeholders: Mapping[str, str] | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize an abort flow exception."""
|
"""Initialize an abort flow exception."""
|
||||||
super().__init__(f"Flow aborted: {reason}")
|
super().__init__(f"Flow aborted: {reason}")
|
||||||
@ -75,7 +75,7 @@ class FlowResult(TypedDict, total=False):
|
|||||||
required: bool
|
required: bool
|
||||||
errors: dict[str, str] | None
|
errors: dict[str, str] | None
|
||||||
description: str | None
|
description: str | None
|
||||||
description_placeholders: dict[str, Any] | None
|
description_placeholders: Mapping[str, str | None] | None
|
||||||
progress_action: str
|
progress_action: str
|
||||||
url: str
|
url: str
|
||||||
reason: str
|
reason: str
|
||||||
@ -422,7 +422,7 @@ class FlowHandler:
|
|||||||
step_id: str,
|
step_id: str,
|
||||||
data_schema: vol.Schema | None = None,
|
data_schema: vol.Schema | None = None,
|
||||||
errors: dict[str, str] | None = None,
|
errors: dict[str, str] | None = None,
|
||||||
description_placeholders: dict[str, Any] | None = None,
|
description_placeholders: Mapping[str, str | None] | None = None,
|
||||||
last_step: bool | None = None,
|
last_step: bool | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Return the definition of a form to gather user input."""
|
"""Return the definition of a form to gather user input."""
|
||||||
@ -444,7 +444,7 @@ class FlowHandler:
|
|||||||
title: str,
|
title: str,
|
||||||
data: Mapping[str, Any],
|
data: Mapping[str, Any],
|
||||||
description: str | None = None,
|
description: str | None = None,
|
||||||
description_placeholders: dict | None = None,
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Finish config flow and create a config entry."""
|
"""Finish config flow and create a config entry."""
|
||||||
return {
|
return {
|
||||||
@ -460,7 +460,10 @@ class FlowHandler:
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_abort(
|
def async_abort(
|
||||||
self, *, reason: str, description_placeholders: dict | None = None
|
self,
|
||||||
|
*,
|
||||||
|
reason: str,
|
||||||
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Abort the config flow."""
|
"""Abort the config flow."""
|
||||||
return _create_abort_data(
|
return _create_abort_data(
|
||||||
@ -469,7 +472,11 @@ class FlowHandler:
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_external_step(
|
def async_external_step(
|
||||||
self, *, step_id: str, url: str, description_placeholders: dict | None = None
|
self,
|
||||||
|
*,
|
||||||
|
step_id: str,
|
||||||
|
url: str,
|
||||||
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Return the definition of an external step for the user to take."""
|
"""Return the definition of an external step for the user to take."""
|
||||||
return {
|
return {
|
||||||
@ -497,7 +504,7 @@ class FlowHandler:
|
|||||||
*,
|
*,
|
||||||
step_id: str,
|
step_id: str,
|
||||||
progress_action: str,
|
progress_action: str,
|
||||||
description_placeholders: dict | None = None,
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Show a progress message to the user, without user input allowed."""
|
"""Show a progress message to the user, without user input allowed."""
|
||||||
return {
|
return {
|
||||||
@ -525,7 +532,7 @@ class FlowHandler:
|
|||||||
*,
|
*,
|
||||||
step_id: str,
|
step_id: str,
|
||||||
menu_options: list[str] | dict[str, str],
|
menu_options: list[str] | dict[str, str],
|
||||||
description_placeholders: dict | None = None,
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Show a navigation menu to the user.
|
"""Show a navigation menu to the user.
|
||||||
|
|
||||||
@ -547,7 +554,7 @@ def _create_abort_data(
|
|||||||
flow_id: str,
|
flow_id: str,
|
||||||
handler: str,
|
handler: str,
|
||||||
reason: str,
|
reason: str,
|
||||||
description_placeholders: dict | None = None,
|
description_placeholders: Mapping[str, str] | None = None,
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Return the definition of an external step for the user to take."""
|
"""Return the definition of an external step for the user to take."""
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user