From 1de4d0efda1fdf0c66f96be4f984769210a93d7c Mon Sep 17 00:00:00 2001 From: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:04:48 +0100 Subject: [PATCH] Fix deprecated enums (#134824) --- homeassistant/helpers/deprecation.py | 6 +++--- tests/helpers/test_deprecation.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/helpers/deprecation.py b/homeassistant/helpers/deprecation.py index 81f7821ec79..f02c6507d02 100644 --- a/homeassistant/helpers/deprecation.py +++ b/homeassistant/helpers/deprecation.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Callable from contextlib import suppress -from enum import Enum, EnumType, _EnumDict +from enum import EnumType, IntEnum, IntFlag, StrEnum, _EnumDict import functools import inspect import logging @@ -255,7 +255,7 @@ class DeprecatedConstant(NamedTuple): class DeprecatedConstantEnum(NamedTuple): """Deprecated constant.""" - enum: Enum + enum: StrEnum | IntEnum | IntFlag breaks_in_ha_version: str | None @@ -306,7 +306,7 @@ def check_if_deprecated_constant(name: str, module_globals: dict[str, Any]) -> A replacement = deprecated_const.replacement breaks_in_ha_version = deprecated_const.breaks_in_ha_version elif isinstance(deprecated_const, DeprecatedConstantEnum): - value = deprecated_const.enum.value + value = deprecated_const.enum replacement = ( f"{deprecated_const.enum.__class__.__name__}.{deprecated_const.enum.name}" ) diff --git a/tests/helpers/test_deprecation.py b/tests/helpers/test_deprecation.py index 4cf7e851af3..a74055c59ec 100644 --- a/tests/helpers/test_deprecation.py +++ b/tests/helpers/test_deprecation.py @@ -295,7 +295,7 @@ def _get_value( return obj.value if isinstance(obj, DeprecatedConstantEnum): - return obj.enum.value + return obj.enum if isinstance(obj, DeprecatedAlias): return obj.value