mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Deprecate deprecated device_registry helper constants (#106227)
This commit is contained in:
parent
23fa86cc23
commit
e18d2b8873
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
from collections import UserDict
|
from collections import UserDict
|
||||||
from collections.abc import Coroutine, ValuesView
|
from collections.abc import Coroutine, ValuesView
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from typing import TYPE_CHECKING, Any, Literal, TypedDict, TypeVar, cast
|
from typing import TYPE_CHECKING, Any, Literal, TypedDict, TypeVar, cast
|
||||||
@ -21,6 +22,11 @@ import homeassistant.util.uuid as uuid_util
|
|||||||
|
|
||||||
from . import storage
|
from . import storage
|
||||||
from .debounce import Debouncer
|
from .debounce import Debouncer
|
||||||
|
from .deprecation import (
|
||||||
|
DeprecatedConstantEnum,
|
||||||
|
check_if_deprecated_constant,
|
||||||
|
dir_with_deprecated_constants,
|
||||||
|
)
|
||||||
from .frame import report
|
from .frame import report
|
||||||
from .json import JSON_DUMP, find_paths_unserializable_data
|
from .json import JSON_DUMP, find_paths_unserializable_data
|
||||||
from .typing import UNDEFINED, UndefinedType
|
from .typing import UNDEFINED, UndefinedType
|
||||||
@ -61,9 +67,17 @@ class DeviceEntryDisabler(StrEnum):
|
|||||||
|
|
||||||
|
|
||||||
# DISABLED_* are deprecated, to be removed in 2022.3
|
# DISABLED_* are deprecated, to be removed in 2022.3
|
||||||
DISABLED_CONFIG_ENTRY = DeviceEntryDisabler.CONFIG_ENTRY.value
|
_DEPRECATED_DISABLED_CONFIG_ENTRY = DeprecatedConstantEnum(
|
||||||
DISABLED_INTEGRATION = DeviceEntryDisabler.INTEGRATION.value
|
DeviceEntryDisabler.CONFIG_ENTRY, "2025.1"
|
||||||
DISABLED_USER = DeviceEntryDisabler.USER.value
|
)
|
||||||
|
_DEPRECATED_DISABLED_INTEGRATION = DeprecatedConstantEnum(
|
||||||
|
DeviceEntryDisabler.INTEGRATION, "2025.1"
|
||||||
|
)
|
||||||
|
_DEPRECATED_DISABLED_USER = DeprecatedConstantEnum(DeviceEntryDisabler.USER, "2025.1")
|
||||||
|
|
||||||
|
# Both 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=globals())
|
||||||
|
|
||||||
|
|
||||||
class DeviceInfo(TypedDict, total=False):
|
class DeviceInfo(TypedDict, total=False):
|
||||||
|
@ -17,7 +17,11 @@ from homeassistant.helpers import (
|
|||||||
entity_registry as er,
|
entity_registry as er,
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, flush_store
|
from tests.common import (
|
||||||
|
MockConfigEntry,
|
||||||
|
flush_store,
|
||||||
|
import_and_test_deprecated_constant_enum,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -2012,3 +2016,12 @@ async def test_loading_invalid_configuration_url_from_storage(
|
|||||||
identifiers={("serial", "123456ABCDEF")},
|
identifiers={("serial", "123456ABCDEF")},
|
||||||
)
|
)
|
||||||
assert entry.configuration_url == "invalid"
|
assert entry.configuration_url == "invalid"
|
||||||
|
|
||||||
|
|
||||||
|
@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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user