diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 6446a4fe6d61b..dad0e2e00f357 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -23,7 +23,6 @@ final, ) -from typing_extensions import dataclass_transform import voluptuous as vol from homeassistant.backports.functools import cached_property @@ -220,17 +219,7 @@ class EntityPlatformState(Enum): REMOVED = auto() -@dataclass_transform( - field_specifiers=(dataclasses.field, dataclasses.Field), - kw_only_default=True, # Set to allow setting kw_only in child classes -) -class _EntityDescriptionBase: - """Add PEP 681 decorator (dataclass transform).""" - - -class EntityDescription( - _EntityDescriptionBase, metaclass=FrozenOrThawed, frozen_or_thawed=True -): +class EntityDescription(metaclass=FrozenOrThawed, frozen_or_thawed=True): """A class that describes Home Assistant entities.""" # This is the key identifier for this entity diff --git a/homeassistant/util/frozen_dataclass_compat.py b/homeassistant/util/frozen_dataclass_compat.py index 96053844ab582..e62e0a34cf141 100644 --- a/homeassistant/util/frozen_dataclass_compat.py +++ b/homeassistant/util/frozen_dataclass_compat.py @@ -9,6 +9,8 @@ import sys from typing import Any +from typing_extensions import dataclass_transform + def _class_fields(cls: type, kw_only: bool) -> list[tuple[str, Any, Any]]: """Return a list of dataclass fields. @@ -41,6 +43,10 @@ def _class_fields(cls: type, kw_only: bool) -> list[tuple[str, Any, Any]]: return [(field.name, field.type, field) for field in cls_fields] +@dataclass_transform( + field_specifiers=(dataclasses.field, dataclasses.Field), + kw_only_default=True, # Set to allow setting kw_only in child classes +) class FrozenOrThawed(type): """Metaclass which which makes classes which behave like a dataclass.