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