mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Add type hint to get_scanner in ubus (#63856)
This commit is contained in:
parent
edc4d3bb6e
commit
d76d9f9e42
@ -1,4 +1,5 @@
|
|||||||
"""Support for OpenWRT (ubus) routers."""
|
"""Support for OpenWRT (ubus) routers."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
@ -12,7 +13,9 @@ from homeassistant.components.device_tracker import (
|
|||||||
DeviceScanner,
|
DeviceScanner,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -32,9 +35,10 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_scanner(hass, config):
|
def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
|
||||||
"""Validate the configuration and return an ubus scanner."""
|
"""Validate the configuration and return an ubus scanner."""
|
||||||
dhcp_sw = config[DOMAIN][CONF_DHCP_SOFTWARE]
|
dhcp_sw = config[DOMAIN][CONF_DHCP_SOFTWARE]
|
||||||
|
scanner: DeviceScanner
|
||||||
if dhcp_sw == "dnsmasq":
|
if dhcp_sw == "dnsmasq":
|
||||||
scanner = DnsmasqUbusDeviceScanner(config[DOMAIN])
|
scanner = DnsmasqUbusDeviceScanner(config[DOMAIN])
|
||||||
elif dhcp_sw == "odhcpd":
|
elif dhcp_sw == "odhcpd":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user