mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 21:37:07 +00:00
Fix deprecated enums (#134824)
This commit is contained in:
parent
440cd5bee0
commit
1de4d0efda
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from enum import Enum, EnumType, _EnumDict
|
from enum import EnumType, IntEnum, IntFlag, StrEnum, _EnumDict
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
@ -255,7 +255,7 @@ class DeprecatedConstant(NamedTuple):
|
|||||||
class DeprecatedConstantEnum(NamedTuple):
|
class DeprecatedConstantEnum(NamedTuple):
|
||||||
"""Deprecated constant."""
|
"""Deprecated constant."""
|
||||||
|
|
||||||
enum: Enum
|
enum: StrEnum | IntEnum | IntFlag
|
||||||
breaks_in_ha_version: str | None
|
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
|
replacement = deprecated_const.replacement
|
||||||
breaks_in_ha_version = deprecated_const.breaks_in_ha_version
|
breaks_in_ha_version = deprecated_const.breaks_in_ha_version
|
||||||
elif isinstance(deprecated_const, DeprecatedConstantEnum):
|
elif isinstance(deprecated_const, DeprecatedConstantEnum):
|
||||||
value = deprecated_const.enum.value
|
value = deprecated_const.enum
|
||||||
replacement = (
|
replacement = (
|
||||||
f"{deprecated_const.enum.__class__.__name__}.{deprecated_const.enum.name}"
|
f"{deprecated_const.enum.__class__.__name__}.{deprecated_const.enum.name}"
|
||||||
)
|
)
|
||||||
|
@ -295,7 +295,7 @@ def _get_value(
|
|||||||
return obj.value
|
return obj.value
|
||||||
|
|
||||||
if isinstance(obj, DeprecatedConstantEnum):
|
if isinstance(obj, DeprecatedConstantEnum):
|
||||||
return obj.enum.value
|
return obj.enum
|
||||||
|
|
||||||
if isinstance(obj, DeprecatedAlias):
|
if isinstance(obj, DeprecatedAlias):
|
||||||
return obj.value
|
return obj.value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user