Remove deprecated (moved) helpers from helpers.__init__ (#120172)

This commit is contained in:
G Johansson 2024-06-22 20:55:03 +02:00 committed by GitHub
parent f14e8b728c
commit 5ddda14e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 109 deletions

View File

@ -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"

View File

@ -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
)