diff --git a/tests/components/google/conftest.py b/tests/components/google/conftest.py index bd64a1d8a49..727209620eb 100644 --- a/tests/components/google/conftest.py +++ b/tests/components/google/conftest.py @@ -2,11 +2,11 @@ from __future__ import annotations -from collections.abc import Awaitable, Callable, Generator +from collections.abc import AsyncGenerator, Awaitable, Callable, Generator import datetime import http import time -from typing import Any, TypeVar +from typing import Any from unittest.mock import Mock, mock_open, patch from aiohttp.client_exceptions import ClientError @@ -29,8 +29,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker ApiResult = Callable[[dict[str, Any]], None] ComponentSetup = Callable[[], Awaitable[bool]] -_T = TypeVar("_T") -YieldFixture = Generator[_T, None, None] +type AsyncYieldFixture[_T] = AsyncGenerator[_T, None] CALENDAR_ID = "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com" diff --git a/tests/components/google/test_config_flow.py b/tests/components/google/test_config_flow.py index 12af97c8604..d75de491baf 100644 --- a/tests/components/google/test_config_flow.py +++ b/tests/components/google/test_config_flow.py @@ -37,7 +37,7 @@ from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.setup import async_setup_component from homeassistant.util.dt import utcnow -from .conftest import CLIENT_ID, CLIENT_SECRET, EMAIL_ADDRESS, YieldFixture +from .conftest import CLIENT_ID, CLIENT_SECRET, EMAIL_ADDRESS, AsyncYieldFixture from tests.common import MockConfigEntry, async_fire_time_changed from tests.test_util.aiohttp import AiohttpClientMocker @@ -70,7 +70,7 @@ async def code_expiration_delta() -> datetime.timedelta: @pytest.fixture async def mock_code_flow( code_expiration_delta: datetime.timedelta, -) -> YieldFixture[Mock]: +) -> AsyncYieldFixture[Mock]: """Fixture for initiating OAuth flow.""" with patch( "homeassistant.components.google.api.OAuth2WebServerFlow.step1_get_device_and_user_codes", @@ -88,7 +88,7 @@ async def mock_code_flow( @pytest.fixture -async def mock_exchange(creds: OAuth2Credentials) -> YieldFixture[Mock]: +async def mock_exchange(creds: OAuth2Credentials) -> AsyncYieldFixture[Mock]: """Fixture for mocking out the exchange for credentials.""" with patch( "homeassistant.components.google.api.OAuth2WebServerFlow.step2_exchange", diff --git a/tests/components/nest/common.py b/tests/components/nest/common.py index 70bc88b003f..cd13fb40344 100644 --- a/tests/components/nest/common.py +++ b/tests/components/nest/common.py @@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable, Generator import copy from dataclasses import dataclass, field import time -from typing import Any, TypeVar +from typing import Any from google_nest_sdm.auth import AbstractAuth from google_nest_sdm.device import Device @@ -20,8 +20,7 @@ from homeassistant.components.nest import DOMAIN # Typing helpers PlatformSetup = Callable[[], Awaitable[None]] -_T = TypeVar("_T") -YieldFixture = Generator[_T, None, None] +type YieldFixture[_T] = Generator[_T, None, None] WEB_AUTH_DOMAIN = DOMAIN APP_AUTH_DOMAIN = f"{DOMAIN}.installed" diff --git a/tests/components/rtsp_to_webrtc/conftest.py b/tests/components/rtsp_to_webrtc/conftest.py index e968df9d860..067e4580c94 100644 --- a/tests/components/rtsp_to_webrtc/conftest.py +++ b/tests/components/rtsp_to_webrtc/conftest.py @@ -2,8 +2,8 @@ from __future__ import annotations -from collections.abc import AsyncGenerator, Awaitable, Callable, Generator -from typing import Any, TypeVar +from collections.abc import AsyncGenerator, Awaitable, Callable +from typing import Any from unittest.mock import patch import pytest @@ -24,8 +24,7 @@ CONFIG_ENTRY_DATA = {"server_url": SERVER_URL} # Typing helpers ComponentSetup = Callable[[], Awaitable[None]] -_T = TypeVar("_T") -YieldFixture = Generator[_T, None, None] +type AsyncYieldFixture[_T] = AsyncGenerator[_T, None] @pytest.fixture(autouse=True) @@ -91,7 +90,7 @@ async def rtsp_to_webrtc_client() -> None: @pytest.fixture async def setup_integration( hass: HomeAssistant, config_entry: MockConfigEntry -) -> YieldFixture[ComponentSetup]: +) -> AsyncYieldFixture[ComponentSetup]: """Fixture for setting up the component.""" config_entry.add_to_hass(hass)