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
epenet 2022-01-19 09:00:09 +01:00 committed by GitHub
parent f38a00740f
commit 2f8d99bf5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 47 additions and 61 deletions

View File

@ -272,7 +272,7 @@ class DeviceTrackerWatcher(WatcherBase):
@callback
def _async_process_device_event(self, event: 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
def _async_process_device_state(self, state: State):

View File

@ -89,7 +89,7 @@ async def async_setup_entry(
probe = GrowattData(
api, username, password, device["deviceSn"], device["deviceType"]
)
sensor_descriptions = ()
sensor_descriptions: tuple[GrowattSensorEntityDescription, ...] = ()
if device["deviceType"] == "inverter":
sensor_descriptions = INVERTER_SENSOR_TYPES
elif device["deviceType"] == "tlx":

View File

@ -1,4 +1,6 @@
"""Support for Habitica sensors."""
from __future__ import annotations
from collections import namedtuple
from datetime import timedelta
from http import HTTPStatus
@ -19,26 +21,34 @@ _LOGGER = logging.getLogger(__name__)
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15)
ST = SensorType = namedtuple("SensorType", ["name", "icon", "unit", "path"])
SensorType = namedtuple("SensorType", ["name", "icon", "unit", "path"])
SENSORS_TYPES = {
"name": ST("Name", None, "", ["profile", "name"]),
"hp": ST("HP", "mdi:heart", "HP", ["stats", "hp"]),
"maxHealth": ST("max HP", "mdi:heart", "HP", ["stats", "maxHealth"]),
"mp": ST("Mana", "mdi:auto-fix", "MP", ["stats", "mp"]),
"maxMP": ST("max Mana", "mdi:auto-fix", "MP", ["stats", "maxMP"]),
"exp": ST("EXP", "mdi:star", "EXP", ["stats", "exp"]),
"toNextLevel": ST("Next Lvl", "mdi:star", "EXP", ["stats", "toNextLevel"]),
"lvl": ST("Lvl", "mdi:arrow-up-bold-circle-outline", "Lvl", ["stats", "lvl"]),
"gp": ST("Gold", "mdi:circle-multiple", "Gold", ["stats", "gp"]),
"class": ST("Class", "mdi:sword", "", ["stats", "class"]),
"name": SensorType("Name", None, "", ["profile", "name"]),
"hp": SensorType("HP", "mdi:heart", "HP", ["stats", "hp"]),
"maxHealth": SensorType("max HP", "mdi:heart", "HP", ["stats", "maxHealth"]),
"mp": SensorType("Mana", "mdi:auto-fix", "MP", ["stats", "mp"]),
"maxMP": SensorType("max Mana", "mdi:auto-fix", "MP", ["stats", "maxMP"]),
"exp": SensorType("EXP", "mdi:star", "EXP", ["stats", "exp"]),
"toNextLevel": SensorType("Next Lvl", "mdi:star", "EXP", ["stats", "toNextLevel"]),
"lvl": SensorType(
"Lvl", "mdi:arrow-up-bold-circle-outline", "Lvl", ["stats", "lvl"]
),
"gp": SensorType("Gold", "mdi:circle-multiple", "Gold", ["stats", "gp"]),
"class": SensorType("Class", "mdi:sword", "", ["stats", "class"]),
}
TASKS_TYPES = {
"habits": ST("Habits", "mdi:clipboard-list-outline", "n_of_tasks", ["habits"]),
"dailys": ST("Dailys", "mdi:clipboard-list-outline", "n_of_tasks", ["dailys"]),
"todos": ST("TODOs", "mdi:clipboard-list-outline", "n_of_tasks", ["todos"]),
"rewards": ST("Rewards", "mdi:clipboard-list-outline", "n_of_tasks", ["rewards"]),
"habits": SensorType(
"Habits", "mdi:clipboard-list-outline", "n_of_tasks", ["habits"]
),
"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"
@ -76,7 +86,7 @@ async def async_setup_entry(
) -> None:
"""Set up the habitica sensors."""
entities = []
entities: list[SensorEntity] = []
name = config_entry.data[CONF_NAME]
sensor_data = HabitipyData(hass.data[DOMAIN][config_entry.entry_id])
await sensor_data.update()

View File

@ -2,6 +2,7 @@
from asyncio import run_coroutine_threadsafe
import logging
from typing import Any
import homeconnect
from homeconnect.api import HomeConnectError
@ -54,7 +55,7 @@ class ConfigEntryAuth(homeconnect.HomeConnectAPI):
hass, config_entry, implementation
)
super().__init__(self.session.token)
self.devices = []
self.devices: list[dict[str, Any]] = []
def refresh_tokens(self) -> dict:
"""Refresh and return new Home Connect tokens using Home Assistant OAuth2 session."""
@ -142,7 +143,7 @@ class HomeConnectDevice:
class DeviceWithPrograms(HomeConnectDevice):
"""Device with programs."""
PROGRAMS = []
PROGRAMS: list[dict[str, str]] = []
def get_programs_available(self):
"""Get the available programs."""

View File

@ -1,4 +1,6 @@
"""Support for Aqualink temperature sensors."""
from __future__ import annotations
from homeassistant.components.binary_sensor import (
DOMAIN,
BinarySensorDeviceClass,
@ -40,7 +42,7 @@ class HassAqualinkBinarySensor(AqualinkEntity, BinarySensorEntity):
return self.dev.is_on
@property
def device_class(self) -> str:
def device_class(self) -> BinarySensorDeviceClass | None:
"""Return the class of the binary sensor."""
if self.name == "Freeze Protection":
return BinarySensorDeviceClass.COLD

View File

@ -43,16 +43,15 @@ class HassAqualinkSensor(AqualinkEntity, SensorEntity):
return None
@property
def native_value(self) -> str | None:
def native_value(self) -> int | float | None:
"""Return the state of the sensor."""
if self.dev.state == "":
return None
try:
state = int(self.dev.state)
return int(self.dev.state)
except ValueError:
state = float(self.dev.state)
return state
return float(self.dev.state)
@property
def device_class(self) -> str | None:

View File

@ -1,4 +1,6 @@
"""Support for Aqualink pool feature switches."""
from __future__ import annotations
from homeassistant.components.switch import DOMAIN, SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -32,7 +34,7 @@ class HassAqualinkSwitch(AqualinkEntity, SwitchEntity):
return self.dev.label
@property
def icon(self) -> str:
def icon(self) -> str | None:
"""Return an icon based on the switch type."""
if self.name == "Cleaner":
return "mdi:robot-vacuum"
@ -42,6 +44,7 @@ class HassAqualinkSwitch(AqualinkEntity, SwitchEntity):
return "mdi:fan"
if self.name.endswith("Heater"):
return "mdi:radiator"
return None
@property
def is_on(self) -> bool:

View File

@ -74,7 +74,8 @@ class IncomfortEntity(Entity):
def __init__(self) -> None:
"""Initialize the class."""
self._unique_id = self._name = None
self._name: str | None = None
self._unique_id: str | None = None
@property
def unique_id(self) -> str | None:

View File

@ -200,7 +200,7 @@ class InputNumber(RestoreEntity):
"""Initialize an input number."""
self._config = config
self.editable = True
self._current_value = config.get(CONF_INITIAL)
self._current_value: float | None = config.get(CONF_INITIAL)
@classmethod
def from_yaml(cls, config: dict) -> InputNumber:
@ -306,6 +306,8 @@ class InputNumber(RestoreEntity):
"""Handle when the config is updated."""
self._config = config
# 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 = max(self._current_value, self._minimum)
self.async_write_ha_state()

View File

@ -39,7 +39,7 @@ async def async_setup_entry(
if (unique_id := entry.unique_id) is None:
unique_id = entry.entry_id
sensors = []
sensors: list[SensorEntity] = []
sensors.append(IPPPrinterSensor(entry.entry_id, unique_id, coordinator))
sensors.append(IPPUptimeSensor(entry.entry_id, unique_id, coordinator))

View File

@ -2033,9 +2033,6 @@ ignore_errors = true
[mypy-homeassistant.components.denonavr.*]
ignore_errors = true
[mypy-homeassistant.components.dhcp.*]
ignore_errors = true
[mypy-homeassistant.components.evohome.*]
ignore_errors = true
@ -2057,12 +2054,6 @@ ignore_errors = true
[mypy-homeassistant.components.gree.*]
ignore_errors = true
[mypy-homeassistant.components.growatt_server.*]
ignore_errors = true
[mypy-homeassistant.components.habitica.*]
ignore_errors = true
[mypy-homeassistant.components.harmony.*]
ignore_errors = true
@ -2072,9 +2063,6 @@ ignore_errors = true
[mypy-homeassistant.components.here_travel_time.*]
ignore_errors = true
[mypy-homeassistant.components.home_connect.*]
ignore_errors = true
[mypy-homeassistant.components.home_plus_control.*]
ignore_errors = true
@ -2087,27 +2075,15 @@ ignore_errors = true
[mypy-homeassistant.components.honeywell.*]
ignore_errors = true
[mypy-homeassistant.components.iaqualink.*]
ignore_errors = true
[mypy-homeassistant.components.icloud.*]
ignore_errors = true
[mypy-homeassistant.components.incomfort.*]
ignore_errors = true
[mypy-homeassistant.components.influxdb.*]
ignore_errors = true
[mypy-homeassistant.components.input_datetime.*]
ignore_errors = true
[mypy-homeassistant.components.input_number.*]
ignore_errors = true
[mypy-homeassistant.components.ipp.*]
ignore_errors = true
[mypy-homeassistant.components.isy994.*]
ignore_errors = true

View File

@ -23,7 +23,6 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.deconz.*",
"homeassistant.components.demo.*",
"homeassistant.components.denonavr.*",
"homeassistant.components.dhcp.*",
"homeassistant.components.evohome.*",
"homeassistant.components.fireservicerota.*",
"homeassistant.components.firmata.*",
@ -31,23 +30,16 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.geniushub.*",
"homeassistant.components.google_assistant.*",
"homeassistant.components.gree.*",
"homeassistant.components.growatt_server.*",
"homeassistant.components.habitica.*",
"homeassistant.components.harmony.*",
"homeassistant.components.hassio.*",
"homeassistant.components.here_travel_time.*",
"homeassistant.components.home_connect.*",
"homeassistant.components.home_plus_control.*",
"homeassistant.components.homekit.*",
"homeassistant.components.homekit_controller.*",
"homeassistant.components.honeywell.*",
"homeassistant.components.iaqualink.*",
"homeassistant.components.icloud.*",
"homeassistant.components.incomfort.*",
"homeassistant.components.influxdb.*",
"homeassistant.components.input_datetime.*",
"homeassistant.components.input_number.*",
"homeassistant.components.ipp.*",
"homeassistant.components.isy994.*",
"homeassistant.components.izone.*",
"homeassistant.components.kaiterra.*",