Skip to content

Commit

Permalink
Remove unneeded class _EntityDescriptionBase (#105518)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Dec 11, 2023
1 parent bf93929 commit d4cf049
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
13 changes: 1 addition & 12 deletions homeassistant/helpers/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
final,
)

from typing_extensions import dataclass_transform
import voluptuous as vol

from homeassistant.backports.functools import cached_property
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/util/frozen_dataclass_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d4cf049

Please sign in to comment.