From cddb057eaedefe91ff215d924e1814bc4e9050e5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 22 May 2024 09:34:17 +0200 Subject: [PATCH] Adjust conftest type hints (#117900) --- tests/components/conftest.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/components/conftest.py b/tests/components/conftest.py index bde8cad5ea4..5e480383513 100644 --- a/tests/components/conftest.py +++ b/tests/components/conftest.py @@ -1,5 +1,7 @@ """Fixtures for component testing.""" +from __future__ import annotations + from collections.abc import Callable, Generator from typing import TYPE_CHECKING, Any from unittest.mock import MagicMock, patch @@ -9,13 +11,12 @@ import pytest from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant -from tests.components.conversation import MockAgent - if TYPE_CHECKING: - from tests.components.device_tracker.common import MockScanner - from tests.components.light.common import MockLight - from tests.components.sensor.common import MockSensor - from tests.components.switch.common import MockSwitch + from .conversation import MockAgent + from .device_tracker.common import MockScanner + from .light.common import MockLight + from .sensor.common import MockSensor + from .switch.common import MockSwitch @pytest.fixture(scope="session", autouse=True) @@ -125,7 +126,7 @@ def prevent_ffmpeg_subprocess() -> Generator[None, None, None]: @pytest.fixture -def mock_light_entities() -> list["MockLight"]: +def mock_light_entities() -> list[MockLight]: """Return mocked light entities.""" from tests.components.light.common import MockLight @@ -137,7 +138,7 @@ def mock_light_entities() -> list["MockLight"]: @pytest.fixture -def mock_sensor_entities() -> dict[str, "MockSensor"]: +def mock_sensor_entities() -> dict[str, MockSensor]: """Return mocked sensor entities.""" from tests.components.sensor.common import get_mock_sensor_entities @@ -145,7 +146,7 @@ def mock_sensor_entities() -> dict[str, "MockSensor"]: @pytest.fixture -def mock_switch_entities() -> list["MockSwitch"]: +def mock_switch_entities() -> list[MockSwitch]: """Return mocked toggle entities.""" from tests.components.switch.common import get_mock_switch_entities @@ -153,7 +154,7 @@ def mock_switch_entities() -> list["MockSwitch"]: @pytest.fixture -def mock_legacy_device_scanner() -> "MockScanner": +def mock_legacy_device_scanner() -> MockScanner: """Return mocked legacy device scanner entity.""" from tests.components.device_tracker.common import MockScanner @@ -161,9 +162,7 @@ def mock_legacy_device_scanner() -> "MockScanner": @pytest.fixture -def mock_legacy_device_tracker_setup() -> ( - Callable[[HomeAssistant, "MockScanner"], None] -): +def mock_legacy_device_tracker_setup() -> Callable[[HomeAssistant, MockScanner], None]: """Return setup callable for legacy device tracker setup.""" from tests.components.device_tracker.common import mock_legacy_device_tracker_setup