Improve entity type hints [r] (#77874)

This commit is contained in:
epenet
2022-09-06 09:47:35 +02:00
committed by GitHub
parent 7198273a42
commit 6f564e4f51
28 changed files with 97 additions and 83 deletions
@@ -58,7 +58,7 @@ class RainCloudBinarySensor(RainCloudEntity, BinarySensorEntity):
"""Return true if the binary sensor is on."""
return self._state
def update(self):
def update(self) -> None:
"""Get the latest data and updates the state."""
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
self._state = getattr(self.data, self._sensor_type)
+1 -1
View File
@@ -66,7 +66,7 @@ class RainCloudSensor(RainCloudEntity, SensorEntity):
"""Return the units of measurement."""
return UNIT_OF_MEASUREMENT_MAP.get(self._sensor_type)
def update(self):
def update(self) -> None:
"""Get the latest data and updates the states."""
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
if self._sensor_type == "battery":
+4 -3
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
import voluptuous as vol
@@ -68,7 +69,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchEntity):
"""Return true if device is on."""
return self._state
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
if self._sensor_type == "manual_watering":
self.data.watering_time = self._default_watering_timer
@@ -76,7 +77,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchEntity):
self.data.auto_watering = True
self._state = True
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
if self._sensor_type == "manual_watering":
self.data.watering_time = "off"
@@ -84,7 +85,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchEntity):
self.data.auto_watering = False
self._state = False
def update(self):
def update(self) -> None:
"""Update device state."""
_LOGGER.debug("Updating RainCloud switch: %s", self._name)
if self._sensor_type == "manual_watering":