mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Remove unneeded class _EntityDescriptionBase (#105518)
This commit is contained in:
parent
bf93929826
commit
d4cf049016
@ -23,7 +23,6 @@ from typing import (
|
|||||||
final,
|
final,
|
||||||
)
|
)
|
||||||
|
|
||||||
from typing_extensions import dataclass_transform
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.backports.functools import cached_property
|
from homeassistant.backports.functools import cached_property
|
||||||
@ -220,17 +219,7 @@ class EntityPlatformState(Enum):
|
|||||||
REMOVED = auto()
|
REMOVED = auto()
|
||||||
|
|
||||||
|
|
||||||
@dataclass_transform(
|
class EntityDescription(metaclass=FrozenOrThawed, frozen_or_thawed=True):
|
||||||
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
|
|
||||||
):
|
|
||||||
"""A class that describes Home Assistant entities."""
|
"""A class that describes Home Assistant entities."""
|
||||||
|
|
||||||
# This is the key identifier for this entity
|
# This is the key identifier for this entity
|
||||||
|
@ -9,6 +9,8 @@ import dataclasses
|
|||||||
import sys
|
import sys
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from typing_extensions import dataclass_transform
|
||||||
|
|
||||||
|
|
||||||
def _class_fields(cls: type, kw_only: bool) -> list[tuple[str, Any, Any]]:
|
def _class_fields(cls: type, kw_only: bool) -> list[tuple[str, Any, Any]]:
|
||||||
"""Return a list of dataclass fields.
|
"""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]
|
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):
|
class FrozenOrThawed(type):
|
||||||
"""Metaclass which which makes classes which behave like a dataclass.
|
"""Metaclass which which makes classes which behave like a dataclass.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user