diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index c6c6986060f..e99c5c1ed39 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -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", diff --git a/tests/components/network/conftest.py b/tests/components/network/conftest.py index 0756ca3b95c..d069fff71b6 100644 --- a/tests/components/network/conftest.py +++ b/tests/components/network/conftest.py @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 4a33ea0e482..13a8daa8ce1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/helpers/test_translation.py b/tests/helpers/test_translation.py index 0e8bbfc4b60..d1df7004c99 100644 --- a/tests/helpers/test_translation.py +++ b/tests/helpers/test_translation.py @@ -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."""