From e4731c07cb96f915621a2c8803a320b2e29e6d5f Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:35:56 +0200 Subject: [PATCH] Add monkeypatch to enforce-type-hints plugin (#121051) --- pylint/plugins/hass_enforce_type_hints.py | 1 + tests/components/google_pubsub/test_init.py | 2 +- tests/components/influxdb/test_init.py | 2 +- tests/components/spc/test_init.py | 4 ++-- tests/helpers/test_config_validation.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index ec129d97c16..2c58e7aae15 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -146,6 +146,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = { "mock_tts_get_cache_files": "MagicMock", "mock_tts_init_cache_dir": "MagicMock", "mock_zeroconf": "MagicMock", + "monkeypatch": "pytest.MonkeyPatch", "mqtt_client_mock": "MqttMockPahoClient", "mqtt_mock": "MqttMockHAClient", "mqtt_mock_entry": "MqttMockHAClientGenerator", diff --git a/tests/components/google_pubsub/test_init.py b/tests/components/google_pubsub/test_init.py index d1cc2d88ab0..fba561f6df1 100644 --- a/tests/components/google_pubsub/test_init.py +++ b/tests/components/google_pubsub/test_init.py @@ -61,7 +61,7 @@ def mock_is_file_fixture() -> Generator[MagicMock]: @pytest.fixture(autouse=True) -def mock_json(hass, monkeypatch): +def mock_json(monkeypatch: pytest.MonkeyPatch) -> None: """Mock the event bus listener and os component.""" monkeypatch.setattr( f"{GOOGLE_PUBSUB_PATH}.json.dumps", Mock(return_value=MagicMock()) diff --git a/tests/components/influxdb/test_init.py b/tests/components/influxdb/test_init.py index d7e06b5c101..e9592a06fe2 100644 --- a/tests/components/influxdb/test_init.py +++ b/tests/components/influxdb/test_init.py @@ -43,7 +43,7 @@ class FilterTest: @pytest.fixture(autouse=True) -def mock_batch_timeout(hass, monkeypatch): +def mock_batch_timeout(monkeypatch: pytest.MonkeyPatch) -> None: """Mock the event bus listener and the batch timeout for tests.""" monkeypatch.setattr( f"{INFLUX_PATH}.InfluxThread.batch_timeout", diff --git a/tests/components/spc/test_init.py b/tests/components/spc/test_init.py index 3dfea94a4bd..d2636d9333c 100644 --- a/tests/components/spc/test_init.py +++ b/tests/components/spc/test_init.py @@ -11,7 +11,7 @@ from homeassistant.const import STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED from homeassistant.core import HomeAssistant -async def test_valid_device_config(hass: HomeAssistant, monkeypatch) -> None: +async def test_valid_device_config(hass: HomeAssistant) -> None: """Test valid device config.""" config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}} @@ -22,7 +22,7 @@ async def test_valid_device_config(hass: HomeAssistant, monkeypatch) -> None: assert await async_setup_component(hass, "spc", config) is True -async def test_invalid_device_config(hass: HomeAssistant, monkeypatch) -> None: +async def test_invalid_device_config(hass: HomeAssistant) -> None: """Test valid device config.""" config = {"spc": {"api_url": "http://localhost/"}} diff --git a/tests/helpers/test_config_validation.py b/tests/helpers/test_config_validation.py index 514eff94250..cde319c0b87 100644 --- a/tests/helpers/test_config_validation.py +++ b/tests/helpers/test_config_validation.py @@ -865,7 +865,7 @@ def schema(): @pytest.fixture -def version(monkeypatch): +def version(monkeypatch: pytest.MonkeyPatch) -> None: """Patch the version used for testing to 0.5.0.""" monkeypatch.setattr(homeassistant.const, "__version__", "0.5.0")