Adjust Generator type hints in tests (#121013)

This commit is contained in:
epenet
2024-07-02 14:12:02 +02:00
committed by GitHub
parent bd234db48f
commit faf43ed4c7
6 changed files with 10 additions and 12 deletions

View File

@@ -4,7 +4,6 @@ from asyncio import AbstractEventLoop
from collections.abc import Generator
from contextlib import suppress
import os
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
@@ -19,7 +18,7 @@ from tests.common import async_capture_events
@pytest.fixture
def iid_storage(hass):
def iid_storage(hass: HomeAssistant) -> Generator[AccessoryIIDStorage]:
"""Mock the iid storage."""
with patch.object(AccessoryIIDStorage, "_async_schedule_save"):
yield AccessoryIIDStorage(hass, "")
@@ -28,7 +27,7 @@ def iid_storage(hass):
@pytest.fixture
def run_driver(
hass: HomeAssistant, event_loop: AbstractEventLoop, iid_storage: AccessoryIIDStorage
) -> Generator[HomeDriver, Any, None]:
) -> Generator[HomeDriver]:
"""Return a custom AccessoryDriver instance for HomeKit accessory init.
This mock does not mock async_stop, so the driver will not be stopped
@@ -57,7 +56,7 @@ def run_driver(
@pytest.fixture
def hk_driver(
hass: HomeAssistant, event_loop: AbstractEventLoop, iid_storage: AccessoryIIDStorage
) -> Generator[HomeDriver, Any, None]:
) -> Generator[HomeDriver]:
"""Return a custom AccessoryDriver instance for HomeKit accessory init."""
with (
patch("pyhap.accessory_driver.AsyncZeroconf"),
@@ -89,7 +88,7 @@ def mock_hap(
event_loop: AbstractEventLoop,
iid_storage: AccessoryIIDStorage,
mock_zeroconf: MagicMock,
) -> Generator[HomeDriver, Any, None]:
) -> Generator[HomeDriver]:
"""Return a custom AccessoryDriver instance for HomeKit accessory init."""
with (
patch("pyhap.accessory_driver.AsyncZeroconf"),
@@ -128,7 +127,7 @@ def events(hass):
@pytest.fixture
def demo_cleanup(hass):
def demo_cleanup(hass: HomeAssistant) -> Generator[None]:
"""Clean up device tracker demo file."""
yield
with suppress(FileNotFoundError):