Improve YieldFixture typing (#117686)

This commit is contained in:
Marc Mueller 2024-05-18 12:35:02 +02:00 committed by GitHub
parent 26a599ad11
commit 3cd1717437
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 15 deletions

View file

@ -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)