From cf371ea8dd74aecdebd38d2323ab49062a93a6e0 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 5 Dec 2021 13:53:52 +0100 Subject: [PATCH] Remove deprecated base entity classes (#61006) * Remove deprecated base entity classes * Clean up tests --- .../alarm_control_panel/__init__.py | 12 ---------- .../components/binary_sensor/__init__.py | 14 +---------- homeassistant/components/climate/__init__.py | 12 ---------- homeassistant/components/cover/__init__.py | 12 ---------- homeassistant/components/light/__init__.py | 12 ---------- homeassistant/components/lock/__init__.py | 12 ---------- .../components/media_player/__init__.py | 14 +---------- homeassistant/components/remote/__init__.py | 12 ---------- homeassistant/components/switch/__init__.py | 12 ---------- homeassistant/components/vacuum/__init__.py | 23 ------------------- .../components/water_heater/__init__.py | 12 ---------- .../alarm_control_panel/test_init.py | 13 ----------- tests/components/binary_sensor/test_init.py | 10 -------- tests/components/climate/test_init.py | 19 --------------- tests/components/cover/test_init.py | 10 -------- tests/components/light/test_init.py | 10 -------- tests/components/lock/test_init.py | 12 ---------- tests/components/media_player/test_init.py | 10 -------- tests/components/remote/test_init.py | 10 -------- tests/components/switch/test_init.py | 10 -------- tests/components/vacuum/test_init.py | 18 --------------- tests/components/water_heater/test_init.py | 12 ---------- 22 files changed, 2 insertions(+), 279 deletions(-) delete mode 100644 tests/components/alarm_control_panel/test_init.py delete mode 100644 tests/components/lock/test_init.py delete mode 100644 tests/components/vacuum/test_init.py delete mode 100644 tests/components/water_heater/test_init.py diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index 50317e97f2b..082327fdec8 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -217,15 +217,3 @@ class AlarmControlPanelEntity(Entity): ATTR_CHANGED_BY: self.changed_by, ATTR_CODE_ARM_REQUIRED: self.code_arm_required, } - - -class AlarmControlPanel(AlarmControlPanelEntity): - """An abstract class for alarm control entities (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs: Any) -> None: - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) # type: ignore[call-arg] - _LOGGER.warning( - "AlarmControlPanel is deprecated, modify %s to extend AlarmControlPanelEntity", - cls.__name__, - ) diff --git a/homeassistant/components/binary_sensor/__init__.py b/homeassistant/components/binary_sensor/__init__.py index 0604d5da586..e3c6ed707e2 100644 --- a/homeassistant/components/binary_sensor/__init__.py +++ b/homeassistant/components/binary_sensor/__init__.py @@ -4,7 +4,7 @@ from __future__ import annotations from dataclasses import dataclass from datetime import timedelta import logging -from typing import Any, final +from typing import final import voluptuous as vol @@ -203,15 +203,3 @@ class BinarySensorEntity(Entity): def state(self) -> StateType: """Return the state of the binary sensor.""" return STATE_ON if self.is_on else STATE_OFF - - -class BinarySensorDevice(BinarySensorEntity): - """Represent a binary sensor (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs: Any): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) # type: ignore[call-arg] - _LOGGER.warning( - "BinarySensorDevice is deprecated, modify %s to extend BinarySensorEntity", - cls.__name__, - ) diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index 98e37237792..ae1c434d342 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -584,15 +584,3 @@ async def async_service_temperature_set( kwargs[value] = temp await entity.async_set_temperature(**kwargs) - - -class ClimateDevice(ClimateEntity): - """Representation of a climate entity (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "ClimateDevice is deprecated, modify %s to extend ClimateEntity", - cls.__name__, - ) diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index e654cf1a0d0..506a93461fe 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -403,15 +403,3 @@ class CoverEntity(Entity): if self._cover_is_last_toggle_direction_open: return fns["close"] return fns["open"] - - -class CoverDevice(CoverEntity): - """Representation of a cover (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "CoverDevice is deprecated, modify %s to extend CoverEntity", - cls.__name__, - ) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index dcf4972706a..390c675886d 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -958,18 +958,6 @@ class LightEntity(ToggleEntity): return self._attr_supported_features -class Light(LightEntity): - """Representation of a light (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "Light is deprecated, modify %s to extend LightEntity", - cls.__name__, - ) - - def legacy_supported_features( supported_features: int, supported_color_modes: list[str] | None ) -> int: diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index 1f2e87fc864..60c7c91152f 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -179,15 +179,3 @@ class LockEntity(Entity): if (locked := self.is_locked) is None: return None return STATE_LOCKED if locked else STATE_UNLOCKED - - -class LockDevice(LockEntity): - """Representation of a lock (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs: Any): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) # type: ignore[call-arg] - _LOGGER.warning( - "LockDevice is deprecated, modify %s to extend LockEntity", - cls.__name__, - ) diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index d1d51f525e4..443225e70a6 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -1147,7 +1147,7 @@ async def websocket_browse_media(hass, connection, msg): To use, media_player integrations can implement MediaPlayerEntity.async_browse_media() """ component = hass.data[DOMAIN] - player: MediaPlayerDevice | None = component.get_entity(msg["entity_id"]) + player: MediaPlayerEntity | None = component.get_entity(msg["entity_id"]) if player is None: connection.send_error(msg["id"], "entity_not_found", "Entity not found") @@ -1195,18 +1195,6 @@ async def websocket_browse_media(hass, connection, msg): connection.send_result(msg["id"], payload) -class MediaPlayerDevice(MediaPlayerEntity): - """ABC for media player devices (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "MediaPlayerDevice is deprecated, modify %s to extend MediaPlayerEntity", - cls.__name__, - ) - - class BrowseMedia: """Represent a browsable media file.""" diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index e67a4eda9a9..8b06827f0d9 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -210,15 +210,3 @@ class RemoteEntity(ToggleEntity): await self.hass.async_add_executor_job( ft.partial(self.delete_command, **kwargs) ) - - -class RemoteDevice(RemoteEntity): - """Representation of a remote (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "RemoteDevice is deprecated, modify %s to extend RemoteEntity", - cls.__name__, - ) diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index ac29e99bb73..157a5cd40c7 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -140,15 +140,3 @@ class SwitchEntity(ToggleEntity): data[attr] = value return data - - -class SwitchDevice(SwitchEntity): - """Representation of a switch (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs: Any) -> None: - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) # type: ignore[call-arg] - _LOGGER.warning( - "SwitchDevice is deprecated, modify %s to extend SwitchEntity", - cls.__name__, - ) diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py index db186a464fa..fde36871185 100644 --- a/homeassistant/components/vacuum/__init__.py +++ b/homeassistant/components/vacuum/__init__.py @@ -341,17 +341,6 @@ class VacuumEntity(_BaseVacuum, ToggleEntity): """Not supported.""" -class VacuumDevice(VacuumEntity): - """Representation of a vacuum (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "VacuumDevice is deprecated, modify %s to extend VacuumEntity", cls.__name__ - ) - - @dataclass class StateVacuumEntityDescription(EntityDescription): """A class that describes vacuum entities.""" @@ -406,15 +395,3 @@ class StateVacuumEntity(_BaseVacuum): async def async_toggle(self, **kwargs): """Not supported.""" - - -class StateVacuumDevice(StateVacuumEntity): - """Representation of a vacuum (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "StateVacuumDevice is deprecated, modify %s to extend StateVacuumEntity", - cls.__name__, - ) diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index 85d6a791d7f..0a9174fa6ea 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -350,15 +350,3 @@ async def async_service_temperature_set(entity, service): kwargs[value] = temp await entity.async_set_temperature(**kwargs) - - -class WaterHeaterDevice(WaterHeaterEntity): - """Representation of a water heater (for backwards compatibility).""" - - def __init_subclass__(cls, **kwargs): - """Print deprecation warning.""" - super().__init_subclass__(**kwargs) - _LOGGER.warning( - "WaterHeaterDevice is deprecated, modify %s to extend WaterHeaterEntity", - cls.__name__, - ) diff --git a/tests/components/alarm_control_panel/test_init.py b/tests/components/alarm_control_panel/test_init.py deleted file mode 100644 index 257d764468a..00000000000 --- a/tests/components/alarm_control_panel/test_init.py +++ /dev/null @@ -1,13 +0,0 @@ -"""Tests for Alarm control panel.""" -from homeassistant.components import alarm_control_panel - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomAlarm(alarm_control_panel.AlarmControlPanel): - def supported_features(self): - pass - - CustomAlarm() - assert "AlarmControlPanel is deprecated, modify CustomAlarm" in caplog.text diff --git a/tests/components/binary_sensor/test_init.py b/tests/components/binary_sensor/test_init.py index 0c574df1569..18b42136ea2 100644 --- a/tests/components/binary_sensor/test_init.py +++ b/tests/components/binary_sensor/test_init.py @@ -19,13 +19,3 @@ def test_state(): new=True, ): assert binary_sensor.BinarySensorEntity().state == STATE_ON - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomBinarySensor(binary_sensor.BinarySensorDevice): - pass - - CustomBinarySensor() - assert "BinarySensorDevice is deprecated, modify CustomBinarySensor" in caplog.text diff --git a/tests/components/climate/test_init.py b/tests/components/climate/test_init.py index 9473e61a165..1109704e1c4 100644 --- a/tests/components/climate/test_init.py +++ b/tests/components/climate/test_init.py @@ -10,7 +10,6 @@ from homeassistant.components.climate import ( HVAC_MODE_HEAT, HVAC_MODE_OFF, SET_TEMPERATURE_SCHEMA, - ClimateDevice, ClimateEntity, ) @@ -93,21 +92,3 @@ async def test_sync_turn_off(hass): await climate.async_turn_off() assert climate.turn_off.called - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomClimate(ClimateDevice): - """Custom climate entity class.""" - - @property - def hvac_mode(self): - pass - - @property - def hvac_modes(self): - pass - - CustomClimate() - assert "ClimateDevice is deprecated, modify CustomClimate" in caplog.text diff --git a/tests/components/cover/test_init.py b/tests/components/cover/test_init.py index b46c0417cd2..95d3053d03b 100644 --- a/tests/components/cover/test_init.py +++ b/tests/components/cover/test_init.py @@ -111,13 +111,3 @@ def is_closed(hass, ent): def is_closing(hass, ent): """Return if the cover is closed based on the statemachine.""" return hass.states.is_state(ent.entity_id, STATE_CLOSING) - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomCover(cover.CoverDevice): - pass - - CustomCover() - assert "CoverDevice is deprecated, modify CustomCover" in caplog.text diff --git a/tests/components/light/test_init.py b/tests/components/light/test_init.py index d51a5b64861..1f7fe431f0e 100644 --- a/tests/components/light/test_init.py +++ b/tests/components/light/test_init.py @@ -898,16 +898,6 @@ async def test_light_brightness_pct_conversion(hass, enable_custom_integrations) assert data["brightness"] == 255 -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomLight(light.Light): - pass - - CustomLight() - assert "Light is deprecated, modify CustomLight" in caplog.text - - async def test_profiles(hass): """Test profiles loading.""" profiles = orig_Profiles(hass) diff --git a/tests/components/lock/test_init.py b/tests/components/lock/test_init.py deleted file mode 100644 index a788b9fa917..00000000000 --- a/tests/components/lock/test_init.py +++ /dev/null @@ -1,12 +0,0 @@ -"""The tests for Lock.""" -from homeassistant.components import lock - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomLock(lock.LockDevice): - pass - - CustomLock() - assert "LockDevice is deprecated, modify CustomLock" in caplog.text diff --git a/tests/components/media_player/test_init.py b/tests/components/media_player/test_init.py index 7bdf3722d5d..caa562fc5a0 100644 --- a/tests/components/media_player/test_init.py +++ b/tests/components/media_player/test_init.py @@ -119,16 +119,6 @@ async def test_get_async_get_browse_image(hass, hass_client_no_auth, hass_ws_cli assert content == b"image" -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomMediaPlayer(media_player.MediaPlayerDevice): - pass - - CustomMediaPlayer() - assert "MediaPlayerDevice is deprecated, modify CustomMediaPlayer" in caplog.text - - async def test_media_browse(hass, hass_ws_client): """Test browsing media.""" await async_setup_component( diff --git a/tests/components/remote/test_init.py b/tests/components/remote/test_init.py index 2c2005a7fee..024990ee000 100644 --- a/tests/components/remote/test_init.py +++ b/tests/components/remote/test_init.py @@ -139,13 +139,3 @@ async def test_delete_command(hass): assert call.domain == remote.DOMAIN assert call.service == SERVICE_DELETE_COMMAND assert call.data[ATTR_ENTITY_ID] == ENTITY_ID - - -async def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomRemote(remote.RemoteDevice): - pass - - CustomRemote() - assert "RemoteDevice is deprecated, modify CustomRemote" in caplog.text diff --git a/tests/components/switch/test_init.py b/tests/components/switch/test_init.py index 44302ec311b..ed3d3c59da9 100644 --- a/tests/components/switch/test_init.py +++ b/tests/components/switch/test_init.py @@ -72,13 +72,3 @@ async def test_switch_context( assert state2 is not None assert state.state != state2.state assert state2.context.user_id == hass_admin_user.id - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomSwitch(switch.SwitchDevice): - pass - - CustomSwitch() - assert "SwitchDevice is deprecated, modify CustomSwitch" in caplog.text diff --git a/tests/components/vacuum/test_init.py b/tests/components/vacuum/test_init.py deleted file mode 100644 index 9075b385f40..00000000000 --- a/tests/components/vacuum/test_init.py +++ /dev/null @@ -1,18 +0,0 @@ -"""The tests for Vacuum.""" -from homeassistant.components import vacuum - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomVacuum(vacuum.VacuumDevice): - pass - - class CustomStateVacuum(vacuum.StateVacuumDevice): - pass - - CustomVacuum() - assert "VacuumDevice is deprecated, modify CustomVacuum" in caplog.text - - CustomStateVacuum() - assert "StateVacuumDevice is deprecated, modify CustomStateVacuum" in caplog.text diff --git a/tests/components/water_heater/test_init.py b/tests/components/water_heater/test_init.py deleted file mode 100644 index 967e8b03620..00000000000 --- a/tests/components/water_heater/test_init.py +++ /dev/null @@ -1,12 +0,0 @@ -"""Tests for Water heater.""" -from homeassistant.components import water_heater - - -def test_deprecated_base_class(caplog): - """Test deprecated base class.""" - - class CustomWaterHeater(water_heater.WaterHeaterDevice): - pass - - CustomWaterHeater() - assert "WaterHeaterDevice is deprecated, modify CustomWaterHeater" in caplog.text