Remove unneeded class _EntityDescriptionBase (#105518)

This commit is contained in:
Erik Montnemery 2023-12-11 23:10:11 +01:00 committed by GitHub
parent bf93929826
commit d4cf049016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 12 deletions

View File

@ -23,7 +23,6 @@ from typing import (
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

View File

@ -9,6 +9,8 @@ import dataclasses
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.