Add type hints to get_scanner/async_get_scanner (#63836)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-10 23:42:39 +01:00 committed by GitHub
parent d76d9f9e42
commit caff3e0630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 116 additions and 24 deletions

View file

@ -10,7 +10,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.const import CONF_HOST, CONF_PASSWORD
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
DEFAULT_HOST = "192.168.178.1" DEFAULT_HOST = "192.168.178.1"
@ -22,7 +24,7 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Return the Arris device scanner.""" """Return the Arris device scanner."""
conf = config[DOMAIN] conf = config[DOMAIN]
url = f"http://{conf[CONF_HOST]}" url = f"http://{conf[CONF_HOST]}"

View file

@ -1,4 +1,6 @@
"""Support for Aruba Access Points.""" """Support for Aruba Access Points."""
from __future__ import annotations
import logging import logging
import re import re
@ -11,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__)
@ -30,7 +34,7 @@ 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 a Aruba scanner.""" """Validate the configuration and return a Aruba scanner."""
scanner = ArubaDeviceScanner(config[DOMAIN]) scanner = ArubaDeviceScanner(config[DOMAIN])

View file

@ -14,7 +14,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
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
from homeassistant.util import Throttle from homeassistant.util import Throttle
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -29,7 +31,7 @@ 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 a Bbox scanner.""" """Validate the configuration and return a Bbox scanner."""
scanner = BboxDeviceScanner(config[DOMAIN]) scanner = BboxDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for BT Home Hub 5.""" """Support for BT Home Hub 5."""
from __future__ import annotations
import logging import logging
import bthomehub5_devicelist import bthomehub5_devicelist
@ -10,7 +12,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
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__)
@ -21,7 +25,7 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Return a BT Home Hub 5 scanner if successful.""" """Return a BT Home Hub 5 scanner if successful."""
scanner = BTHomeHub5DeviceScanner(config[DOMAIN]) scanner = BTHomeHub5DeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for BT Smart Hub (Sometimes referred to as BT Home Hub 6).""" """Support for BT Smart Hub (Sometimes referred to as BT Home Hub 6)."""
from __future__ import annotations
from collections import namedtuple from collections import namedtuple
import logging import logging
@ -11,7 +13,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
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__)
@ -26,7 +30,7 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Return a BT Smart Hub scanner if successful.""" """Return a BT Smart Hub scanner if successful."""
info = config[DOMAIN] info = config[DOMAIN]
smarthub_client = BTSmartHub( smarthub_client = BTSmartHub(

View file

@ -1,4 +1,6 @@
"""Support for Cisco IOS Routers.""" """Support for Cisco IOS Routers."""
from __future__ import annotations
import logging import logging
import re import re
@ -11,7 +13,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, 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__)
@ -27,7 +31,7 @@ PLATFORM_SCHEMA = vol.All(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Validate the configuration and return a Cisco scanner.""" """Validate the configuration and return a Cisco scanner."""
scanner = CiscoDeviceScanner(config[DOMAIN]) scanner = CiscoDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Cisco Mobility Express.""" """Support for Cisco Mobility Express."""
from __future__ import annotations
import logging import logging
from ciscomobilityexpress.ciscome import CiscoMobilityExpress from ciscomobilityexpress.ciscome import CiscoMobilityExpress
@ -16,7 +18,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
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__)
@ -34,7 +38,7 @@ 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 a Cisco ME scanner.""" """Validate the configuration and return a Cisco ME scanner."""
config = config[DOMAIN] config = config[DOMAIN]

View file

@ -1,4 +1,6 @@
"""Support for ClearPass Policy Manager.""" """Support for ClearPass Policy Manager."""
from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
@ -11,7 +13,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_API_KEY, CONF_CLIENT_ID, CONF_HOST from homeassistant.const import CONF_API_KEY, CONF_CLIENT_ID, CONF_HOST
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
SCAN_INTERVAL = timedelta(seconds=120) SCAN_INTERVAL = timedelta(seconds=120)
@ -28,7 +32,7 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Initialize Scanner.""" """Initialize Scanner."""
data = { data = {

View file

@ -1,4 +1,6 @@
"""Support for DD-WRT routers.""" """Support for DD-WRT routers."""
from __future__ import annotations
from http import HTTPStatus from http import HTTPStatus
import logging import logging
import re import re
@ -18,7 +20,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
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__)
@ -42,7 +46,7 @@ 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 a DD-WRT scanner.""" """Validate the configuration and return a DD-WRT scanner."""
try: try:
return DdWrtDeviceScanner(config[DOMAIN]) return DdWrtDeviceScanner(config[DOMAIN])

View file

@ -3,6 +3,8 @@ Support to use FortiOS device like FortiGate as device tracker.
This component is part of the device_tracker platform. This component is part of the device_tracker platform.
""" """
from __future__ import annotations
import logging import logging
from awesomeversion import AwesomeVersion from awesomeversion import AwesomeVersion
@ -15,7 +17,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_TOKEN, CONF_VERIFY_SSL from homeassistant.const import CONF_HOST, CONF_TOKEN, CONF_VERIFY_SSL
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__)
DEFAULT_VERIFY_SSL = False DEFAULT_VERIFY_SSL = False
@ -30,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Validate the configuration and return a FortiOSDeviceScanner.""" """Validate the configuration and return a FortiOSDeviceScanner."""
host = config[DOMAIN][CONF_HOST] host = config[DOMAIN][CONF_HOST]
verify_ssl = config[DOMAIN][CONF_VERIFY_SSL] verify_ssl = config[DOMAIN][CONF_VERIFY_SSL]

View file

@ -1,4 +1,6 @@
"""Support for the Hitron CODA-4582U, provided by Rogers.""" """Support for the Hitron CODA-4582U, provided by Rogers."""
from __future__ import annotations
from collections import namedtuple from collections import namedtuple
from http import HTTPStatus from http import HTTPStatus
import logging import logging
@ -12,7 +14,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_TYPE, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_TYPE, 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__)
@ -28,7 +32,7 @@ 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 a Hitron CODA-4582U scanner.""" """Validate the configuration and return a Hitron CODA-4582U scanner."""
scanner = HitronCODADeviceScanner(config[DOMAIN]) scanner = HitronCODADeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Linksys Smart Wifi routers.""" """Support for Linksys Smart Wifi routers."""
from __future__ import annotations
from http import HTTPStatus from http import HTTPStatus
import logging import logging
@ -11,7 +13,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
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
DEFAULT_TIMEOUT = 10 DEFAULT_TIMEOUT = 10
@ -20,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string}) PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Validate the configuration and return a Linksys AP scanner.""" """Validate the configuration and return a Linksys AP scanner."""
try: try:
return LinksysSmartWifiDeviceScanner(config[DOMAIN]) return LinksysSmartWifiDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for OpenWRT (luci) routers.""" """Support for OpenWRT (luci) routers."""
from __future__ import annotations
import logging import logging
from openwrt_luci_rpc import OpenWrtRpc from openwrt_luci_rpc import OpenWrtRpc
@ -16,7 +18,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
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__)
@ -34,7 +38,7 @@ 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 a Luci scanner.""" """Validate the configuration and return a Luci scanner."""
scanner = LuciDeviceScanner(config[DOMAIN]) scanner = LuciDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Verizon FiOS Quantum Gateways.""" """Support for Verizon FiOS Quantum Gateways."""
from __future__ import annotations
import logging import logging
from quantum_gateway import QuantumGatewayScanner from quantum_gateway import QuantumGatewayScanner
@ -11,7 +13,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_SSL from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_SSL
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__)
@ -26,7 +30,7 @@ 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 a Quantum Gateway scanner.""" """Validate the configuration and return a Quantum Gateway scanner."""
scanner = QuantumGatewayDeviceScanner(config[DOMAIN]) scanner = QuantumGatewayDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Sky Hub.""" """Support for Sky Hub."""
from __future__ import annotations
import logging import logging
from pyskyqhub.skyq_hub import SkyQHub from pyskyqhub.skyq_hub import SkyQHub
@ -10,15 +12,19 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
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__)
PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string}) PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string})
async def async_get_scanner(hass, config): async def async_get_scanner(
hass: HomeAssistant, config: ConfigType
) -> DeviceScanner | None:
"""Return a Sky Hub scanner if successful.""" """Return a Sky Hub scanner if successful."""
host = config[DOMAIN].get(CONF_HOST, "192.168.1.254") host = config[DOMAIN].get(CONF_HOST, "192.168.1.254")
websession = async_get_clientsession(hass) websession = async_get_clientsession(hass)

View file

@ -1,4 +1,6 @@
"""Support for fetching WiFi associations through SNMP.""" """Support for fetching WiFi associations through SNMP."""
from __future__ import annotations
import binascii import binascii
import logging import logging
@ -12,7 +14,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
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
from .const import ( from .const import (
CONF_AUTH_KEY, CONF_AUTH_KEY,
@ -35,7 +39,7 @@ 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 SNMP scanner.""" """Validate the configuration and return an SNMP scanner."""
scanner = SnmpScanner(config[DOMAIN]) scanner = SnmpScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Swisscom routers (Internet-Box).""" """Support for Swisscom routers (Internet-Box)."""
from __future__ import annotations
from contextlib import suppress from contextlib import suppress
import logging import logging
@ -12,7 +14,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
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__)
@ -23,7 +27,7 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Return the Swisscom device scanner.""" """Return the Swisscom device scanner."""
scanner = SwisscomDeviceScanner(config[DOMAIN]) scanner = SwisscomDeviceScanner(config[DOMAIN])

View file

@ -19,7 +19,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
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__)
@ -68,7 +70,7 @@ ATTRIBUTE_ALIAS = {
} }
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Validate the configuration and return Synology SRM scanner.""" """Validate the configuration and return Synology SRM scanner."""
scanner = SynologySrmDeviceScanner(config[DOMAIN]) scanner = SynologySrmDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Tado Smart device trackers.""" """Support for Tado Smart device trackers."""
from __future__ import annotations
import asyncio import asyncio
from collections import namedtuple from collections import namedtuple
from datetime import timedelta from datetime import timedelta
@ -15,8 +17,10 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -34,7 +38,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Return a Tado scanner.""" """Return a Tado scanner."""
scanner = TadoDeviceScanner(hass, config[DOMAIN]) scanner = TadoDeviceScanner(hass, config[DOMAIN])
return scanner if scanner.success_init else None return scanner if scanner.success_init else None

View file

@ -1,4 +1,6 @@
"""Support for THOMSON routers.""" """Support for THOMSON routers."""
from __future__ import annotations
import logging import logging
import re import re
import telnetlib import telnetlib
@ -11,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__)
@ -34,7 +38,7 @@ 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 a THOMSON scanner.""" """Validate the configuration and return a THOMSON scanner."""
scanner = ThomsonDeviceScanner(config[DOMAIN]) scanner = ThomsonDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Tomato routers.""" """Support for Tomato routers."""
from __future__ import annotations
from http import HTTPStatus from http import HTTPStatus
import json import json
import logging import logging
@ -20,7 +22,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
) )
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
CONF_HTTP_ID = "http_id" CONF_HTTP_ID = "http_id"
@ -39,7 +43,7 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Validate the configuration and returns a Tomato scanner.""" """Validate the configuration and returns a Tomato scanner."""
return TomatoDeviceScanner(config[DOMAIN]) return TomatoDeviceScanner(config[DOMAIN])

View file

@ -13,7 +13,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP
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__)
@ -27,7 +29,9 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
) )
async def async_get_scanner(hass, config): async def async_get_scanner(
hass: HomeAssistant, config: ConfigType
) -> DeviceScanner | None:
"""Return the UPC device scanner.""" """Return the UPC device scanner."""
conf = config[DOMAIN] conf = config[DOMAIN]
session = hass.helpers.aiohttp_client.async_get_clientsession() session = hass.helpers.aiohttp_client.async_get_clientsession()

View file

@ -1,4 +1,6 @@
"""Support for Xiaomi Mi routers.""" """Support for Xiaomi Mi routers."""
from __future__ import annotations
from http import HTTPStatus from http import HTTPStatus
import logging import logging
@ -11,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__)
@ -24,7 +28,7 @@ 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 a Xiaomi Device Scanner.""" """Validate the configuration and return a Xiaomi Device Scanner."""
scanner = XiaomiDeviceScanner(config[DOMAIN]) scanner = XiaomiDeviceScanner(config[DOMAIN])

View file

@ -1,4 +1,6 @@
"""Support for Xiaomi Mi WiFi Repeater 2.""" """Support for Xiaomi Mi WiFi Repeater 2."""
from __future__ import annotations
import logging import logging
from miio import DeviceException, WifiRepeater from miio import DeviceException, WifiRepeater
@ -10,7 +12,9 @@ from homeassistant.components.device_tracker import (
DeviceScanner, DeviceScanner,
) )
from homeassistant.const import CONF_HOST, CONF_TOKEN from homeassistant.const import CONF_HOST, CONF_TOKEN
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__)
@ -22,7 +26,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
def get_scanner(hass, config): def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Return a Xiaomi MiIO device scanner.""" """Return a Xiaomi MiIO device scanner."""
scanner = None scanner = None
host = config[DOMAIN][CONF_HOST] host = config[DOMAIN][CONF_HOST]