mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Remove deprecated siren constants (#131807)
This commit is contained in:
parent
4d27a32905
commit
3e0326dd66
@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import Any, TypedDict, cast, final
|
||||
|
||||
@ -14,22 +13,12 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import SERVICE_TOGGLE, SERVICE_TURN_OFF, SERVICE_TURN_ON
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.deprecation import (
|
||||
all_with_deprecated_constants,
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.typing import ConfigType, VolDictType
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .const import ( # noqa: F401
|
||||
_DEPRECATED_SUPPORT_DURATION,
|
||||
_DEPRECATED_SUPPORT_TONES,
|
||||
_DEPRECATED_SUPPORT_TURN_OFF,
|
||||
_DEPRECATED_SUPPORT_TURN_ON,
|
||||
_DEPRECATED_SUPPORT_VOLUME_SET,
|
||||
from .const import (
|
||||
ATTR_AVAILABLE_TONES,
|
||||
ATTR_DURATION,
|
||||
ATTR_TONE,
|
||||
@ -208,13 +197,3 @@ class SirenEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
self._report_deprecated_supported_features_values(new_features)
|
||||
return new_features
|
||||
return features
|
||||
|
||||
|
||||
# As we import deprecated constants from the const module, we need to add these two functions
|
||||
# otherwise this module will be logged for using deprecated constants and not the custom component
|
||||
# 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())
|
||||
|
@ -1,16 +1,8 @@
|
||||
"""Constants for the siren component."""
|
||||
|
||||
from enum import IntFlag
|
||||
from functools import partial
|
||||
from typing import Final
|
||||
|
||||
from homeassistant.helpers.deprecation import (
|
||||
DeprecatedConstantEnum,
|
||||
all_with_deprecated_constants,
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
|
||||
DOMAIN: Final = "siren"
|
||||
|
||||
ATTR_TONE: Final = "tone"
|
||||
@ -28,29 +20,3 @@ class SirenEntityFeature(IntFlag):
|
||||
TONES = 4
|
||||
VOLUME_SET = 8
|
||||
DURATION = 16
|
||||
|
||||
|
||||
# These constants are deprecated as of Home Assistant 2022.5
|
||||
# Please use the SirenEntityFeature enum instead.
|
||||
_DEPRECATED_SUPPORT_TURN_ON: Final = DeprecatedConstantEnum(
|
||||
SirenEntityFeature.TURN_ON, "2025.1"
|
||||
)
|
||||
_DEPRECATED_SUPPORT_TURN_OFF: Final = DeprecatedConstantEnum(
|
||||
SirenEntityFeature.TURN_OFF, "2025.1"
|
||||
)
|
||||
_DEPRECATED_SUPPORT_TONES: Final = DeprecatedConstantEnum(
|
||||
SirenEntityFeature.TONES, "2025.1"
|
||||
)
|
||||
_DEPRECATED_SUPPORT_VOLUME_SET: Final = DeprecatedConstantEnum(
|
||||
SirenEntityFeature.VOLUME_SET, "2025.1"
|
||||
)
|
||||
_DEPRECATED_SUPPORT_DURATION: Final = DeprecatedConstantEnum(
|
||||
SirenEntityFeature.DURATION, "2025.1"
|
||||
)
|
||||
|
||||
# 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())
|
||||
|
@ -1,6 +1,5 @@
|
||||
"""The tests for the siren component."""
|
||||
|
||||
from types import ModuleType
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
@ -14,8 +13,6 @@ from homeassistant.components.siren import (
|
||||
from homeassistant.components.siren.const import SirenEntityFeature
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import help_test_all, import_and_test_deprecated_constant_enum
|
||||
|
||||
|
||||
class MockSirenEntity(SirenEntity):
|
||||
"""Mock siren device to use in tests."""
|
||||
@ -111,26 +108,6 @@ async def test_missing_tones_dict(hass: HomeAssistant) -> None:
|
||||
process_turn_on_params(siren, {"tone": 3})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"module",
|
||||
[siren, siren.const],
|
||||
)
|
||||
def test_all(module: ModuleType) -> None:
|
||||
"""Test module.__all__ is correctly set."""
|
||||
help_test_all(module)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("enum"), list(SirenEntityFeature))
|
||||
@pytest.mark.parametrize(("module"), [siren, siren.const])
|
||||
def test_deprecated_constants(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
enum: SirenEntityFeature,
|
||||
module: ModuleType,
|
||||
) -> None:
|
||||
"""Test deprecated constants."""
|
||||
import_and_test_deprecated_constant_enum(caplog, module, enum, "SUPPORT_", "2025.1")
|
||||
|
||||
|
||||
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test deprecated supported features ints."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user