Only apply OptionsFlowWithConfigEntry deprecation to core (#130054)

* Only apply OptionsFlowWithConfigEntry deprecation to core

* Fix match string in pytest.raises

* Improve coverage
This commit is contained in:
epenet
2024-11-08 15:55:19 +01:00
committed by GitHub
parent 6b90d8ff1a
commit 353ccf3ea7
2 changed files with 38 additions and 14 deletions

View File

@ -63,7 +63,7 @@ from .helpers.event import (
RANDOM_MICROSECOND_MIN,
async_call_later,
)
from .helpers.frame import report
from .helpers.frame import ReportBehavior, report, report_usage
from .helpers.json import json_bytes, json_bytes_sorted, json_fragment
from .helpers.typing import UNDEFINED, ConfigType, DiscoveryInfoType, UndefinedType
from .loader import async_suggest_report_issue
@ -3168,17 +3168,21 @@ class OptionsFlow(ConfigEntryBaseFlow):
class OptionsFlowWithConfigEntry(OptionsFlow):
"""Base class for options flows with config entry and options."""
"""Base class for options flows with config entry and options.
This class is being phased out, and should not be referenced in new code.
It is kept only for backward compatibility, and only for custom integrations.
"""
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self._config_entry = config_entry
self._options = deepcopy(dict(config_entry.options))
report(
"inherits from OptionsFlowWithConfigEntry, which is deprecated "
"and will stop working in 2025.12",
error_if_integration=False,
error_if_core=True,
report_usage(
"inherits from OptionsFlowWithConfigEntry",
core_behavior=ReportBehavior.ERROR,
core_integration_behavior=ReportBehavior.ERROR,
custom_integration_behavior=ReportBehavior.IGNORE,
)
@property