Remove entity description mixin in Schlage (#112934)

This commit is contained in:
Joost Lekkerkerker 2024-03-11 11:18:34 +01:00 committed by GitHub
parent e4b43680e1
commit da40e83fd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 30 deletions

View File

@ -20,25 +20,13 @@ from .coordinator import LockData, SchlageDataUpdateCoordinator
from .entity import SchlageEntity from .entity import SchlageEntity
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class SchlageBinarySensorEntityDescriptionMixin: class SchlageBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Mixin for required keys.""" """Entity description for a Schlage binary_sensor."""
# NOTE: This has to be a mixin because these are required keys.
# BinarySensorEntityDescription has attributes with default values,
# which means we can't inherit from it because you haven't have
# non-default arguments follow default arguments in an initializer.
value_fn: Callable[[LockData], bool] value_fn: Callable[[LockData], bool]
@dataclass(frozen=True)
class SchlageBinarySensorEntityDescription(
BinarySensorEntityDescription, SchlageBinarySensorEntityDescriptionMixin
):
"""Entity description for a Schlage binary_sensor."""
_DESCRIPTIONS: tuple[SchlageBinarySensorEntityDescription] = ( _DESCRIPTIONS: tuple[SchlageBinarySensorEntityDescription] = (
SchlageBinarySensorEntityDescription( SchlageBinarySensorEntityDescription(
key="keypad_disabled", key="keypad_disabled",

View File

@ -24,27 +24,15 @@ from .coordinator import SchlageDataUpdateCoordinator
from .entity import SchlageEntity from .entity import SchlageEntity
@dataclass(frozen=True) @dataclass(frozen=True, kw_only=True)
class SchlageSwitchEntityDescriptionMixin: class SchlageSwitchEntityDescription(SwitchEntityDescription):
"""Mixin for required keys.""" """Entity description for a Schlage switch."""
# NOTE: This has to be a mixin because these are required keys.
# SwitchEntityDescription has attributes with default values,
# which means we can't inherit from it because you haven't have
# non-default arguments follow default arguments in an initializer.
on_fn: Callable[[Lock], None] on_fn: Callable[[Lock], None]
off_fn: Callable[[Lock], None] off_fn: Callable[[Lock], None]
value_fn: Callable[[Lock], bool] value_fn: Callable[[Lock], bool]
@dataclass(frozen=True)
class SchlageSwitchEntityDescription(
SwitchEntityDescription, SchlageSwitchEntityDescriptionMixin
):
"""Entity description for a Schlage switch."""
SWITCHES: tuple[SchlageSwitchEntityDescription, ...] = ( SWITCHES: tuple[SchlageSwitchEntityDescription, ...] = (
SchlageSwitchEntityDescription( SchlageSwitchEntityDescription(
key="beeper", key="beeper",