mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
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
@ -1620,7 +1620,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
|||||||
return await self._async_step_discovery_without_unique_id()
|
return await self._async_step_discovery_without_unique_id()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_create_entry(
|
def async_create_entry( # type: ignore[override]
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
title: str,
|
title: str,
|
||||||
|
@ -84,27 +84,27 @@ class AbortFlow(FlowError):
|
|||||||
class FlowResult(TypedDict, total=False):
|
class FlowResult(TypedDict, total=False):
|
||||||
"""Typed result dict."""
|
"""Typed result dict."""
|
||||||
|
|
||||||
version: int
|
context: dict[str, Any]
|
||||||
type: FlowResultType
|
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
|
flow_id: str
|
||||||
handler: 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
|
last_step: bool | None
|
||||||
options: Mapping[str, Any]
|
|
||||||
menu_options: list[str] | dict[str, str]
|
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
|
@callback
|
||||||
@ -498,23 +498,25 @@ class FlowHandler:
|
|||||||
def async_create_entry(
|
def async_create_entry(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
title: str,
|
title: str | None = None,
|
||||||
data: Mapping[str, Any],
|
data: Mapping[str, Any],
|
||||||
description: str | None = None,
|
description: str | None = None,
|
||||||
description_placeholders: Mapping[str, str] | 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 FlowResult(
|
flow_result = FlowResult(
|
||||||
version=self.VERSION,
|
version=self.VERSION,
|
||||||
type=FlowResultType.CREATE_ENTRY,
|
type=FlowResultType.CREATE_ENTRY,
|
||||||
flow_id=self.flow_id,
|
flow_id=self.flow_id,
|
||||||
handler=self.handler,
|
handler=self.handler,
|
||||||
title=title,
|
|
||||||
data=data,
|
data=data,
|
||||||
description=description,
|
description=description,
|
||||||
description_placeholders=description_placeholders,
|
description_placeholders=description_placeholders,
|
||||||
context=self.context,
|
context=self.context,
|
||||||
)
|
)
|
||||||
|
if title is not None:
|
||||||
|
flow_result["title"] = title
|
||||||
|
return flow_result
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_abort(
|
def async_abort(
|
||||||
|
@ -401,7 +401,7 @@ class SchemaOptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry):
|
|||||||
"""Finish config flow and create a config entry."""
|
"""Finish config flow and create a config entry."""
|
||||||
if self._async_options_flow_finished:
|
if self._async_options_flow_finished:
|
||||||
self._async_options_flow_finished(self.hass, data)
|
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
|
@callback
|
||||||
|
@ -110,5 +110,4 @@ async def test_option_flow(hass):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == ""
|
|
||||||
assert result["data"]["forecast_threshold"] == 65
|
assert result["data"]["forecast_threshold"] == 65
|
||||||
|
@ -84,6 +84,9 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
|
|||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.username",
|
||||||
|
"some_name",
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.ovo_energy.async_setup_entry",
|
"homeassistant.components.ovo_energy.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
|
@ -43,6 +43,7 @@ class VenstarColorTouchMock:
|
|||||||
|
|
||||||
def update_info(self):
|
def update_info(self):
|
||||||
"""Mock update_info."""
|
"""Mock update_info."""
|
||||||
|
self.name = "username"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def broken_update_info(self):
|
def broken_update_info(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user