Improve drop_connect typing (#106404)

pull/106409/head
Marc Mueller 2023-12-26 13:11:05 +01:00 committed by GitHub
parent 1c96cf33b8
commit 0d2ec6cd5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -49,7 +49,7 @@ SALT_LOW = "salt"
class DROPBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Describes DROP binary sensor entity."""
value_fn: Callable[[DROPDeviceDataUpdateCoordinator], bool | None]
value_fn: Callable[[DROPDeviceDataUpdateCoordinator], int | None]
BINARY_SENSORS: list[DROPBinarySensorEntityDescription] = [

View File

@ -15,7 +15,7 @@ from .const import CONF_COMMAND_TOPIC, DOMAIN
_LOGGER = logging.getLogger(__name__)
class DROPDeviceDataUpdateCoordinator(DataUpdateCoordinator):
class DROPDeviceDataUpdateCoordinator(DataUpdateCoordinator[None]):
"""DROP device object."""
config_entry: ConfigEntry

View File

@ -30,7 +30,7 @@ FLOOD_ICON = "mdi:home-flood"
class DROPSelectEntityDescription(SelectEntityDescription):
"""Describes DROP select entity."""
value_fn: Callable[[DROPDeviceDataUpdateCoordinator], str | None]
value_fn: Callable[[DROPDeviceDataUpdateCoordinator], int | None]
set_fn: Callable[[DROPDeviceDataUpdateCoordinator, str], Awaitable[Any]]
@ -88,7 +88,8 @@ class DROPSelect(DROPEntity, SelectEntity):
@property
def current_option(self) -> str | None:
"""Return the current selected option."""
return self.entity_description.value_fn(self.coordinator)
val = self.entity_description.value_fn(self.coordinator)
return str(val) if val else None
async def async_select_option(self, option: str) -> None:
"""Update the current selected option."""