Remove deprecated device registry constants (#131802)

This commit is contained in:
Robert Resch 2024-11-28 11:20:44 +01:00 committed by GitHub
parent b28f352902
commit fd14add67b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 46 deletions

View File

@ -6,7 +6,7 @@ from collections import defaultdict
from collections.abc import Mapping from collections.abc import Mapping
from datetime import datetime from datetime import datetime
from enum import StrEnum from enum import StrEnum
from functools import lru_cache, partial from functools import lru_cache
import logging import logging
import time import time
from typing import TYPE_CHECKING, Any, Literal, TypedDict from typing import TYPE_CHECKING, Any, Literal, TypedDict
@ -32,12 +32,6 @@ import homeassistant.util.uuid as uuid_util
from . import storage, translation from . import storage, translation
from .debounce import Debouncer from .debounce import Debouncer
from .deprecation import (
DeprecatedConstantEnum,
all_with_deprecated_constants,
check_if_deprecated_constant,
dir_with_deprecated_constants,
)
from .frame import ReportBehavior, report_usage from .frame import ReportBehavior, report_usage
from .json import JSON_DUMP, find_paths_unserializable_data, json_bytes, json_fragment from .json import JSON_DUMP, find_paths_unserializable_data, json_bytes, json_fragment
from .registry import BaseRegistry, BaseRegistryItems, RegistryIndexType from .registry import BaseRegistry, BaseRegistryItems, RegistryIndexType
@ -86,16 +80,6 @@ class DeviceEntryDisabler(StrEnum):
USER = "user" USER = "user"
# DISABLED_* are deprecated, to be removed in 2022.3
_DEPRECATED_DISABLED_CONFIG_ENTRY = DeprecatedConstantEnum(
DeviceEntryDisabler.CONFIG_ENTRY, "2025.1"
)
_DEPRECATED_DISABLED_INTEGRATION = DeprecatedConstantEnum(
DeviceEntryDisabler.INTEGRATION, "2025.1"
)
_DEPRECATED_DISABLED_USER = DeprecatedConstantEnum(DeviceEntryDisabler.USER, "2025.1")
class DeviceInfo(TypedDict, total=False): class DeviceInfo(TypedDict, total=False):
"""Entity device information for device registry.""" """Entity device information for device registry."""
@ -1480,11 +1464,3 @@ def _normalize_connections(connections: set[tuple[str, str]]) -> set[tuple[str,
(key, format_mac(value)) if key == CONNECTION_NETWORK_MAC else (key, value) (key, format_mac(value)) if key == CONNECTION_NETWORK_MAC else (key, value)
for key, value in connections for key, value in connections
} }
# 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

@ -23,13 +23,7 @@ from homeassistant.helpers import (
) )
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from tests.common import ( from tests.common import MockConfigEntry, async_capture_events, flush_store
MockConfigEntry,
async_capture_events,
flush_store,
help_test_all,
import_and_test_deprecated_constant_enum,
)
@pytest.fixture @pytest.fixture
@ -2904,20 +2898,6 @@ async def test_loading_invalid_configuration_url_from_storage(
assert entry.configuration_url == "invalid" assert entry.configuration_url == "invalid"
def test_all() -> None:
"""Test module.__all__ is correctly set."""
help_test_all(dr)
@pytest.mark.parametrize(("enum"), list(dr.DeviceEntryDisabler))
def test_deprecated_constants(
caplog: pytest.LogCaptureFixture,
enum: dr.DeviceEntryDisabler,
) -> None:
"""Test deprecated constants."""
import_and_test_deprecated_constant_enum(caplog, dr, enum, "DISABLED_", "2025.1")
async def test_removing_labels( async def test_removing_labels(
hass: HomeAssistant, device_registry: dr.DeviceRegistry hass: HomeAssistant, device_registry: dr.DeviceRegistry
) -> None: ) -> None: