Remove integrations from mypy ignored modules (part 2) (#64367)
* Adjust dhcp * Adjust growatt_server * Adjust habitica * Adjust home_connect * Adjust iaqualink * Adjust incomfort * Adjust input_number * Adjust ipp * Adjust mypy_config * Unindent input-number * Fix type hint in home_connect Co-authored-by: epenet <epenet@users.noreply.github.com>pull/64417/head
parent
f38a00740f
commit
2f8d99bf5d
|
@ -272,7 +272,7 @@ class DeviceTrackerWatcher(WatcherBase):
|
||||||
@callback
|
@callback
|
||||||
def _async_process_device_event(self, event: Event):
|
def _async_process_device_event(self, event: Event):
|
||||||
"""Process a device tracker state change event."""
|
"""Process a device tracker state change event."""
|
||||||
self._async_process_device_state(event.data.get("new_state"))
|
self._async_process_device_state(event.data["new_state"])
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_process_device_state(self, state: State):
|
def _async_process_device_state(self, state: State):
|
||||||
|
|
|
@ -89,7 +89,7 @@ async def async_setup_entry(
|
||||||
probe = GrowattData(
|
probe = GrowattData(
|
||||||
api, username, password, device["deviceSn"], device["deviceType"]
|
api, username, password, device["deviceSn"], device["deviceType"]
|
||||||
)
|
)
|
||||||
sensor_descriptions = ()
|
sensor_descriptions: tuple[GrowattSensorEntityDescription, ...] = ()
|
||||||
if device["deviceType"] == "inverter":
|
if device["deviceType"] == "inverter":
|
||||||
sensor_descriptions = INVERTER_SENSOR_TYPES
|
sensor_descriptions = INVERTER_SENSOR_TYPES
|
||||||
elif device["deviceType"] == "tlx":
|
elif device["deviceType"] == "tlx":
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Habitica sensors."""
|
"""Support for Habitica sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
@ -19,26 +21,34 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15)
|
||||||
|
|
||||||
ST = SensorType = namedtuple("SensorType", ["name", "icon", "unit", "path"])
|
SensorType = namedtuple("SensorType", ["name", "icon", "unit", "path"])
|
||||||
|
|
||||||
SENSORS_TYPES = {
|
SENSORS_TYPES = {
|
||||||
"name": ST("Name", None, "", ["profile", "name"]),
|
"name": SensorType("Name", None, "", ["profile", "name"]),
|
||||||
"hp": ST("HP", "mdi:heart", "HP", ["stats", "hp"]),
|
"hp": SensorType("HP", "mdi:heart", "HP", ["stats", "hp"]),
|
||||||
"maxHealth": ST("max HP", "mdi:heart", "HP", ["stats", "maxHealth"]),
|
"maxHealth": SensorType("max HP", "mdi:heart", "HP", ["stats", "maxHealth"]),
|
||||||
"mp": ST("Mana", "mdi:auto-fix", "MP", ["stats", "mp"]),
|
"mp": SensorType("Mana", "mdi:auto-fix", "MP", ["stats", "mp"]),
|
||||||
"maxMP": ST("max Mana", "mdi:auto-fix", "MP", ["stats", "maxMP"]),
|
"maxMP": SensorType("max Mana", "mdi:auto-fix", "MP", ["stats", "maxMP"]),
|
||||||
"exp": ST("EXP", "mdi:star", "EXP", ["stats", "exp"]),
|
"exp": SensorType("EXP", "mdi:star", "EXP", ["stats", "exp"]),
|
||||||
"toNextLevel": ST("Next Lvl", "mdi:star", "EXP", ["stats", "toNextLevel"]),
|
"toNextLevel": SensorType("Next Lvl", "mdi:star", "EXP", ["stats", "toNextLevel"]),
|
||||||
"lvl": ST("Lvl", "mdi:arrow-up-bold-circle-outline", "Lvl", ["stats", "lvl"]),
|
"lvl": SensorType(
|
||||||
"gp": ST("Gold", "mdi:circle-multiple", "Gold", ["stats", "gp"]),
|
"Lvl", "mdi:arrow-up-bold-circle-outline", "Lvl", ["stats", "lvl"]
|
||||||
"class": ST("Class", "mdi:sword", "", ["stats", "class"]),
|
),
|
||||||
|
"gp": SensorType("Gold", "mdi:circle-multiple", "Gold", ["stats", "gp"]),
|
||||||
|
"class": SensorType("Class", "mdi:sword", "", ["stats", "class"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
TASKS_TYPES = {
|
TASKS_TYPES = {
|
||||||
"habits": ST("Habits", "mdi:clipboard-list-outline", "n_of_tasks", ["habits"]),
|
"habits": SensorType(
|
||||||
"dailys": ST("Dailys", "mdi:clipboard-list-outline", "n_of_tasks", ["dailys"]),
|
"Habits", "mdi:clipboard-list-outline", "n_of_tasks", ["habits"]
|
||||||
"todos": ST("TODOs", "mdi:clipboard-list-outline", "n_of_tasks", ["todos"]),
|
),
|
||||||
"rewards": ST("Rewards", "mdi:clipboard-list-outline", "n_of_tasks", ["rewards"]),
|
"dailys": SensorType(
|
||||||
|
"Dailys", "mdi:clipboard-list-outline", "n_of_tasks", ["dailys"]
|
||||||
|
),
|
||||||
|
"todos": SensorType("TODOs", "mdi:clipboard-list-outline", "n_of_tasks", ["todos"]),
|
||||||
|
"rewards": SensorType(
|
||||||
|
"Rewards", "mdi:clipboard-list-outline", "n_of_tasks", ["rewards"]
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
TASKS_MAP_ID = "id"
|
TASKS_MAP_ID = "id"
|
||||||
|
@ -76,7 +86,7 @@ async def async_setup_entry(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the habitica sensors."""
|
"""Set up the habitica sensors."""
|
||||||
|
|
||||||
entities = []
|
entities: list[SensorEntity] = []
|
||||||
name = config_entry.data[CONF_NAME]
|
name = config_entry.data[CONF_NAME]
|
||||||
sensor_data = HabitipyData(hass.data[DOMAIN][config_entry.entry_id])
|
sensor_data = HabitipyData(hass.data[DOMAIN][config_entry.entry_id])
|
||||||
await sensor_data.update()
|
await sensor_data.update()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from asyncio import run_coroutine_threadsafe
|
from asyncio import run_coroutine_threadsafe
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import homeconnect
|
import homeconnect
|
||||||
from homeconnect.api import HomeConnectError
|
from homeconnect.api import HomeConnectError
|
||||||
|
@ -54,7 +55,7 @@ class ConfigEntryAuth(homeconnect.HomeConnectAPI):
|
||||||
hass, config_entry, implementation
|
hass, config_entry, implementation
|
||||||
)
|
)
|
||||||
super().__init__(self.session.token)
|
super().__init__(self.session.token)
|
||||||
self.devices = []
|
self.devices: list[dict[str, Any]] = []
|
||||||
|
|
||||||
def refresh_tokens(self) -> dict:
|
def refresh_tokens(self) -> dict:
|
||||||
"""Refresh and return new Home Connect tokens using Home Assistant OAuth2 session."""
|
"""Refresh and return new Home Connect tokens using Home Assistant OAuth2 session."""
|
||||||
|
@ -142,7 +143,7 @@ class HomeConnectDevice:
|
||||||
class DeviceWithPrograms(HomeConnectDevice):
|
class DeviceWithPrograms(HomeConnectDevice):
|
||||||
"""Device with programs."""
|
"""Device with programs."""
|
||||||
|
|
||||||
PROGRAMS = []
|
PROGRAMS: list[dict[str, str]] = []
|
||||||
|
|
||||||
def get_programs_available(self):
|
def get_programs_available(self):
|
||||||
"""Get the available programs."""
|
"""Get the available programs."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Aqualink temperature sensors."""
|
"""Support for Aqualink temperature sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
BinarySensorDeviceClass,
|
BinarySensorDeviceClass,
|
||||||
|
@ -40,7 +42,7 @@ class HassAqualinkBinarySensor(AqualinkEntity, BinarySensorEntity):
|
||||||
return self.dev.is_on
|
return self.dev.is_on
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> BinarySensorDeviceClass | None:
|
||||||
"""Return the class of the binary sensor."""
|
"""Return the class of the binary sensor."""
|
||||||
if self.name == "Freeze Protection":
|
if self.name == "Freeze Protection":
|
||||||
return BinarySensorDeviceClass.COLD
|
return BinarySensorDeviceClass.COLD
|
||||||
|
|
|
@ -43,16 +43,15 @@ class HassAqualinkSensor(AqualinkEntity, SensorEntity):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> str | None:
|
def native_value(self) -> int | float | None:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
if self.dev.state == "":
|
if self.dev.state == "":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
state = int(self.dev.state)
|
return int(self.dev.state)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
state = float(self.dev.state)
|
return float(self.dev.state)
|
||||||
return state
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str | None:
|
def device_class(self) -> str | None:
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Aqualink pool feature switches."""
|
"""Support for Aqualink pool feature switches."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN, SwitchEntity
|
from homeassistant.components.switch import DOMAIN, SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -32,7 +34,7 @@ class HassAqualinkSwitch(AqualinkEntity, SwitchEntity):
|
||||||
return self.dev.label
|
return self.dev.label
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str | None:
|
||||||
"""Return an icon based on the switch type."""
|
"""Return an icon based on the switch type."""
|
||||||
if self.name == "Cleaner":
|
if self.name == "Cleaner":
|
||||||
return "mdi:robot-vacuum"
|
return "mdi:robot-vacuum"
|
||||||
|
@ -42,6 +44,7 @@ class HassAqualinkSwitch(AqualinkEntity, SwitchEntity):
|
||||||
return "mdi:fan"
|
return "mdi:fan"
|
||||||
if self.name.endswith("Heater"):
|
if self.name.endswith("Heater"):
|
||||||
return "mdi:radiator"
|
return "mdi:radiator"
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
|
|
@ -74,7 +74,8 @@ class IncomfortEntity(Entity):
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize the class."""
|
"""Initialize the class."""
|
||||||
self._unique_id = self._name = None
|
self._name: str | None = None
|
||||||
|
self._unique_id: str | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str | None:
|
def unique_id(self) -> str | None:
|
||||||
|
|
|
@ -200,7 +200,7 @@ class InputNumber(RestoreEntity):
|
||||||
"""Initialize an input number."""
|
"""Initialize an input number."""
|
||||||
self._config = config
|
self._config = config
|
||||||
self.editable = True
|
self.editable = True
|
||||||
self._current_value = config.get(CONF_INITIAL)
|
self._current_value: float | None = config.get(CONF_INITIAL)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: dict) -> InputNumber:
|
def from_yaml(cls, config: dict) -> InputNumber:
|
||||||
|
@ -306,6 +306,8 @@ class InputNumber(RestoreEntity):
|
||||||
"""Handle when the config is updated."""
|
"""Handle when the config is updated."""
|
||||||
self._config = config
|
self._config = config
|
||||||
# just in case min/max values changed
|
# just in case min/max values changed
|
||||||
|
if self._current_value is None:
|
||||||
|
return
|
||||||
self._current_value = min(self._current_value, self._maximum)
|
self._current_value = min(self._current_value, self._maximum)
|
||||||
self._current_value = max(self._current_value, self._minimum)
|
self._current_value = max(self._current_value, self._minimum)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
|
@ -39,7 +39,7 @@ async def async_setup_entry(
|
||||||
if (unique_id := entry.unique_id) is None:
|
if (unique_id := entry.unique_id) is None:
|
||||||
unique_id = entry.entry_id
|
unique_id = entry.entry_id
|
||||||
|
|
||||||
sensors = []
|
sensors: list[SensorEntity] = []
|
||||||
|
|
||||||
sensors.append(IPPPrinterSensor(entry.entry_id, unique_id, coordinator))
|
sensors.append(IPPPrinterSensor(entry.entry_id, unique_id, coordinator))
|
||||||
sensors.append(IPPUptimeSensor(entry.entry_id, unique_id, coordinator))
|
sensors.append(IPPUptimeSensor(entry.entry_id, unique_id, coordinator))
|
||||||
|
|
24
mypy.ini
24
mypy.ini
|
@ -2033,9 +2033,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.denonavr.*]
|
[mypy-homeassistant.components.denonavr.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.dhcp.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.evohome.*]
|
[mypy-homeassistant.components.evohome.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
@ -2057,12 +2054,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.gree.*]
|
[mypy-homeassistant.components.gree.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.growatt_server.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.habitica.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.harmony.*]
|
[mypy-homeassistant.components.harmony.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
@ -2072,9 +2063,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.here_travel_time.*]
|
[mypy-homeassistant.components.here_travel_time.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.home_connect.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.home_plus_control.*]
|
[mypy-homeassistant.components.home_plus_control.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
@ -2087,27 +2075,15 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.honeywell.*]
|
[mypy-homeassistant.components.honeywell.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.iaqualink.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.icloud.*]
|
[mypy-homeassistant.components.icloud.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.incomfort.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.influxdb.*]
|
[mypy-homeassistant.components.influxdb.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.input_datetime.*]
|
[mypy-homeassistant.components.input_datetime.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.input_number.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.ipp.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.isy994.*]
|
[mypy-homeassistant.components.isy994.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||||
"homeassistant.components.deconz.*",
|
"homeassistant.components.deconz.*",
|
||||||
"homeassistant.components.demo.*",
|
"homeassistant.components.demo.*",
|
||||||
"homeassistant.components.denonavr.*",
|
"homeassistant.components.denonavr.*",
|
||||||
"homeassistant.components.dhcp.*",
|
|
||||||
"homeassistant.components.evohome.*",
|
"homeassistant.components.evohome.*",
|
||||||
"homeassistant.components.fireservicerota.*",
|
"homeassistant.components.fireservicerota.*",
|
||||||
"homeassistant.components.firmata.*",
|
"homeassistant.components.firmata.*",
|
||||||
|
@ -31,23 +30,16 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||||
"homeassistant.components.geniushub.*",
|
"homeassistant.components.geniushub.*",
|
||||||
"homeassistant.components.google_assistant.*",
|
"homeassistant.components.google_assistant.*",
|
||||||
"homeassistant.components.gree.*",
|
"homeassistant.components.gree.*",
|
||||||
"homeassistant.components.growatt_server.*",
|
|
||||||
"homeassistant.components.habitica.*",
|
|
||||||
"homeassistant.components.harmony.*",
|
"homeassistant.components.harmony.*",
|
||||||
"homeassistant.components.hassio.*",
|
"homeassistant.components.hassio.*",
|
||||||
"homeassistant.components.here_travel_time.*",
|
"homeassistant.components.here_travel_time.*",
|
||||||
"homeassistant.components.home_connect.*",
|
|
||||||
"homeassistant.components.home_plus_control.*",
|
"homeassistant.components.home_plus_control.*",
|
||||||
"homeassistant.components.homekit.*",
|
"homeassistant.components.homekit.*",
|
||||||
"homeassistant.components.homekit_controller.*",
|
"homeassistant.components.homekit_controller.*",
|
||||||
"homeassistant.components.honeywell.*",
|
"homeassistant.components.honeywell.*",
|
||||||
"homeassistant.components.iaqualink.*",
|
|
||||||
"homeassistant.components.icloud.*",
|
"homeassistant.components.icloud.*",
|
||||||
"homeassistant.components.incomfort.*",
|
|
||||||
"homeassistant.components.influxdb.*",
|
"homeassistant.components.influxdb.*",
|
||||||
"homeassistant.components.input_datetime.*",
|
"homeassistant.components.input_datetime.*",
|
||||||
"homeassistant.components.input_number.*",
|
|
||||||
"homeassistant.components.ipp.*",
|
|
||||||
"homeassistant.components.isy994.*",
|
"homeassistant.components.isy994.*",
|
||||||
"homeassistant.components.izone.*",
|
"homeassistant.components.izone.*",
|
||||||
"homeassistant.components.kaiterra.*",
|
"homeassistant.components.kaiterra.*",
|
||||||
|
|
Loading…
Reference in New Issue