Component asuswrt: Improve get_bridge parameters typing in asuswrt (#154540)

This commit is contained in:
Magnus
2025-10-17 16:00:56 +02:00
committed by GitHub
parent 03bc698936
commit 36f4723f6e
3 changed files with 9 additions and 9 deletions

View File

@@ -125,7 +125,9 @@ class AsusWrtBridge(ABC):
@staticmethod @staticmethod
def get_bridge( def get_bridge(
hass: HomeAssistant, conf: dict[str, Any], options: dict[str, Any] | None = None hass: HomeAssistant,
conf: dict[str, str | int],
options: dict[str, str | bool | int] | None = None,
) -> AsusWrtBridge: ) -> AsusWrtBridge:
"""Get Bridge instance.""" """Get Bridge instance."""
if conf[CONF_PROTOCOL] in (PROTOCOL_HTTPS, PROTOCOL_HTTP): if conf[CONF_PROTOCOL] in (PROTOCOL_HTTPS, PROTOCOL_HTTP):

View File

@@ -175,12 +175,12 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
) )
async def _async_check_connection( async def _async_check_connection(
self, user_input: dict[str, Any] self, user_input: dict[str, str | int]
) -> tuple[str, str | None]: ) -> tuple[str, str | None]:
"""Attempt to connect the AsusWrt router.""" """Attempt to connect the AsusWrt router."""
api: AsusWrtBridge api: AsusWrtBridge
host: str = user_input[CONF_HOST] host = user_input[CONF_HOST]
protocol = user_input[CONF_PROTOCOL] protocol = user_input[CONF_PROTOCOL]
error: str | None = None error: str | None = None

View File

@@ -176,7 +176,7 @@ class AsusWrtRouter:
self._on_close: list[Callable] = [] self._on_close: list[Callable] = []
self._options: dict[str, Any] = { self._options: dict[str, str | bool | int] = {
CONF_DNSMASQ: DEFAULT_DNSMASQ, CONF_DNSMASQ: DEFAULT_DNSMASQ,
CONF_INTERFACE: DEFAULT_INTERFACE, CONF_INTERFACE: DEFAULT_INTERFACE,
CONF_REQUIRE_IP: True, CONF_REQUIRE_IP: True,
@@ -299,12 +299,10 @@ class AsusWrtRouter:
_LOGGER.warning("Reconnected to ASUS router %s", self.host) _LOGGER.warning("Reconnected to ASUS router %s", self.host)
self._connected_devices = len(wrt_devices) self._connected_devices = len(wrt_devices)
consider_home: int = self._options.get( consider_home = int(
CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME.total_seconds() self._options.get(CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME.total_seconds())
)
track_unknown: bool = self._options.get(
CONF_TRACK_UNKNOWN, DEFAULT_TRACK_UNKNOWN
) )
track_unknown = self._options.get(CONF_TRACK_UNKNOWN, DEFAULT_TRACK_UNKNOWN)
for device_mac, device in self._devices.items(): for device_mac, device in self._devices.items():
dev_info = wrt_devices.pop(device_mac, None) dev_info = wrt_devices.pop(device_mac, None)