Improve type hints in calendar tests (#121654)

This commit is contained in:
epenet 2024-07-10 09:12:56 +02:00 committed by GitHub
parent 8b0f28e7f4
commit 5d809f88ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 11 deletions

View File

@ -23,7 +23,7 @@ from tests.typing import ClientSessionGenerator, WebSocketGenerator
@pytest.fixture(name="frozen_time") @pytest.fixture(name="frozen_time")
def mock_frozen_time() -> None: def mock_frozen_time() -> str | None:
"""Fixture to set a frozen time used in tests. """Fixture to set a frozen time used in tests.
This is needed so that it can run before other fixtures. This is needed so that it can run before other fixtures.
@ -32,7 +32,7 @@ def mock_frozen_time() -> None:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_set_frozen_time(frozen_time: Any) -> Generator[None]: def mock_set_frozen_time(frozen_time: str | None) -> Generator[None]:
"""Fixture to freeze time that also can work for other fixtures.""" """Fixture to freeze time that also can work for other fixtures."""
if not frozen_time: if not frozen_time:
yield yield
@ -44,9 +44,9 @@ def mock_set_frozen_time(frozen_time: Any) -> Generator[None]:
@pytest.fixture(name="setup_platform", autouse=True) @pytest.fixture(name="setup_platform", autouse=True)
async def mock_setup_platform( async def mock_setup_platform(
hass: HomeAssistant, hass: HomeAssistant,
set_time_zone: Any, set_time_zone: None,
frozen_time: Any, frozen_time: str | None,
mock_setup_integration: Any, mock_setup_integration: None,
config_entry: MockConfigEntry, config_entry: MockConfigEntry,
) -> None: ) -> None:
"""Fixture to setup platforms used in the test and fixtures are set up in the right order.""" """Fixture to setup platforms used in the test and fixtures are set up in the right order."""

View File

@ -1,7 +1,6 @@
"""The tests for calendar recorder.""" """The tests for calendar recorder."""
from datetime import timedelta from datetime import timedelta
from typing import Any
import pytest import pytest
@ -19,7 +18,7 @@ from tests.components.recorder.common import async_wait_recording_done
async def mock_setup_dependencies( async def mock_setup_dependencies(
recorder_mock: Recorder, recorder_mock: Recorder,
hass: HomeAssistant, hass: HomeAssistant,
set_time_zone: Any, set_time_zone: None,
mock_setup_integration: None, mock_setup_integration: None,
config_entry: MockConfigEntry, config_entry: MockConfigEntry,
) -> None: ) -> None:

View File

@ -84,9 +84,7 @@ class FakeSchedule:
@pytest.fixture @pytest.fixture
def fake_schedule( def fake_schedule(hass: HomeAssistant, freezer: FrozenDateTimeFactory) -> FakeSchedule:
hass: HomeAssistant, freezer: FrozenDateTimeFactory
) -> Generator[FakeSchedule]:
"""Fixture that tests can use to make fake events.""" """Fixture that tests can use to make fake events."""
# Setup start time for all tests # Setup start time for all tests
@ -104,7 +102,7 @@ def mock_test_entity(test_entities: list[MockCalendarEntity]) -> MockCalendarEnt
@pytest.fixture(name="setup_platform", autouse=True) @pytest.fixture(name="setup_platform", autouse=True)
async def mock_setup_platform( async def mock_setup_platform(
hass: HomeAssistant, hass: HomeAssistant,
mock_setup_integration: Any, mock_setup_integration: None,
config_entry: MockConfigEntry, config_entry: MockConfigEntry,
) -> None: ) -> None:
"""Fixture to setup platforms used in the test.""" """Fixture to setup platforms used in the test."""