From 6b6e26c96d1d41d3fab501509ecbb4f3f993de0b Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sat, 18 Sep 2021 21:54:11 +0200 Subject: [PATCH] Strictly type binary_sensor.py. (#56376) --- homeassistant/components/modbus/binary_sensor.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/modbus/binary_sensor.py b/homeassistant/components/modbus/binary_sensor.py index adc5e2d28f1..d3a8578f47d 100644 --- a/homeassistant/components/modbus/binary_sensor.py +++ b/homeassistant/components/modbus/binary_sensor.py @@ -1,11 +1,13 @@ """Support for Modbus Coil and Discrete Input sensors.""" from __future__ import annotations +from datetime import datetime import logging from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.const import CONF_BINARY_SENSORS, CONF_NAME, STATE_ON from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -19,9 +21,9 @@ _LOGGER = logging.getLogger(__name__) async def async_setup_platform( hass: HomeAssistant, config: ConfigType, - async_add_entities, + async_add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, -): +) -> None: """Set up the Modbus binary sensors.""" sensors = [] @@ -38,14 +40,14 @@ async def async_setup_platform( class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity): """Modbus binary sensor.""" - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Handle entity which will be added.""" await self.async_base_added_to_hass() state = await self.async_get_last_state() if state: self._attr_is_on = state.state == STATE_ON - async def async_update(self, now=None): + async def async_update(self, now: datetime | None = None) -> None: """Update the state of the sensor.""" # do not allow multiple active calls to the same platform