mirror of
https://github.com/home-assistant/core
synced 2024-08-02 23:40:32 +02:00
Enable basic type checking for asuswrt (#54929)
This commit is contained in:
parent
ef9ad89c23
commit
09ee7fc021
@ -19,7 +19,7 @@ async def async_setup_entry(
|
||||
) -> None:
|
||||
"""Set up device tracker for AsusWrt component."""
|
||||
router = hass.data[DOMAIN][entry.entry_id][DATA_ASUSWRT]
|
||||
tracked = set()
|
||||
tracked: set = set()
|
||||
|
||||
@callback
|
||||
def update_router():
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import Any, Callable
|
||||
|
||||
from aioasuswrt.asuswrt import AsusWrt
|
||||
|
||||
@ -209,16 +209,16 @@ class AsusWrtRouter:
|
||||
self._protocol = entry.data[CONF_PROTOCOL]
|
||||
self._host = entry.data[CONF_HOST]
|
||||
self._model = "Asus Router"
|
||||
self._sw_v = None
|
||||
self._sw_v: str | None = None
|
||||
|
||||
self._devices: dict[str, Any] = {}
|
||||
self._connected_devices = 0
|
||||
self._connect_error = False
|
||||
|
||||
self._sensors_data_handler: AsusWrtSensorDataHandler = None
|
||||
self._sensors_data_handler: AsusWrtSensorDataHandler | None = None
|
||||
self._sensors_coordinator: dict[str, Any] = {}
|
||||
|
||||
self._on_close = []
|
||||
self._on_close: list[Callable] = []
|
||||
|
||||
self._options = {
|
||||
CONF_DNSMASQ: DEFAULT_DNSMASQ,
|
||||
@ -229,7 +229,7 @@ class AsusWrtRouter:
|
||||
|
||||
async def setup(self) -> None:
|
||||
"""Set up a AsusWrt router."""
|
||||
self._api = get_api(self._entry.data, self._options)
|
||||
self._api = get_api(dict(self._entry.data), self._options)
|
||||
|
||||
try:
|
||||
await self._api.connection.async_connect()
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from numbers import Number
|
||||
from numbers import Real
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
@ -149,7 +149,7 @@ class AsusWrtSensor(CoordinatorEntity, SensorEntity):
|
||||
) -> None:
|
||||
"""Initialize a AsusWrt sensor."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self.entity_description: AsusWrtSensorEntityDescription = description
|
||||
|
||||
self._attr_name = f"{DEFAULT_PREFIX} {description.name}"
|
||||
self._attr_unique_id = f"{DOMAIN} {self.name}"
|
||||
@ -157,10 +157,10 @@ class AsusWrtSensor(CoordinatorEntity, SensorEntity):
|
||||
self._attr_extra_state_attributes = {"hostname": router.host}
|
||||
|
||||
@property
|
||||
def native_value(self) -> str | None:
|
||||
def native_value(self) -> float | str | None:
|
||||
"""Return current state."""
|
||||
descr = self.entity_description
|
||||
state = self.coordinator.data.get(descr.key)
|
||||
if state is not None and descr.factor and isinstance(state, Number):
|
||||
if state is not None and descr.factor and isinstance(state, Real):
|
||||
return round(state / descr.factor, descr.precision)
|
||||
return state
|
||||
|
3
mypy.ini
3
mypy.ini
@ -1277,9 +1277,6 @@ ignore_errors = true
|
||||
[mypy-homeassistant.components.analytics.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.asuswrt.*]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.atag.*]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -18,7 +18,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.aemet.*",
|
||||
"homeassistant.components.almond.*",
|
||||
"homeassistant.components.analytics.*",
|
||||
"homeassistant.components.asuswrt.*",
|
||||
"homeassistant.components.atag.*",
|
||||
"homeassistant.components.awair.*",
|
||||
"homeassistant.components.azure_event_hub.*",
|
||||
|
Loading…
Reference in New Issue
Block a user