Update pylint plugin to validate `_async_has_devices` (#66512)
parent
8456c6416e
commit
ab67ba20f5
|
@ -102,7 +102,7 @@ components: &components
|
|||
# Testing related files that affect the whole test/linting suite
|
||||
tests: &tests
|
||||
- codecov.yaml
|
||||
- pylint/*
|
||||
- pylint/**
|
||||
- requirements_test_pre_commit.txt
|
||||
- requirements_test.txt
|
||||
- tests/auth/**
|
||||
|
|
|
@ -9,6 +9,7 @@ from bleak.backends.device import BLEDevice
|
|||
from bleak.backends.scanner import AdvertisementData
|
||||
from fjaraskupan import UUID_SERVICE, device_filter
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.config_entry_flow import register_discovery_flow
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -16,7 +17,7 @@ from .const import DOMAIN
|
|||
CONST_WAIT_TIME = 5.0
|
||||
|
||||
|
||||
async def _async_has_devices(hass) -> bool:
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
|
||||
event = asyncio.Event()
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
"""Config flow for Gree."""
|
||||
from greeclimate.discovery import Discovery
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
|
||||
from .const import DISCOVERY_TIMEOUT, DOMAIN
|
||||
|
||||
|
||||
async def _async_has_devices(hass) -> bool:
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
gree_discovery = Discovery(DISCOVERY_TIMEOUT)
|
||||
devices = await gree_discovery.scan(wait_for=DISCOVERY_TIMEOUT)
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
"""Config flow for Hisense AEH-W4A1 integration."""
|
||||
from pyaehw4a1.aehw4a1 import AehW4a1
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def _async_has_devices(hass):
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
aehw4a1_ip_addresses = await AehW4a1().discovery()
|
||||
return len(aehw4a1_ip_addresses) > 0
|
||||
|
|
|
@ -3,4 +3,6 @@ from homeassistant.helpers import config_entry_flow
|
|||
|
||||
from .const import DOMAIN
|
||||
|
||||
config_entry_flow.register_discovery_flow(DOMAIN, "Home Assistant iOS", lambda *_: True)
|
||||
config_entry_flow.register_discovery_flow(
|
||||
DOMAIN, "Home Assistant iOS", lambda hass: True
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
|||
|
||||
from async_timeout import timeout
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -16,7 +16,7 @@ from .discovery import async_start_discovery_service, async_stop_discovery_servi
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def _async_has_devices(hass):
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
|
||||
controller_ready = asyncio.Event()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import logging
|
|||
|
||||
import pykulersky
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -10,7 +11,7 @@ from .const import DOMAIN
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def _async_has_devices(hass) -> bool:
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
# Check if there are any devices that can be discovered in the network.
|
||||
try:
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
"""Config flow flow LIFX."""
|
||||
import aiolifx
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def _async_has_devices(hass):
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
lifx_ip_addresses = await aiolifx.LifxScan(hass.loop).scan()
|
||||
return len(lifx_ip_addresses) > 0
|
||||
|
|
|
@ -3,6 +3,7 @@ import logging
|
|||
|
||||
import pyzerproc
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -10,7 +11,7 @@ from .const import DOMAIN
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def _async_has_devices(hass) -> bool:
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
try:
|
||||
devices = await pyzerproc.discover()
|
||||
|
|
|
@ -44,6 +44,8 @@ _MODULE_FILTERS: dict[str, re.Pattern] = {
|
|||
"device_tracker": re.compile(r"^homeassistant\.components\.\w+\.(device_tracker)$"),
|
||||
# diagnostics matches only in the package root (diagnostics.py)
|
||||
"diagnostics": re.compile(r"^homeassistant\.components\.\w+\.(diagnostics)$"),
|
||||
# config_flow matches only in the package root (config_flow.py)
|
||||
"config_flow": re.compile(r"^homeassistant\.components\.\w+\.(config_flow)$")
|
||||
}
|
||||
|
||||
_METHOD_MATCH: list[TypeHintMatch] = [
|
||||
|
@ -192,6 +194,14 @@ _METHOD_MATCH: list[TypeHintMatch] = [
|
|||
},
|
||||
return_type=UNDEFINED,
|
||||
),
|
||||
TypeHintMatch(
|
||||
module_filter=_MODULE_FILTERS["config_flow"],
|
||||
function_name="_async_has_devices",
|
||||
arg_types={
|
||||
0: "HomeAssistant",
|
||||
},
|
||||
return_type="bool",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue