Deprecate hass.helpers (#114484)

* Deprecate hass.helpers

* Patch

* Patch _REPORTED_INTEGRATIONS set in test

* Fix test

* Update version
This commit is contained in:
Jan-Philipp Benecke
2024-03-31 11:44:11 +02:00
committed by GitHub
parent f2f24a5d35
commit d5da0a053b
2 changed files with 45 additions and 0 deletions

View File

@@ -1550,6 +1550,20 @@ class Helpers:
def __getattr__(self, helper_name: str) -> ModuleWrapper:
"""Fetch a helper."""
helper = importlib.import_module(f"homeassistant.helpers.{helper_name}")
# Local import to avoid circular dependencies
from .helpers.frame import report # pylint: disable=import-outside-toplevel
report(
(
f"accesses hass.helpers.{helper_name}."
" This is deprecated and will stop working in Home Assistant 2024.11, it"
f" should be updated to import functions used from {helper_name} directly"
),
error_if_core=False,
log_custom_component_only=True,
)
wrapped = ModuleWrapper(self._hass, helper)
setattr(self, helper_name, wrapped)
return wrapped