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:
Robert Resch 2024-11-29 00:37:26 +01:00 committed by GitHub
parent d596b4169d
commit a68cf21179
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 70 deletions

View File

@ -10,9 +10,8 @@ from aiohttp import ClientConnectorError
from aiomusiccast import MusicCastConnectionException, MusicCastDevice
import voluptuous as vol
from homeassistant import data_entry_flow
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.helpers.aiohttp_client import async_get_clientsession
@ -33,7 +32,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> data_entry_flow.ConfigFlowResult:
) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
# Request user input, unless we are preparing discovery flow
if user_input is None:
@ -73,9 +72,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
return self._show_setup_form(errors)
def _show_setup_form(
self, errors: dict | None = None
) -> data_entry_flow.ConfigFlowResult:
def _show_setup_form(self, errors: dict | None = None) -> ConfigFlowResult:
"""Show the setup form to the user."""
return self.async_show_form(
step_id="user",
@ -85,7 +82,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp(
self, discovery_info: ssdp.SsdpServiceInfo
) -> data_entry_flow.ConfigFlowResult:
) -> ConfigFlowResult:
"""Handle ssdp discoveries."""
if not await MusicCastDevice.check_yamaha_ssdp(
discovery_info.ssdp_location, async_get_clientsession(self.hass)
@ -117,9 +114,7 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
return await self.async_step_confirm()
async def async_step_confirm(
self, user_input=None
) -> data_entry_flow.ConfigFlowResult:
async def async_step_confirm(self, user_input=None) -> ConfigFlowResult:
"""Allow the user to confirm adding the device."""
if user_input is not None:
return self.async_create_entry(

View File

@ -10,7 +10,6 @@ from contextlib import suppress
import copy
from dataclasses import dataclass
from enum import StrEnum
from functools import partial
import logging
from types import MappingProxyType
from typing import Any, Generic, Required, TypedDict, cast
@ -20,12 +19,6 @@ import voluptuous as vol
from .core import HomeAssistant, callback
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 .loader import async_suggest_report_issue
from .util import uuid as uuid_util
@ -46,26 +39,6 @@ class FlowResultType(StrEnum):
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_DATA_ENTRY_FLOW_PROGRESSED = "data_entry_flow_progressed"
@ -126,6 +99,7 @@ class InvalidData(vol.Invalid):
schema_errors: dict[str, Any],
**kwargs: Any,
) -> None:
"""Initialize an invalid data exception."""
super().__init__(message, path, error_message, **kwargs)
self.schema_errors = schema_errors
@ -929,11 +903,3 @@ class section:
def __call__(self, value: Any) -> Any:
"""Validate input."""
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())

View File

@ -25,7 +25,7 @@ async def test_config_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
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"
mock_setup_entry.assert_called_once()
@ -59,12 +59,12 @@ async def test_config_flow_errors(
result["flow_id"],
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}
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
@ -77,4 +77,4 @@ async def test_config_flow_errors(
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

View File

@ -13,11 +13,7 @@ from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.util.decorator import Registry
from .common import (
async_capture_events,
help_test_all,
import_and_test_deprecated_constant_enum,
)
from .common import async_capture_events
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
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:
"""Test section with custom_serializer."""
assert cv.custom_serializer(