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