From 0c816c22e0f265c2009118ffa9f51a6c242581f9 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 May 2026 11:13:24 +0200 Subject: [PATCH] Remove `show_advanced_options` from data entry flow API (#172249) --- .../components/config/config_entries.py | 2 -- homeassistant/data_entry_flow.py | 1 - homeassistant/helpers/data_entry_flow.py | 3 +-- tests/common.py | 6 ------ .../components/config/test_config_entries.py | 4 ++-- tests/components/dnsip/test_config_flow.py | 6 +++--- tests/components/group/test_config_flow.py | 20 +++++++------------ tests/test_data_entry_flow.py | 18 +++-------------- 8 files changed, 16 insertions(+), 44 deletions(-) diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index e92fc9d3e926..15d793ee1b65 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -175,7 +175,6 @@ class ConfigManagerFlowIndexView( vol.Schema( { vol.Required("handler"): vol.Any(str, list), - vol.Optional("show_advanced_options", default=False): cv.boolean, vol.Optional("entry_id"): cv.string, }, extra=vol.ALLOW_EXTRA, @@ -302,7 +301,6 @@ class SubentryManagerFlowIndexView( vol.Schema( { vol.Required("handler"): vol.All(vol.Coerce(tuple), (str, str)), - vol.Optional("show_advanced_options", default=False): cv.boolean, }, extra=vol.ALLOW_EXTRA, ) diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index ca5fa08f40dd..d17a02222d2b 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -118,7 +118,6 @@ class AbortFlow(FlowError): class FlowContext(TypedDict, total=False): """Typed context dict.""" - show_advanced_options: bool source: str diff --git a/homeassistant/helpers/data_entry_flow.py b/homeassistant/helpers/data_entry_flow.py index 464e3f249c4a..719ed2d2f90e 100644 --- a/homeassistant/helpers/data_entry_flow.py +++ b/homeassistant/helpers/data_entry_flow.py @@ -60,7 +60,6 @@ class FlowManagerIndexView(_BaseFlowManagerView[_FlowManagerT]): vol.Schema( { vol.Required("handler"): str, - vol.Optional("show_advanced_options", default=False): cv.boolean, }, extra=vol.ALLOW_EXTRA, ) @@ -93,7 +92,7 @@ class FlowManagerIndexView(_BaseFlowManagerView[_FlowManagerT]): def get_context(self, data: dict[str, Any]) -> dict[str, Any]: """Return context.""" - return {"show_advanced_options": data["show_advanced_options"]} + return {} class FlowManagerResourceView(_BaseFlowManagerView[_FlowManagerT]): diff --git a/tests/common.py b/tests/common.py index c875de454888..dbb11bdbc632 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1176,8 +1176,6 @@ class MockConfigEntry(config_entries.ConfigEntry): async def start_reconfigure_flow( self, hass: HomeAssistant, - *, - show_advanced_options: bool = False, ) -> ConfigFlowResult: """Start a reconfiguration flow.""" if self.entry_id not in hass.config_entries._entries: @@ -1189,7 +1187,6 @@ class MockConfigEntry(config_entries.ConfigEntry): context={ "source": config_entries.SOURCE_RECONFIGURE, "entry_id": self.entry_id, - "show_advanced_options": show_advanced_options, }, ) @@ -1197,8 +1194,6 @@ class MockConfigEntry(config_entries.ConfigEntry): self, hass: HomeAssistant, subentry_id: str, - *, - show_advanced_options: bool = False, ) -> ConfigFlowResult: """Start a subentry reconfiguration flow.""" if self.entry_id not in hass.config_entries._entries: @@ -1212,7 +1207,6 @@ class MockConfigEntry(config_entries.ConfigEntry): context={ "source": config_entries.SOURCE_RECONFIGURE, "subentry_id": subentry_id, - "show_advanced_options": show_advanced_options, }, ) diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index 332b023eb22c..07e2441c5a93 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -419,7 +419,7 @@ async def test_initialize_flow(hass: HomeAssistant, client: TestClient) -> None: with mock_config_flow("test", TestFlow): resp = await client.post( "/api/config/config_entries/flow", - json={"handler": "test", "show_advanced_options": True}, + json={"handler": "test"}, ) assert resp.status == HTTPStatus.OK @@ -469,7 +469,7 @@ async def test_initialize_flow_unmet_dependency( with mock_config_flow("test2", TestFlow): resp = await client.post( "/api/config/config_entries/flow", - json={"handler": "test2", "show_advanced_options": True}, + json={"handler": "test2"}, ) assert resp.status == HTTPStatus.BAD_REQUEST diff --git a/tests/components/dnsip/test_config_flow.py b/tests/components/dnsip/test_config_flow.py index 0d67f57adb24..481fed6ede88 100644 --- a/tests/components/dnsip/test_config_flow.py +++ b/tests/components/dnsip/test_config_flow.py @@ -71,12 +71,12 @@ async def test_form(hass: HomeAssistant) -> None: assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_adv(hass: HomeAssistant) -> None: - """Test we get the form with advanced options on.""" +async def test_form_with_advanced_options(hass: HomeAssistant) -> None: + """Test we can submit the form with custom resolver and port options.""" result = await hass.config_entries.flow.async_init( DOMAIN, - context={"source": config_entries.SOURCE_USER, "show_advanced_options": True}, + context={"source": config_entries.SOURCE_USER}, ) assert result["data_schema"] == DATA_SCHEMA diff --git a/tests/components/group/test_config_flow.py b/tests/components/group/test_config_flow.py index c570492e6b5c..8381079c728a 100644 --- a/tests/components/group/test_config_flow.py +++ b/tests/components/group/test_config_flow.py @@ -317,20 +317,16 @@ async def test_options( @pytest.mark.parametrize( - ("group_type", "extra_options", "extra_options_after", "advanced"), + ("group_type", "extra_options", "extra_options_after"), [ - ("light", {"all": False}, {"all": False}, False), - ("light", {"all": True}, {"all": False}, False), - ("light", {"all": False}, {"all": False}, True), - ("light", {"all": True}, {"all": False}, True), - ("switch", {"all": False}, {"all": False}, False), - ("switch", {"all": True}, {"all": False}, False), - ("switch", {"all": False}, {"all": False}, True), - ("switch", {"all": True}, {"all": False}, True), + ("light", {"all": False}, {"all": False}), + ("light", {"all": True}, {"all": False}), + ("switch", {"all": False}, {"all": False}), + ("switch", {"all": True}, {"all": False}), ], ) async def test_all_options( - hass: HomeAssistant, group_type, extra_options, extra_options_after, advanced + hass: HomeAssistant, group_type, extra_options, extra_options_after ) -> None: """Test reconfiguring.""" members1 = [f"{group_type}.one", f"{group_type}.two"] @@ -356,9 +352,7 @@ async def test_all_options( config_entry = hass.config_entries.async_entries(DOMAIN)[0] - result = await hass.config_entries.options.async_init( - config_entry.entry_id, context={"show_advanced_options": advanced} - ) + result = await hass.config_entries.options.async_init(config_entry.entry_id) assert result["type"] is FlowResultType.FORM assert result["step_id"] == group_type diff --git a/tests/test_data_entry_flow.py b/tests/test_data_entry_flow.py index 480d25488726..ec6254217d16 100644 --- a/tests/test_data_entry_flow.py +++ b/tests/test_data_entry_flow.py @@ -3,7 +3,6 @@ import asyncio import dataclasses import logging -from typing import Any from unittest.mock import Mock, patch import pytest @@ -1275,32 +1274,21 @@ def test_nested_section_in_serializer() -> None: ) -@pytest.mark.parametrize( - ("context", "expected_show_advanced"), - [ - # The property is deprecated and now unconditionally returns True - ({}, True), - ({"show_advanced_options": False}, True), - ({"show_advanced_options": True}, True), - ], -) async def test_show_advanced_options( manager: MockFlowManager, - context: dict[str, Any], - expected_show_advanced: bool, caplog: pytest.LogCaptureFixture, ) -> None: - """Test FlowHandler show_advanced_options property.""" + """Test FlowHandler show_advanced_options property is deprecated and always True.""" @manager.mock_reg_handler("test") class TestFlow(data_entry_flow.FlowHandler): VERSION = 5 async def async_step_init(self, info): - assert self.show_advanced_options == expected_show_advanced + assert self.show_advanced_options is True return self.async_create_entry(title="hello", data={}) - await manager.async_init("test", context=context, data={}) + await manager.async_init("test", context={}, data={}) assert len(manager.async_progress()) == 0 assert len(manager.mock_created_entries) == 1