diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index 1253a4d5f9b..0dd80e8b11b 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -783,7 +783,7 @@ async def test_invalid_discovery_prefix( mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator, mock_try_connection, mock_reload_after_entry_update, -) -> HomeAssistant: +) -> None: """Test setting an invalid discovery prefix.""" mqtt_mock = await mqtt_mock_entry_no_yaml_config() mock_try_connection.return_value = True @@ -1160,7 +1160,7 @@ async def test_try_connection_with_advanced_parameters( tmp_path: Path, mock_ssl_context, mock_process_uploaded_file, -) -> HomeAssistant: +) -> None: """Test config flow with advanced parameters from config.""" with open(tmp_path / "client.crt", "wb") as certfile: diff --git a/tests/components/mqtt/test_device_trigger.py b/tests/components/mqtt/test_device_trigger.py index 18e90121999..4616627c61f 100644 --- a/tests/components/mqtt/test_device_trigger.py +++ b/tests/components/mqtt/test_device_trigger.py @@ -10,7 +10,7 @@ import homeassistant.components.automation as automation from homeassistant.components.device_automation import DeviceAutomationType from homeassistant.components.mqtt import _LOGGER, DOMAIN, debug_info from homeassistant.const import Platform -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import device_registry as dr from homeassistant.helpers.trigger import async_initialize_triggers from homeassistant.setup import async_setup_component @@ -28,7 +28,7 @@ from tests.typing import MqttMockHAClient, MqttMockHAClientGenerator, WebSocketG @pytest.fixture -def calls(hass): +def calls(hass: HomeAssistant) -> list[ServiceCall]: """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation") diff --git a/tests/components/mqtt/test_light_json.py b/tests/components/mqtt/test_light_json.py index cc14d9cd661..80d26788bf8 100644 --- a/tests/components/mqtt/test_light_json.py +++ b/tests/components/mqtt/test_light_json.py @@ -79,7 +79,6 @@ light: brightness_scale: 99 """ import copy -import json from pathlib import Path from unittest.mock import call, patch @@ -98,6 +97,7 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant, State +from homeassistant.helpers.json import JsonValueType, json_loads from homeassistant.setup import async_setup_component from .test_common import ( @@ -154,13 +154,13 @@ def light_platform_only(): class JsonValidator: """Helper to compare JSON.""" - def __init__(self, jsondata): + def __init__(self, jsondata: JsonValueType) -> None: """Initialize JSON validator.""" self.jsondata = jsondata - def __eq__(self, other): + def __eq__(self, other: JsonValueType) -> bool: """Compare JSON data.""" - return json.loads(self.jsondata) == json.loads(other) + return json_loads(self.jsondata) == json_loads(other) async def test_fail_setup_if_no_command_topic( diff --git a/tests/components/mqtt/test_mixins.py b/tests/components/mqtt/test_mixins.py index 834032a88a0..c9bcd07f26c 100644 --- a/tests/components/mqtt/test_mixins.py +++ b/tests/components/mqtt/test_mixins.py @@ -44,7 +44,7 @@ async def test_availability_with_shared_state_topic( events = [] @callback - def test_callback(event): + def test_callback(event) -> None: events.append(event) hass.bus.async_listen(EVENT_STATE_CHANGED, test_callback) diff --git a/tests/components/mqtt/test_siren.py b/tests/components/mqtt/test_siren.py index 5af903ec046..d3185a12104 100644 --- a/tests/components/mqtt/test_siren.py +++ b/tests/components/mqtt/test_siren.py @@ -1,6 +1,7 @@ """The tests for the MQTT siren platform.""" import copy from pathlib import Path +from typing import Any from unittest.mock import patch import pytest @@ -66,7 +67,11 @@ def siren_platform_only(): yield -async def async_turn_on(hass, entity_id=ENTITY_MATCH_ALL, parameters={}) -> None: +async def async_turn_on( + hass: HomeAssistant, + entity_id: str = ENTITY_MATCH_ALL, + parameters: dict[str, Any] = {}, +) -> None: """Turn all or specified siren on.""" data = {ATTR_ENTITY_ID: entity_id} if entity_id else {} data.update(parameters) @@ -74,7 +79,9 @@ async def async_turn_on(hass, entity_id=ENTITY_MATCH_ALL, parameters={}) -> None await hass.services.async_call(siren.DOMAIN, SERVICE_TURN_ON, data, blocking=True) -async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL) -> None: +async def async_turn_off( + hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL +) -> None: """Turn all or specified siren off.""" data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}