Compare commits

...

1 Commits

Author SHA1 Message Date
Erik 8283f6bc72 Deprecate the FlowHandler show_advanced_options property 2026-05-21 18:54:01 +02:00
2 changed files with 24 additions and 5 deletions
+11 -2
View File
@@ -16,6 +16,7 @@ import voluptuous as vol
from .core import HomeAssistant, callback
from .exceptions import HomeAssistantError
from .helpers.deprecation import deprecated_function
from .helpers.frame import ReportBehavior, report_usage
from .loader import async_suggest_report_issue
from .util import uuid as uuid_util
@@ -641,9 +642,17 @@ class FlowHandler(Generic[_FlowContextT, _FlowResultT, _HandlerT]):
return self.context.get("source", None) # type: ignore[return-value]
@property
@deprecated_function(
"a user friendly way to present additional options in the UI, for example in a section",
breaks_in_ha_version="2027.6",
)
def show_advanced_options(self) -> bool:
"""If we should show advanced options."""
return self.context.get("show_advanced_options", False) # type: ignore[return-value]
"""If we should show advanced options.
During the deprecation period return True to not break existing flows that use
this property to determine whether to show additional options.
"""
return True
def add_suggested_values_to_schema(
self, data_schema: vol.Schema, suggested_values: Mapping[str, Any] | None
+13 -3
View File
@@ -1278,13 +1278,17 @@ def test_nested_section_in_serializer() -> None:
@pytest.mark.parametrize(
("context", "expected_show_advanced"),
[
({}, False),
({"show_advanced_options": False}, False),
# 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
manager: MockFlowManager,
context: dict[str, Any],
expected_show_advanced: bool,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test FlowHandler show_advanced_options property."""
@@ -1303,3 +1307,9 @@ async def test_show_advanced_options(
entry = manager.mock_created_entries[0]
assert entry["handler"] == "test"
assert entry["title"] == "hello"
assert (
"The deprecated function show_advanced_options was called. It will be "
"removed in HA Core 2027.6. Use a user friendly way to present additional "
"options in the UI, for example in a section instead"
) in caplog.text