mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Remove deprecated data entry flow constants (#131800)
* Remove deprecated data entry flow constants * Fix * Fix * Fix * Fix --------- Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
d596b4169d
commit
a68cf21179
@ -10,9 +10,8 @@ from aiohttp import ClientConnectorError
|
|||||||
from aiomusiccast import MusicCastConnectionException, MusicCastDevice
|
from aiomusiccast import MusicCastConnectionException, MusicCastDevice
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> data_entry_flow.ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
# Request user input, unless we are preparing discovery flow
|
# Request user input, unless we are preparing discovery flow
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
@ -73,9 +72,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return self._show_setup_form(errors)
|
return self._show_setup_form(errors)
|
||||||
|
|
||||||
def _show_setup_form(
|
def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult:
|
||||||
self, errors: dict | None = None
|
|
||||||
) -> data_entry_flow.ConfigFlowResult:
|
|
||||||
"""Show the setup form to the user."""
|
"""Show the setup form to the user."""
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
@ -85,7 +82,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
async def async_step_ssdp(
|
async def async_step_ssdp(
|
||||||
self, discovery_info: ssdp.SsdpServiceInfo
|
self, discovery_info: ssdp.SsdpServiceInfo
|
||||||
) -> data_entry_flow.ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle ssdp discoveries."""
|
"""Handle ssdp discoveries."""
|
||||||
if not await MusicCastDevice.check_yamaha_ssdp(
|
if not await MusicCastDevice.check_yamaha_ssdp(
|
||||||
discovery_info.ssdp_location, async_get_clientsession(self.hass)
|
discovery_info.ssdp_location, async_get_clientsession(self.hass)
|
||||||
@ -117,9 +114,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(self, user_input=None) -> ConfigFlowResult:
|
||||||
self, user_input=None
|
|
||||||
) -> data_entry_flow.ConfigFlowResult:
|
|
||||||
"""Allow the user to confirm adding the device."""
|
"""Allow the user to confirm adding the device."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -10,7 +10,6 @@ from contextlib import suppress
|
|||||||
import copy
|
import copy
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
from functools import partial
|
|
||||||
import logging
|
import logging
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import Any, Generic, Required, TypedDict, cast
|
from typing import Any, Generic, Required, TypedDict, cast
|
||||||
@ -20,12 +19,6 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from .core import HomeAssistant, callback
|
from .core import HomeAssistant, callback
|
||||||
from .exceptions import HomeAssistantError
|
from .exceptions import HomeAssistantError
|
||||||
from .helpers.deprecation import (
|
|
||||||
DeprecatedConstantEnum,
|
|
||||||
all_with_deprecated_constants,
|
|
||||||
check_if_deprecated_constant,
|
|
||||||
dir_with_deprecated_constants,
|
|
||||||
)
|
|
||||||
from .helpers.frame import ReportBehavior, report_usage
|
from .helpers.frame import ReportBehavior, report_usage
|
||||||
from .loader import async_suggest_report_issue
|
from .loader import async_suggest_report_issue
|
||||||
from .util import uuid as uuid_util
|
from .util import uuid as uuid_util
|
||||||
@ -46,26 +39,6 @@ class FlowResultType(StrEnum):
|
|||||||
MENU = "menu"
|
MENU = "menu"
|
||||||
|
|
||||||
|
|
||||||
# RESULT_TYPE_* is deprecated, to be removed in 2025.1
|
|
||||||
_DEPRECATED_RESULT_TYPE_FORM = DeprecatedConstantEnum(FlowResultType.FORM, "2025.1")
|
|
||||||
_DEPRECATED_RESULT_TYPE_CREATE_ENTRY = DeprecatedConstantEnum(
|
|
||||||
FlowResultType.CREATE_ENTRY, "2025.1"
|
|
||||||
)
|
|
||||||
_DEPRECATED_RESULT_TYPE_ABORT = DeprecatedConstantEnum(FlowResultType.ABORT, "2025.1")
|
|
||||||
_DEPRECATED_RESULT_TYPE_EXTERNAL_STEP = DeprecatedConstantEnum(
|
|
||||||
FlowResultType.EXTERNAL_STEP, "2025.1"
|
|
||||||
)
|
|
||||||
_DEPRECATED_RESULT_TYPE_EXTERNAL_STEP_DONE = DeprecatedConstantEnum(
|
|
||||||
FlowResultType.EXTERNAL_STEP_DONE, "2025.1"
|
|
||||||
)
|
|
||||||
_DEPRECATED_RESULT_TYPE_SHOW_PROGRESS = DeprecatedConstantEnum(
|
|
||||||
FlowResultType.SHOW_PROGRESS, "2025.1"
|
|
||||||
)
|
|
||||||
_DEPRECATED_RESULT_TYPE_SHOW_PROGRESS_DONE = DeprecatedConstantEnum(
|
|
||||||
FlowResultType.SHOW_PROGRESS_DONE, "2025.1"
|
|
||||||
)
|
|
||||||
_DEPRECATED_RESULT_TYPE_MENU = DeprecatedConstantEnum(FlowResultType.MENU, "2025.1")
|
|
||||||
|
|
||||||
# Event that is fired when a flow is progressed via external or progress source.
|
# Event that is fired when a flow is progressed via external or progress source.
|
||||||
EVENT_DATA_ENTRY_FLOW_PROGRESSED = "data_entry_flow_progressed"
|
EVENT_DATA_ENTRY_FLOW_PROGRESSED = "data_entry_flow_progressed"
|
||||||
|
|
||||||
@ -126,6 +99,7 @@ class InvalidData(vol.Invalid):
|
|||||||
schema_errors: dict[str, Any],
|
schema_errors: dict[str, Any],
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""Initialize an invalid data exception."""
|
||||||
super().__init__(message, path, error_message, **kwargs)
|
super().__init__(message, path, error_message, **kwargs)
|
||||||
self.schema_errors = schema_errors
|
self.schema_errors = schema_errors
|
||||||
|
|
||||||
@ -929,11 +903,3 @@ class section:
|
|||||||
def __call__(self, value: Any) -> Any:
|
def __call__(self, value: Any) -> Any:
|
||||||
"""Validate input."""
|
"""Validate input."""
|
||||||
return self.schema(value)
|
return self.schema(value)
|
||||||
|
|
||||||
|
|
||||||
# These can be removed if no deprecated constant are in this module anymore
|
|
||||||
__getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
|
|
||||||
__dir__ = partial(
|
|
||||||
dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
|
|
||||||
)
|
|
||||||
__all__ = all_with_deprecated_constants(globals())
|
|
||||||
|
@ -25,7 +25,7 @@ async def test_config_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
|
|||||||
BASE_CONFIG.copy(),
|
BASE_CONFIG.copy(),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "cluster.region.kusto.windows.net"
|
assert result2["title"] == "cluster.region.kusto.windows.net"
|
||||||
mock_setup_entry.assert_called_once()
|
mock_setup_entry.assert_called_once()
|
||||||
|
|
||||||
@ -59,12 +59,12 @@ async def test_config_flow_errors(
|
|||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
BASE_CONFIG.copy(),
|
BASE_CONFIG.copy(),
|
||||||
)
|
)
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": expected}
|
assert result2["errors"] == {"base": expected}
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
|
|
||||||
# Retest error handling if error is corrected and connection is successful
|
# Retest error handling if error is corrected and connection is successful
|
||||||
|
|
||||||
@ -77,4 +77,4 @@ async def test_config_flow_errors(
|
|||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||||
|
@ -13,11 +13,7 @@ from homeassistant.core import Event, HomeAssistant, callback
|
|||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.util.decorator import Registry
|
from homeassistant.util.decorator import Registry
|
||||||
|
|
||||||
from .common import (
|
from .common import async_capture_events
|
||||||
async_capture_events,
|
|
||||||
help_test_all,
|
|
||||||
import_and_test_deprecated_constant_enum,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class MockFlowManager(data_entry_flow.FlowManager):
|
class MockFlowManager(data_entry_flow.FlowManager):
|
||||||
@ -985,22 +981,6 @@ async def test_find_flows_by_init_data_type(manager: MockFlowManager) -> None:
|
|||||||
assert len(manager.async_progress()) == 0
|
assert len(manager.async_progress()) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_all() -> None:
|
|
||||||
"""Test module.__all__ is correctly set."""
|
|
||||||
help_test_all(data_entry_flow)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(("enum"), list(data_entry_flow.FlowResultType))
|
|
||||||
def test_deprecated_constants(
|
|
||||||
caplog: pytest.LogCaptureFixture,
|
|
||||||
enum: data_entry_flow.FlowResultType,
|
|
||||||
) -> None:
|
|
||||||
"""Test deprecated constants."""
|
|
||||||
import_and_test_deprecated_constant_enum(
|
|
||||||
caplog, data_entry_flow, enum, "RESULT_TYPE_", "2025.1"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_section_in_serializer() -> None:
|
def test_section_in_serializer() -> None:
|
||||||
"""Test section with custom_serializer."""
|
"""Test section with custom_serializer."""
|
||||||
assert cv.custom_serializer(
|
assert cv.custom_serializer(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user