Make it optional to provide a title when finishing a FlowHandler (#83534)
* Make it optional to provide a title when finishing a FlowHandler * Make ConfigEntry.title a str * Revert changes in ConfigFlow * Adjust tests
This commit is contained in:
parent
8f761f44bd
commit
cc132bfad6
6 changed files with 28 additions and 23 deletions
|
@ -1620,7 +1620,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
|||
return await self._async_step_discovery_without_unique_id()
|
||||
|
||||
@callback
|
||||
def async_create_entry(
|
||||
def async_create_entry( # type: ignore[override]
|
||||
self,
|
||||
*,
|
||||
title: str,
|
||||
|
|
|
@ -84,27 +84,27 @@ class AbortFlow(FlowError):
|
|||
class FlowResult(TypedDict, total=False):
|
||||
"""Typed result dict."""
|
||||
|
||||
version: int
|
||||
type: FlowResultType
|
||||
context: dict[str, Any]
|
||||
data_schema: vol.Schema | None
|
||||
data: Mapping[str, Any]
|
||||
description_placeholders: Mapping[str, str | None] | None
|
||||
description: str | None
|
||||
errors: dict[str, str] | None
|
||||
extra: str
|
||||
flow_id: str
|
||||
handler: str
|
||||
title: str
|
||||
data: Mapping[str, Any]
|
||||
step_id: str
|
||||
data_schema: vol.Schema | None
|
||||
extra: str
|
||||
required: bool
|
||||
errors: dict[str, str] | None
|
||||
description: str | None
|
||||
description_placeholders: Mapping[str, str | None] | None
|
||||
progress_action: str
|
||||
url: str
|
||||
reason: str
|
||||
context: dict[str, Any]
|
||||
result: Any
|
||||
last_step: bool | None
|
||||
options: Mapping[str, Any]
|
||||
menu_options: list[str] | dict[str, str]
|
||||
options: Mapping[str, Any]
|
||||
progress_action: str
|
||||
reason: str
|
||||
required: bool
|
||||
result: Any
|
||||
step_id: str
|
||||
title: str
|
||||
type: FlowResultType
|
||||
url: str
|
||||
version: int
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -498,23 +498,25 @@ class FlowHandler:
|
|||
def async_create_entry(
|
||||
self,
|
||||
*,
|
||||
title: str,
|
||||
title: str | None = None,
|
||||
data: Mapping[str, Any],
|
||||
description: str | None = None,
|
||||
description_placeholders: Mapping[str, str] | None = None,
|
||||
) -> FlowResult:
|
||||
"""Finish config flow and create a config entry."""
|
||||
return FlowResult(
|
||||
flow_result = FlowResult(
|
||||
version=self.VERSION,
|
||||
type=FlowResultType.CREATE_ENTRY,
|
||||
flow_id=self.flow_id,
|
||||
handler=self.handler,
|
||||
title=title,
|
||||
data=data,
|
||||
description=description,
|
||||
description_placeholders=description_placeholders,
|
||||
context=self.context,
|
||||
)
|
||||
if title is not None:
|
||||
flow_result["title"] = title
|
||||
return flow_result
|
||||
|
||||
@callback
|
||||
def async_abort(
|
||||
|
|
|
@ -401,7 +401,7 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
|||
"""Finish config flow and create a config entry."""
|
||||
if self._async_options_flow_finished:
|
||||
self._async_options_flow_finished(self.hass, data)
|
||||
return super().async_create_entry(title="", data=data, **kwargs)
|
||||
return super().async_create_entry(data=data, **kwargs)
|
||||
|
||||
|
||||
@callback
|
||||
|
|
|
@ -110,5 +110,4 @@ async def test_option_flow(hass):
|
|||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"]["forecast_threshold"] == 65
|
||||
|
|
|
@ -84,6 +84,9 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
|
|||
with patch(
|
||||
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
||||
return_value=True,
|
||||
), patch(
|
||||
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.username",
|
||||
"some_name",
|
||||
), patch(
|
||||
"homeassistant.components.ovo_energy.async_setup_entry",
|
||||
return_value=True,
|
||||
|
|
|
@ -43,6 +43,7 @@ class VenstarColorTouchMock:
|
|||
|
||||
def update_info(self):
|
||||
"""Mock update_info."""
|
||||
self.name = "username"
|
||||
return True
|
||||
|
||||
def broken_update_info(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue