Improve entity type hints [e] (#77041)

This commit is contained in:
epenet 2022-08-20 07:52:55 +02:00 committed by GitHub
parent 21cd2f5db7
commit 3a3f41f3df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 138 additions and 111 deletions

View file

@ -2,6 +2,7 @@
from __future__ import annotations
import collections
from typing import Any
import voluptuous as vol
@ -330,7 +331,7 @@ class Thermostat(ClimateEntity):
self._fan_modes = [FAN_AUTO, FAN_ON]
self.update_without_throttle = False
async def async_update(self):
async def async_update(self) -> None:
"""Get the latest state from the thermostat."""
if self.update_without_throttle:
await self.data.update(no_throttle=True)
@ -342,12 +343,12 @@ class Thermostat(ClimateEntity):
self._last_active_hvac_mode = self.hvac_mode
@property
def available(self):
def available(self) -> bool:
"""Return if device is available."""
return self.thermostat["runtime"]["connected"]
@property
def supported_features(self):
def supported_features(self) -> int:
"""Return the list of supported features."""
if self.has_humidifier_control:
return SUPPORT_FLAGS | ClimateEntityFeature.TARGET_HUMIDITY
@ -563,7 +564,7 @@ class Thermostat(ClimateEntity):
if self.is_aux_heat:
_LOGGER.warning("# Changing aux heat is not supported")
def set_preset_mode(self, preset_mode):
def set_preset_mode(self, preset_mode: str) -> None:
"""Activate a preset."""
if preset_mode == self.preset_mode:
return
@ -653,7 +654,7 @@ class Thermostat(ClimateEntity):
self.update_without_throttle = True
def set_fan_mode(self, fan_mode):
def set_fan_mode(self, fan_mode: str) -> None:
"""Set the fan mode. Valid values are "on" or "auto"."""
if fan_mode.lower() not in (FAN_ON, FAN_AUTO):
error = "Invalid fan_mode value: Valid values are 'on' or 'auto'"
@ -689,7 +690,7 @@ class Thermostat(ClimateEntity):
cool_temp = temp + delta
self.set_auto_temp_hold(heat_temp, cool_temp)
def set_temperature(self, **kwargs):
def set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
low_temp = kwargs.get(ATTR_TARGET_TEMP_LOW)
high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH)
@ -704,7 +705,7 @@ class Thermostat(ClimateEntity):
else:
_LOGGER.error("Missing valid arguments for set_temperature in %s", kwargs)
def set_humidity(self, humidity):
def set_humidity(self, humidity: int) -> None:
"""Set the humidity level."""
if humidity not in range(0, 101):
raise ValueError(
@ -714,7 +715,7 @@ class Thermostat(ClimateEntity):
self.data.ecobee.set_humidity(self.thermostat_index, int(humidity))
self.update_without_throttle = True
def set_hvac_mode(self, hvac_mode):
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set HVAC mode (auto, auxHeatOnly, cool, heat, off)."""
ecobee_value = next(
(k for k, v in ECOBEE_HVAC_TO_HASS.items() if v == hvac_mode), None
@ -821,7 +822,7 @@ class Thermostat(ClimateEntity):
)
self.data.ecobee.delete_vacation(self.thermostat_index, vacation_name)
def turn_on(self):
def turn_on(self) -> None:
"""Set the thermostat to the last active HVAC mode."""
_LOGGER.debug(
"Turning on ecobee thermostat %s in %s mode",