Prevent None strings in description_placeholders (#127103)

pull/130707/head
epenet 2024-11-15 14:39:57 +01:00 committed by GitHub
parent dc09b7a532
commit e772eef035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 15 additions and 5 deletions

View File

@ -92,6 +92,7 @@ class EmonitorConfigFlow(ConfigFlow, domain=DOMAIN):
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Attempt to confirm.""" """Attempt to confirm."""
assert self.discovered_ip is not None
if user_input is not None: if user_input is not None:
return self.async_create_entry( return self.async_create_entry(
title=self.discovered_info["title"], title=self.discovered_info["title"],

View File

@ -145,6 +145,7 @@ class KodiConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle user-confirmation of discovered node.""" """Handle user-confirmation of discovered node."""
if user_input is None: if user_input is None:
assert self._name is not None
return self.async_show_form( return self.async_show_form(
step_id="discovery_confirm", step_id="discovery_confirm",
description_placeholders={"name": self._name}, description_placeholders={"name": self._name},

View File

@ -97,7 +97,10 @@ class LookinFlowHandler(ConfigFlow, domain=DOMAIN):
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
step_id="discovery_confirm", step_id="discovery_confirm",
description_placeholders={"name": self._name, "host": self._host}, description_placeholders={
"name": self._name or "LOOKin",
"host": self._host,
},
) )
return self.async_create_entry( return self.async_create_entry(

View File

@ -93,6 +93,9 @@ class RidwellConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle re-auth completion.""" """Handle re-auth completion."""
if not user_input: if not user_input:
if TYPE_CHECKING:
assert self._username
return self.async_show_form( return self.async_show_form(
step_id="reauth_confirm", step_id="reauth_confirm",
data_schema=STEP_REAUTH_CONFIRM_DATA_SCHEMA, data_schema=STEP_REAUTH_CONFIRM_DATA_SCHEMA,

View File

@ -24,6 +24,8 @@ class SongpalConfig:
def __init__(self, name: str, host: str | None, endpoint: str) -> None: def __init__(self, name: str, host: str | None, endpoint: str) -> None:
"""Initialize Configuration.""" """Initialize Configuration."""
self.name = name self.name = name
if TYPE_CHECKING:
assert host is not None
self.host = host self.host = host
self.endpoint = endpoint self.endpoint = endpoint

View File

@ -372,7 +372,7 @@ class WorkdayOptionsFlowHandler(OptionsFlow):
errors=errors, errors=errors,
description_placeholders={ description_placeholders={
"name": options[CONF_NAME], "name": options[CONF_NAME],
"country": options.get(CONF_COUNTRY), "country": options.get(CONF_COUNTRY, "-"),
}, },
) )

View File

@ -2966,7 +2966,7 @@ class ConfigFlow(ConfigEntryBaseFlow):
step_id: str | None = None, step_id: str | None = None,
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: Mapping[str, str | None] | None = None, description_placeholders: Mapping[str, str] | None = None,
last_step: bool | None = None, last_step: bool | None = None,
preview: str | None = None, preview: str | None = None,
) -> ConfigFlowResult: ) -> ConfigFlowResult:

View File

@ -155,7 +155,7 @@ class FlowResult(TypedDict, Generic[_FlowContextT, _HandlerT], total=False):
context: _FlowContextT context: _FlowContextT
data_schema: vol.Schema | None data_schema: vol.Schema | None
data: Mapping[str, Any] data: Mapping[str, Any]
description_placeholders: Mapping[str, str | None] | None description_placeholders: Mapping[str, str] | None
description: str | None description: str | None
errors: dict[str, str] | None errors: dict[str, str] | None
extra: str extra: str
@ -705,7 +705,7 @@ class FlowHandler(Generic[_FlowContextT, _FlowResultT, _HandlerT]):
step_id: str | None = None, step_id: str | None = None,
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: Mapping[str, str | None] | None = None, description_placeholders: Mapping[str, str] | None = None,
last_step: bool | None = None, last_step: bool | None = None,
preview: str | None = None, preview: str | None = None,
) -> _FlowResultT: ) -> _FlowResultT: