From 5ddda14e5963c92e5d5ce7970aee7742c644eac7 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sat, 22 Jun 2024 20:55:03 +0200 Subject: [PATCH] Remove deprecated (moved) helpers from helpers.__init__ (#120172) --- homeassistant/helpers/__init__.py | 59 ------------------------------- tests/helpers/test_init.py | 50 -------------------------- 2 files changed, 109 deletions(-) delete mode 100644 tests/helpers/test_init.py diff --git a/homeassistant/helpers/__init__.py b/homeassistant/helpers/__init__.py index 9f72445822e..abb9bc79dc8 100644 --- a/homeassistant/helpers/__init__.py +++ b/homeassistant/helpers/__init__.py @@ -1,60 +1 @@ """Helper methods for components within Home Assistant.""" - -from __future__ import annotations - -from collections.abc import Iterable, Sequence -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from .typing import ConfigType - - -def config_per_platform( - config: ConfigType, domain: str -) -> Iterable[tuple[str | None, ConfigType]]: - """Break a component config into different platforms. - - For example, will find 'switch', 'switch 2', 'switch 3', .. etc - Async friendly. - """ - # pylint: disable-next=import-outside-toplevel - from homeassistant import config as ha_config - - # pylint: disable-next=import-outside-toplevel - from .deprecation import _print_deprecation_warning - - _print_deprecation_warning( - config_per_platform, - "config.config_per_platform", - "function", - "called", - "2024.6", - ) - return ha_config.config_per_platform(config, domain) - - -config_per_platform.__name__ = "helpers.config_per_platform" - - -def extract_domain_configs(config: ConfigType, domain: str) -> Sequence[str]: - """Extract keys from config for given domain name. - - Async friendly. - """ - # pylint: disable-next=import-outside-toplevel - from homeassistant import config as ha_config - - # pylint: disable-next=import-outside-toplevel - from .deprecation import _print_deprecation_warning - - _print_deprecation_warning( - extract_domain_configs, - "config.extract_domain_configs", - "function", - "called", - "2024.6", - ) - return ha_config.extract_domain_configs(config, domain) - - -extract_domain_configs.__name__ = "helpers.extract_domain_configs" diff --git a/tests/helpers/test_init.py b/tests/helpers/test_init.py deleted file mode 100644 index 39b387000ca..00000000000 --- a/tests/helpers/test_init.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Test component helpers.""" - -from collections import OrderedDict - -import pytest - -from homeassistant import helpers - - -def test_extract_domain_configs(caplog: pytest.LogCaptureFixture) -> None: - """Test the extraction of domain configuration.""" - config = { - "zone": None, - "zoner": None, - "zone ": None, - "zone Hallo": None, - "zone 100": None, - } - - assert {"zone", "zone Hallo", "zone 100"} == set( - helpers.extract_domain_configs(config, "zone") - ) - - assert ( - "helpers.extract_domain_configs is a deprecated function which will be removed " - "in HA Core 2024.6. Use config.extract_domain_configs instead" in caplog.text - ) - - -def test_config_per_platform(caplog: pytest.LogCaptureFixture) -> None: - """Test config per platform method.""" - config = OrderedDict( - [ - ("zone", {"platform": "hello"}), - ("zoner", None), - ("zone Hallo", [1, {"platform": "hello 2"}]), - ("zone 100", None), - ] - ) - - assert [ - ("hello", config["zone"]), - (None, 1), - ("hello 2", config["zone Hallo"][1]), - ] == list(helpers.config_per_platform(config, "zone")) - - assert ( - "helpers.config_per_platform is a deprecated function which will be removed " - "in HA Core 2024.6. Use config.config_per_platform instead" in caplog.text - )