From 28ec8272ee4b1a6d0c74e49be089ff6a2c4e42ef Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Thu, 28 Nov 2024 11:05:45 +0100 Subject: [PATCH] Remove deprecated camera constants (#131796) --- homeassistant/components/camera/__init__.py | 14 +-------- homeassistant/components/camera/const.py | 21 ------------- tests/components/camera/test_init.py | 35 +-------------------- 3 files changed, 2 insertions(+), 68 deletions(-) diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 781388f12d6..4d718433fca 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -67,9 +67,7 @@ from homeassistant.helpers.template import Template from homeassistant.helpers.typing import ConfigType, VolDictType from homeassistant.loader import bind_hass -from .const import ( # noqa: F401 - _DEPRECATED_STREAM_TYPE_HLS, - _DEPRECATED_STREAM_TYPE_WEB_RTC, +from .const import ( CAMERA_IMAGE_TIMEOUT, CAMERA_STREAM_SOURCE_TIMEOUT, CONF_DURATION, @@ -135,16 +133,6 @@ class CameraEntityFeature(IntFlag): STREAM = 2 -# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5. -# Pleease use the CameraEntityFeature enum instead. -_DEPRECATED_SUPPORT_ON_OFF: Final = DeprecatedConstantEnum( - CameraEntityFeature.ON_OFF, "2025.1" -) -_DEPRECATED_SUPPORT_STREAM: Final = DeprecatedConstantEnum( - CameraEntityFeature.STREAM, "2025.1" -) - - DEFAULT_CONTENT_TYPE: Final = "image/jpeg" ENTITY_IMAGE_URL: Final = "/api/camera_proxy/{0}?token={1}" diff --git a/homeassistant/components/camera/const.py b/homeassistant/components/camera/const.py index 7e4633d410a..65862e66dab 100644 --- a/homeassistant/components/camera/const.py +++ b/homeassistant/components/camera/const.py @@ -3,15 +3,8 @@ from __future__ import annotations from enum import StrEnum -from functools import partial from typing import TYPE_CHECKING, Final -from homeassistant.helpers.deprecation import ( - DeprecatedConstantEnum, - all_with_deprecated_constants, - check_if_deprecated_constant, - dir_with_deprecated_constants, -) from homeassistant.util.hass_dict import HassKey if TYPE_CHECKING: @@ -58,17 +51,3 @@ class StreamType(StrEnum): HLS = "hls" WEB_RTC = "web_rtc" - - -# These constants are deprecated as of Home Assistant 2022.5 -# Please use the StreamType enum instead. -_DEPRECATED_STREAM_TYPE_HLS = DeprecatedConstantEnum(StreamType.HLS, "2025.1") -_DEPRECATED_STREAM_TYPE_WEB_RTC = DeprecatedConstantEnum(StreamType.WEB_RTC, "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()) diff --git a/tests/components/camera/test_init.py b/tests/components/camera/test_init.py index f9d30c240db..32520fcad23 100644 --- a/tests/components/camera/test_init.py +++ b/tests/components/camera/test_init.py @@ -802,32 +802,13 @@ async def test_use_stream_for_stills( @pytest.mark.parametrize( "module", - [camera, camera.const], + [camera], ) def test_all(module: ModuleType) -> None: """Test module.__all__ is correctly set.""" help_test_all(module) -@pytest.mark.parametrize( - "enum", - list(camera.const.StreamType), -) -@pytest.mark.parametrize( - "module", - [camera, camera.const], -) -def test_deprecated_stream_type_constants( - caplog: pytest.LogCaptureFixture, - enum: camera.const.StreamType, - module: ModuleType, -) -> None: - """Test deprecated stream type constants.""" - import_and_test_deprecated_constant_enum( - caplog, module, enum, "STREAM_TYPE_", "2025.1" - ) - - @pytest.mark.parametrize( "enum", list(camera.const.CameraState), @@ -845,20 +826,6 @@ def test_deprecated_state_constants( import_and_test_deprecated_constant_enum(caplog, module, enum, "STATE_", "2025.10") -@pytest.mark.parametrize( - "entity_feature", - list(camera.CameraEntityFeature), -) -def test_deprecated_support_constants( - caplog: pytest.LogCaptureFixture, - entity_feature: camera.CameraEntityFeature, -) -> None: - """Test deprecated support constants.""" - import_and_test_deprecated_constant_enum( - caplog, camera, entity_feature, "SUPPORT_", "2025.1" - ) - - def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None: """Test deprecated supported features ints."""