Fix incorrect `patch` type hint in main conftest (#118461)

pull/118640/head
epenet 2024-06-02 15:34:30 +02:00 committed by GitHub
parent dbb27755a4
commit 37fc16d7b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 7 deletions

View File

@ -138,7 +138,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = {
"mock_bluetooth": "None",
"mock_bluetooth_adapters": "None",
"mock_device_tracker_conf": "list[Device]",
"mock_get_source_ip": "None",
"mock_get_source_ip": "_patch",
"mock_hass_config": "None",
"mock_hass_config_yaml": "None",
"mock_zeroconf": "MagicMock",

View File

@ -1,5 +1,8 @@
"""Tests for the Network Configuration integration."""
from collections.abc import Generator
from unittest.mock import _patch
import pytest
@ -9,7 +12,9 @@ def mock_network():
@pytest.fixture(autouse=True)
def override_mock_get_source_ip(mock_get_source_ip):
def override_mock_get_source_ip(
mock_get_source_ip: _patch,
) -> Generator[None, None, None]:
"""Override mock of network util's async_get_source_ip."""
mock_get_source_ip.stop()
yield

View File

@ -15,7 +15,7 @@ import sqlite3
import ssl
import threading
from typing import TYPE_CHECKING, Any, cast
from unittest.mock import AsyncMock, MagicMock, Mock, patch
from unittest.mock import AsyncMock, MagicMock, Mock, _patch, patch
from aiohttp import client
from aiohttp.test_utils import (
@ -1151,7 +1151,7 @@ def mock_network() -> Generator[None, None, None]:
@pytest.fixture(autouse=True, scope="session")
def mock_get_source_ip() -> Generator[patch, None, None]:
def mock_get_source_ip() -> Generator[_patch, None, None]:
"""Mock network util's async_get_source_ip."""
patcher = patch(
"homeassistant.components.network.util.async_get_source_ip",
@ -1165,7 +1165,7 @@ def mock_get_source_ip() -> Generator[patch, None, None]:
@pytest.fixture(autouse=True, scope="session")
def translations_once() -> Generator[patch, None, None]:
def translations_once() -> Generator[_patch, None, None]:
"""Only load translations once per session."""
from homeassistant.helpers.translation import _TranslationsCacheData
@ -1182,7 +1182,9 @@ def translations_once() -> Generator[patch, None, None]:
@pytest.fixture
def disable_translations_once(translations_once):
def disable_translations_once(
translations_once: _patch,
) -> Generator[None, None, None]:
"""Override loading translations once."""
translations_once.stop()
yield

View File

@ -15,7 +15,7 @@ from homeassistant.setup import async_setup_component
@pytest.fixture(autouse=True)
def _disable_translations_once(disable_translations_once):
def _disable_translations_once(disable_translations_once: None) -> None:
"""Override loading translations once."""