Add missing argument type hints to component tests (#119671)

This commit is contained in:
epenet 2024-06-14 09:26:46 +02:00 committed by GitHub
parent 83b97d3218
commit 3e9d25f81d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 135 additions and 67 deletions

View File

@ -1,11 +1,12 @@
"""Tests for AccuWeather."""
from homeassistant.components.accuweather.const import DOMAIN
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the AccuWeather integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,

View File

@ -1,8 +1,10 @@
"""Tests for Airly."""
from homeassistant.components.airly.const import DOMAIN
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, load_fixture
from tests.test_util.aiohttp import AiohttpClientMocker
API_NEAREST_URL = "https://airapi.airly.eu/v2/measurements/nearest?lat=123.000000&lng=456.000000&maxDistanceKM=5.000000"
API_POINT_URL = (
@ -14,7 +16,9 @@ HEADERS = {
}
async def init_integration(hass, aioclient_mock) -> MockConfigEntry:
async def init_integration(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> MockConfigEntry:
"""Set up the Airly integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,

View File

@ -52,7 +52,13 @@ GENERIC_BLUETOOTH_SERVICE_INFO = BluetoothServiceInfo(
class MyCoordinator(PassiveBluetoothDataUpdateCoordinator):
"""An example coordinator that subclasses PassiveBluetoothDataUpdateCoordinator."""
def __init__(self, hass, logger, device_id, mode) -> None:
def __init__(
self,
hass: HomeAssistant,
logger: logging.Logger,
device_id: str,
mode: BluetoothScanningMode,
) -> None:
"""Initialize the coordinator."""
super().__init__(hass, logger, device_id, mode)
self.data: dict[str, Any] = {}

View File

@ -25,7 +25,7 @@ def get_device_id(mac: str) -> tuple[str, str]:
return (BLUETOOTH_DOMAIN, mac)
async def _async_setup_bthome_device(hass, mac: str):
async def _async_setup_bthome_device(hass: HomeAssistant, mac: str) -> MockConfigEntry:
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=mac,

View File

@ -20,7 +20,7 @@ from homeassistant.components.device_tracker import (
SourceType,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import GPSType
from homeassistant.helpers.typing import ConfigType, GPSType
from homeassistant.loader import bind_hass
from tests.common import MockPlatform, mock_platform
@ -143,7 +143,9 @@ def mock_legacy_device_tracker_setup(
) -> None:
"""Mock legacy device tracker platform setup."""
async def _async_get_scanner(hass, config) -> MockScanner:
async def _async_get_scanner(
hass: HomeAssistant, config: ConfigType
) -> MockScanner:
"""Return the test scanner."""
return legacy_device_scanner

View File

@ -7,6 +7,7 @@ from pydexcom import GlucoseReading
from homeassistant.components.dexcom.const import CONF_SERVER, DOMAIN, SERVER_US
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, load_fixture
@ -19,7 +20,7 @@ CONFIG = {
GLUCOSE_READING = GlucoseReading(json.loads(load_fixture("data.json", "dexcom")))
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Dexcom integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,

View File

@ -38,7 +38,7 @@ NEW_DEVICE_LOCATION: Final = "http://192.88.99.7" + "/dmr_description.xml"
@pytest.fixture
async def setup_media_source(hass) -> None:
async def setup_media_source(hass: HomeAssistant) -> None:
"""Set up media source."""
assert await async_setup_component(hass, "media_source", {})

View File

@ -52,7 +52,7 @@ def esphome_mock_async_zeroconf(mock_async_zeroconf: MagicMock) -> None:
@pytest.fixture(autouse=True)
async def load_homeassistant(hass) -> None:
async def load_homeassistant(hass: HomeAssistant) -> None:
"""Load the homeassistant integration."""
assert await async_setup_component(hass, "homeassistant", {})
@ -63,7 +63,7 @@ def mock_tts(mock_tts_cache_dir: Path) -> None:
@pytest.fixture
def mock_config_entry(hass) -> MockConfigEntry:
def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry:
"""Return the default mocked config entry."""
config_entry = MockConfigEntry(
title="ESPHome Device",

View File

@ -25,12 +25,13 @@ from homeassistant.const import (
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
from homeassistant.core import HomeAssistant
from tests.common import MockEntity
async def async_turn_on(
hass,
hass: HomeAssistant,
entity_id=ENTITY_MATCH_ALL,
percentage: int | None = None,
preset_mode: str | None = None,
@ -50,7 +51,7 @@ async def async_turn_on(
await hass.async_block_till_done()
async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL) -> None:
async def async_turn_off(hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL) -> None:
"""Turn all or specified fan off."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
@ -59,7 +60,7 @@ async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL) -> None:
async def async_oscillate(
hass, entity_id=ENTITY_MATCH_ALL, should_oscillate: bool = True
hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, should_oscillate: bool = True
) -> None:
"""Set oscillation on all or specified fan."""
data = {
@ -76,7 +77,7 @@ async def async_oscillate(
async def async_set_preset_mode(
hass, entity_id=ENTITY_MATCH_ALL, preset_mode: str | None = None
hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, preset_mode: str | None = None
) -> None:
"""Set preset mode for all or specified fan."""
data = {
@ -90,7 +91,7 @@ async def async_set_preset_mode(
async def async_set_percentage(
hass, entity_id=ENTITY_MATCH_ALL, percentage: int | None = None
hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, percentage: int | None = None
) -> None:
"""Set percentage for all or specified fan."""
data = {
@ -104,7 +105,7 @@ async def async_set_percentage(
async def async_increase_speed(
hass, entity_id=ENTITY_MATCH_ALL, percentage_step: int | None = None
hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, percentage_step: int | None = None
) -> None:
"""Increase speed for all or specified fan."""
data = {
@ -121,7 +122,7 @@ async def async_increase_speed(
async def async_decrease_speed(
hass, entity_id=ENTITY_MATCH_ALL, percentage_step: int | None = None
hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, percentage_step: int | None = None
) -> None:
"""Decrease speed for all or specified fan."""
data = {
@ -138,7 +139,7 @@ async def async_decrease_speed(
async def async_set_direction(
hass, entity_id=ENTITY_MATCH_ALL, direction: str | None = None
hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, direction: str | None = None
) -> None:
"""Set direction for all or specified fan."""
data = {

View File

@ -10,6 +10,7 @@ import pytest
from typing_extensions import Generator
from homeassistant.components.freedompro.const import DOMAIN
from homeassistant.core import HomeAssistant
from .const import DEVICES, DEVICES_STATE
@ -45,7 +46,7 @@ def mock_freedompro():
@pytest.fixture
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Freedompro integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -64,7 +65,7 @@ async def init_integration(hass) -> MockConfigEntry:
@pytest.fixture
async def init_integration_no_state(hass) -> MockConfigEntry:
async def init_integration_no_state(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Freedompro integration in Home Assistant without state."""
entry = MockConfigEntry(
domain=DOMAIN,

View File

@ -4,6 +4,7 @@ import json
from unittest.mock import patch
from homeassistant.components.gios.const import DOMAIN
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, load_fixture
@ -14,7 +15,7 @@ STATIONS = [
async def init_integration(
hass, incomplete_data=False, invalid_indexes=False
hass: HomeAssistant, incomplete_data=False, invalid_indexes=False
) -> MockConfigEntry:
"""Set up the GIOS integration in Home Assistant."""
entry = MockConfigEntry(

View File

@ -1,9 +1,13 @@
"""Tests for the IMGW-PIB integration."""
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def init_integration(hass, config_entry: MockConfigEntry) -> MockConfigEntry:
async def init_integration(
hass: HomeAssistant, config_entry: MockConfigEntry
) -> MockConfigEntry:
"""Set up the IMGW-PIB integration in Home Assistant."""
config_entry.add_to_hass(hass)

View File

@ -11,13 +11,14 @@ from homeassistant.const import (
CONF_SSL,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from .util import MockConnection
from tests.common import MockConfigEntry
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Kodi integration in Home Assistant."""
entry_data = {
CONF_NAME: "name",

View File

@ -3,13 +3,14 @@
from homeassistant.components import scene, switch
from homeassistant.components.litejet import DOMAIN
from homeassistant.const import CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from tests.common import MockConfigEntry
async def async_init_integration(
hass, use_switch=False, use_scene=False
hass: HomeAssistant, use_switch: bool = False, use_scene: bool = False
) -> MockConfigEntry:
"""Set up the LiteJet integration in Home Assistant."""

View File

@ -144,7 +144,7 @@ async def test_setup_cloudhook_from_entry_in_bridge(
async def test_unload_entry(
hass, integration: MockConfigEntry, lock: loqed.Lock
hass: HomeAssistant, integration: MockConfigEntry, lock: loqed.Lock
) -> None:
"""Test successful unload of entry."""
@ -157,7 +157,7 @@ async def test_unload_entry(
async def test_unload_entry_fails(
hass, integration: MockConfigEntry, lock: loqed.Lock
hass: HomeAssistant, integration: MockConfigEntry, lock: loqed.Lock
) -> None:
"""Test unsuccessful unload of entry."""
lock.deleteWebhook = AsyncMock(side_effect=Exception)

View File

@ -9,6 +9,7 @@ from homeassistant.components.lutron_caseta.const import (
CONF_KEYFILE,
)
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@ -83,7 +84,7 @@ _LEAP_DEVICE_TYPES = {
}
async def async_setup_integration(hass, mock_bridge) -> MockConfigEntry:
async def async_setup_integration(hass: HomeAssistant, mock_bridge) -> MockConfigEntry:
"""Set up a mock bridge."""
mock_entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_MOCK_DATA)
mock_entry.add_to_hass(hass)

View File

@ -4,11 +4,14 @@ from unittest.mock import patch
from homeassistant.components.met.const import CONF_TRACK_HOME, DOMAIN
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def init_integration(hass, track_home=False) -> MockConfigEntry:
async def init_integration(
hass: HomeAssistant, track_home: bool = False
) -> MockConfigEntry:
"""Set up the Met integration in Home Assistant."""
entry_data = {
CONF_NAME: "test",

View File

@ -4,11 +4,12 @@ from unittest.mock import patch
from homeassistant.components.met_eireann.const import DOMAIN
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Met Éireann integration in Home Assistant."""
entry_data = {
CONF_NAME: "test",

View File

@ -74,7 +74,7 @@ _LOGGER = logging.getLogger(__name__)
@pytest.fixture(autouse=True)
async def setup_media_source(hass) -> None:
async def setup_media_source(hass: HomeAssistant) -> None:
"""Set up media source."""
assert await async_setup_component(hass, "media_source", {})

View File

@ -3,6 +3,7 @@
from unittest.mock import AsyncMock, Mock, patch
from homeassistant.components.nam.const import DOMAIN
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, load_json_object_fixture
@ -12,7 +13,9 @@ INCOMPLETE_NAM_DATA = {
}
async def init_integration(hass, co2_sensor=True) -> MockConfigEntry:
async def init_integration(
hass: HomeAssistant, co2_sensor: bool = True
) -> MockConfigEntry:
"""Set up the Nettigo Air Monitor integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,

View File

@ -12,6 +12,7 @@ import aiohttp
from freezegun import freeze_time
from google_nest_sdm.event import EventMessage
import pytest
from typing_extensions import Generator
from homeassistant.components import camera
from homeassistant.components.camera import STATE_IDLE, STATE_STREAMING, StreamType
@ -149,7 +150,7 @@ def make_stream_url_response(
@pytest.fixture
async def mock_create_stream(hass) -> Mock:
async def mock_create_stream(hass: HomeAssistant) -> Generator[AsyncMock]:
"""Fixture to mock out the create stream call."""
assert await async_setup_component(hass, "stream", {})
with patch(

View File

@ -95,7 +95,7 @@ def platforms() -> list[str]:
@pytest.fixture(autouse=True)
async def setup_components(hass) -> None:
async def setup_components(hass: HomeAssistant) -> None:
"""Fixture to initialize the integration."""
await async_setup_component(hass, "media_source", {})

View File

@ -8,6 +8,7 @@ from py_nightscout.models import SGV, ServerStatus
from homeassistant.components.nightscout.const import DOMAIN
from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@ -30,7 +31,7 @@ SERVER_STATUS_STATUS_ONLY = ServerStatus.new_from_json_dict(
)
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Nightscout integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -53,7 +54,7 @@ async def init_integration(hass) -> MockConfigEntry:
return entry
async def init_integration_unavailable(hass) -> MockConfigEntry:
async def init_integration_unavailable(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Nightscout integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,
@ -76,7 +77,7 @@ async def init_integration_unavailable(hass) -> MockConfigEntry:
return entry
async def init_integration_empty_response(hass) -> MockConfigEntry:
async def init_integration_empty_response(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the Nightscout integration in Home Assistant."""
entry = MockConfigEntry(
domain=DOMAIN,

View File

@ -22,7 +22,7 @@ ENTRY_DATA: dict[str, Any] = {
}
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the NINA integration in Home Assistant."""
with patch(

View File

@ -13,6 +13,7 @@ from homeassistant.const import (
CONF_USERNAME,
CONF_VERIFY_SSL,
)
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@ -59,7 +60,7 @@ MOCK_HISTORY = [
]
async def init_integration(hass) -> MockConfigEntry:
async def init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Set up the NZBGet integration in Home Assistant."""
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG, options=ENTRY_OPTIONS)
entry.add_to_hass(hass)

View File

@ -14,6 +14,8 @@ from pyoctoprintapi import (
from homeassistant.components.octoprint import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
from tests.common import MockConfigEntry
@ -33,11 +35,11 @@ DEFAULT_PRINTER = {
async def init_integration(
hass,
platform,
hass: HomeAssistant,
platform: Platform,
printer: dict[str, Any] | UndefinedType | None = UNDEFINED,
job: dict[str, Any] | None = None,
):
) -> None:
"""Set up the octoprint integration in Home Assistant."""
printer_info: OctoprintPrinterInfo | None = None
if printer is UNDEFINED:

View File

@ -18,6 +18,7 @@ from homeassistant.components.onvif.models import (
WebHookManagerState,
)
from homeassistant.const import HTTP_DIGEST_AUTHENTICATION
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@ -158,7 +159,7 @@ def setup_mock_device(mock_device, capabilities=None):
async def setup_onvif_integration(
hass,
hass: HomeAssistant,
config=None,
options=None,
unique_id=MAC,

View File

@ -290,7 +290,9 @@ BAD_JSON_SUFFIX = "** and it ends here ^^"
@pytest.fixture
def setup_comp(
hass, mock_device_tracker_conf: list[Device], mqtt_mock: MqttMockHAClient
hass: HomeAssistant,
mock_device_tracker_conf: list[Device],
mqtt_mock: MqttMockHAClient,
):
"""Initialize components."""
hass.loop.run_until_complete(async_setup_component(hass, "device_tracker", {}))

View File

@ -8,6 +8,7 @@ from typing_extensions import Generator
from homeassistant.components.plex.const import DOMAIN, PLEX_SERVER_CONFIG, SERVERS
from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from .const import DEFAULT_DATA, DEFAULT_OPTIONS, PLEX_DIRECT_URL
from .helpers import websocket_connected
@ -546,7 +547,7 @@ def mock_plex_calls(
@pytest.fixture
def setup_plex_server(
hass,
hass: HomeAssistant,
entry,
livetv_sessions,
mock_websocket,

View File

@ -270,7 +270,7 @@ async def test_setup_when_certificate_changed(
assert old_entry.data[const.PLEX_SERVER_CONFIG][CONF_URL] == new_url
async def test_tokenless_server(hass, entry, setup_plex_server) -> None:
async def test_tokenless_server(hass: HomeAssistant, entry, setup_plex_server) -> None:
"""Test setup with a server with token auth disabled."""
TOKENLESS_DATA = copy.deepcopy(DEFAULT_DATA)
TOKENLESS_DATA[const.PLEX_SERVER_CONFIG].pop(CONF_TOKEN, None)

View File

@ -16,12 +16,16 @@ from tesla_powerwall import (
SiteMasterResponse,
)
from homeassistant.core import HomeAssistant
from tests.common import load_fixture
MOCK_GATEWAY_DIN = "111-0----2-000000000FFA"
async def _mock_powerwall_with_fixtures(hass, empty_meters: bool = False) -> MagicMock:
async def _mock_powerwall_with_fixtures(
hass: HomeAssistant, empty_meters: bool = False
) -> MagicMock:
"""Mock data used to build powerwall state."""
async with asyncio.TaskGroup() as tg:
meters_file = "meters_empty.json" if empty_meters else "meters.json"

View File

@ -10,6 +10,7 @@ from RFXtrx import Connect, RFXtrxTransport
from homeassistant.components import rfxtrx
from homeassistant.components.rfxtrx import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.util.dt import utcnow
from tests.common import MockConfigEntry, async_fire_time_changed
@ -37,7 +38,7 @@ def create_rfx_test_cfg(
async def setup_rfx_test_cfg(
hass,
hass: HomeAssistant,
device="abcd",
automatic_add=False,
devices: dict[str, dict] | None = None,

View File

@ -39,7 +39,7 @@ async def webrtc_server() -> None:
@pytest.fixture
async def mock_camera(hass) -> AsyncGenerator[None]:
async def mock_camera(hass: HomeAssistant) -> AsyncGenerator[None]:
"""Initialize a demo camera platform."""
assert await async_setup_component(
hass, "camera", {camera.DOMAIN: {"platform": "demo"}}

View File

@ -139,7 +139,7 @@ async def entry_with_additional_account_config(hass, flow_at_add_account_step):
)
async def setup_sia(hass, config_entry: MockConfigEntry):
async def setup_sia(hass: HomeAssistant, config_entry: MockConfigEntry):
"""Add mock config to HASS."""
assert await async_setup_component(hass, DOMAIN, {})
config_entry.add_to_hass(hass)

View File

@ -55,7 +55,9 @@ from tests.components.light.conftest import mock_light_profiles # noqa: F401
COMPONENT_PREFIX = "homeassistant.components.smartthings."
async def setup_platform(hass, platform: str, *, devices=None, scenes=None):
async def setup_platform(
hass: HomeAssistant, platform: str, *, devices=None, scenes=None
):
"""Set up the SmartThings platform and prerequisites."""
hass.config.components.add(DOMAIN)
config_entry = MockConfigEntry(

View File

@ -46,7 +46,7 @@ HLS_CONFIG = {
@pytest.fixture
async def setup_component(hass) -> None:
async def setup_component(hass: HomeAssistant) -> None:
"""Test fixture to setup the stream component."""
await async_setup_component(hass, "stream", HLS_CONFIG)

View File

@ -13,6 +13,7 @@ from unittest.mock import MagicMock, patch
from homeassistant.bootstrap import async_setup_component
from homeassistant.components import system_log
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import ConfigType
from tests.common import async_capture_events
from tests.typing import WebSocketGenerator
@ -89,7 +90,9 @@ class WatchLogErrorHandler(system_log.LogErrorHandler):
self.watch_event.set()
async def async_setup_system_log(hass, config) -> WatchLogErrorHandler:
async def async_setup_system_log(
hass: HomeAssistant, config: ConfigType
) -> WatchLogErrorHandler:
"""Set up the system_log component."""
WatchLogErrorHandler.instances = []
with patch(

View File

@ -65,7 +65,7 @@ def fixture_discovery():
@pytest.fixture(name="mock_device_registry")
def fixture_device_registry(hass, device_registry: dr.DeviceRegistry):
def fixture_device_registry(hass: HomeAssistant, device_registry: dr.DeviceRegistry):
"""Mock device registry."""
config_entry = MockConfigEntry(domain="something_else")
config_entry.add_to_hass(hass)
@ -139,7 +139,9 @@ def fixture_known_wireless_clients() -> list[str]:
@pytest.fixture(autouse=True, name="mock_wireless_client_storage")
def fixture_wireless_client_storage(hass_storage, known_wireless_clients: list[str]):
def fixture_wireless_client_storage(
hass_storage: dict[str, Any], known_wireless_clients: list[str]
):
"""Mock the known wireless storage."""
data: dict[str, list[str]] = (
{"wireless_clients": known_wireless_clients} if known_wireless_clients else {}

View File

@ -1,9 +1,13 @@
"""Tests for the V2C integration."""
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def init_integration(hass, config_entry: MockConfigEntry) -> MockConfigEntry:
async def init_integration(
hass: HomeAssistant, config_entry: MockConfigEntry
) -> MockConfigEntry:
"""Set up the V2C integration in Home Assistant."""
config_entry.add_to_hass(hass)

View File

@ -131,7 +131,7 @@ def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
@pytest.fixture
def mock_config_entry(hass) -> tuple[MockConfigEntry, list[ValveEntity]]:
def mock_config_entry(hass: HomeAssistant) -> tuple[MockConfigEntry, list[ValveEntity]]:
"""Mock a config entry which sets up a couple of valve entities."""
entities = [
MockBinaryValveEntity(

View File

@ -17,7 +17,7 @@ from tests.common import MockConfigEntry
@pytest.fixture(autouse=True)
async def load_homeassistant(hass) -> None:
async def load_homeassistant(hass: HomeAssistant) -> None:
"""Load the homeassistant integration."""
assert await async_setup_component(hass, "homeassistant", {})

View File

@ -138,7 +138,7 @@ async def test_setup_success(hass: HomeAssistant) -> None:
assert hass.states.get(ZONE_1_ID) is not None
async def _setup_ws66i(hass, ws66i) -> MockConfigEntry:
async def _setup_ws66i(hass: HomeAssistant, ws66i) -> MockConfigEntry:
config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG, options=MOCK_DEFAULT_OPTIONS
)
@ -154,7 +154,7 @@ async def _setup_ws66i(hass, ws66i) -> MockConfigEntry:
return config_entry
async def _setup_ws66i_with_options(hass, ws66i) -> MockConfigEntry:
async def _setup_ws66i_with_options(hass: HomeAssistant, ws66i) -> MockConfigEntry:
config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG, options=MOCK_OPTIONS
)

View File

@ -35,7 +35,9 @@ def calls(hass: HomeAssistant) -> list[ServiceCall]:
return async_mock_service(hass, "test", "automation")
async def _async_setup_xiaomi_device(hass, mac: str, data: Any | None = None):
async def _async_setup_xiaomi_device(
hass: HomeAssistant, mac: str, data: Any | None = None
):
config_entry = MockConfigEntry(domain=DOMAIN, unique_id=mac, data=data)
config_entry.add_to_hass(hass)

View File

@ -14,6 +14,7 @@ from homeassistant.components.zha.core.helpers import (
async_get_zha_config_value,
get_zha_gateway,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
import homeassistant.util.dt as dt_util
@ -102,7 +103,9 @@ def send_attribute_report(hass, cluster, attrid, value):
return send_attributes_report(hass, cluster, {attrid: value})
async def send_attributes_report(hass, cluster: zigpy.zcl.Cluster, attributes: dict):
async def send_attributes_report(
hass: HomeAssistant, cluster: zigpy.zcl.Cluster, attributes: dict
):
"""Cause the sensor to receive an attribute report from the network.
This is to simulate the normal device communication that happens when a

View File

@ -29,6 +29,7 @@ import homeassistant.components.zha.core.const as zha_const
import homeassistant.components.zha.core.device as zha_core_device
from homeassistant.components.zha.core.gateway import ZHAGateway
from homeassistant.components.zha.core.helpers import get_zha_gateway
from homeassistant.core import HomeAssistant
from homeassistant.helpers import restore_state
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util
@ -198,7 +199,7 @@ async def zigpy_app_controller():
@pytest.fixture(name="config_entry")
async def config_entry_fixture(hass) -> MockConfigEntry:
async def config_entry_fixture() -> MockConfigEntry:
"""Fixture representing a config entry."""
return MockConfigEntry(
version=3,
@ -243,7 +244,9 @@ def mock_zigpy_connect(
@pytest.fixture
def setup_zha(
hass, config_entry: MockConfigEntry, mock_zigpy_connect: ControllerApplication
hass: HomeAssistant,
config_entry: MockConfigEntry,
mock_zigpy_connect: ControllerApplication,
):
"""Set up ZHA component."""
zha_config = {zha_const.CONF_ENABLE_QUIRKS: False}
@ -395,7 +398,7 @@ def zha_device_joined_restored(request: pytest.FixtureRequest):
@pytest.fixture
def zha_device_mock(
hass, config_entry, zigpy_device_mock
hass: HomeAssistant, config_entry, zigpy_device_mock
) -> Callable[..., zha_core_device.ZHADevice]:
"""Return a ZHA Device factory."""

View File

@ -493,7 +493,7 @@ async def test_group_probe_cleanup_called(
async def test_quirks_v2_entity_discovery(
hass,
hass: HomeAssistant,
zigpy_device_mock,
zha_device_joined,
) -> None:
@ -561,7 +561,7 @@ async def test_quirks_v2_entity_discovery(
async def test_quirks_v2_entity_discovery_e1_curtain(
hass,
hass: HomeAssistant,
zigpy_device_mock,
zha_device_joined,
) -> None:

View File

@ -1466,7 +1466,11 @@ async def async_test_off_from_hass(hass, cluster, entity_id):
async def async_test_level_on_off_from_hass(
hass, on_off_cluster, level_cluster, entity_id, expected_default_transition: int = 0
hass: HomeAssistant,
on_off_cluster,
level_cluster,
entity_id,
expected_default_transition: int = 0,
):
"""Test on off functionality from hass."""