Skip to content

Commit

Permalink
Remove deprecated fan constants (home-assistant#131845)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus authored Nov 28, 2024
1 parent 57b099c commit 0c5c093
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 49 deletions.
29 changes: 0 additions & 29 deletions homeassistant/components/fan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.deprecation import (
DeprecatedConstantEnum,
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.entity_platform import EntityPlatform
Expand Down Expand Up @@ -61,21 +55,6 @@ class FanEntityFeature(IntFlag):
TURN_ON = 32


# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
# Please use the FanEntityFeature enum instead.
_DEPRECATED_SUPPORT_SET_SPEED = DeprecatedConstantEnum(
FanEntityFeature.SET_SPEED, "2025.1"
)
_DEPRECATED_SUPPORT_OSCILLATE = DeprecatedConstantEnum(
FanEntityFeature.OSCILLATE, "2025.1"
)
_DEPRECATED_SUPPORT_DIRECTION = DeprecatedConstantEnum(
FanEntityFeature.DIRECTION, "2025.1"
)
_DEPRECATED_SUPPORT_PRESET_MODE = DeprecatedConstantEnum(
FanEntityFeature.PRESET_MODE, "2025.1"
)

SERVICE_INCREASE_SPEED = "increase_speed"
SERVICE_DECREASE_SPEED = "decrease_speed"
SERVICE_OSCILLATE = "oscillate"
Expand Down Expand Up @@ -543,11 +522,3 @@ def preset_modes(self) -> list[str] | None:
Requires FanEntityFeature.SET_SPEED.
"""
return self._attr_preset_modes


# These can be removed if no deprecated constant are in this module anymore
__getattr__ = ft.partial(check_if_deprecated_constant, module_globals=globals())
__dir__ = ft.partial(
dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
)
__all__ = all_with_deprecated_constants(globals())
20 changes: 0 additions & 20 deletions tests/components/fan/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest

from homeassistant.components import fan
from homeassistant.components.fan import (
ATTR_PRESET_MODE,
ATTR_PRESET_MODES,
Expand All @@ -27,8 +26,6 @@
MockConfigEntry,
MockModule,
MockPlatform,
help_test_all,
import_and_test_deprecated_constant_enum,
mock_integration,
mock_platform,
setup_test_component_platform,
Expand Down Expand Up @@ -166,23 +163,6 @@ async def test_preset_mode_validation(
assert exc.value.translation_key == "not_valid_preset_mode"


def test_all() -> None:
"""Test module.__all__ is correctly set."""
help_test_all(fan)


@pytest.mark.parametrize(("enum"), list(fan.FanEntityFeature))
def test_deprecated_constants(
caplog: pytest.LogCaptureFixture,
enum: fan.FanEntityFeature,
) -> None:
"""Test deprecated constants."""
if not FanEntityFeature.TURN_OFF and not FanEntityFeature.TURN_ON:
import_and_test_deprecated_constant_enum(
caplog, fan, enum, "SUPPORT_", "2025.1"
)


def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
"""Test deprecated supported features ints."""

Expand Down

0 comments on commit 0c5c093

Please sign in to comment.