diff --git a/tests/util/test_json.py b/tests/util/test_json.py index 3eccb5245380658ef6ae7df1e4ae78574abd565c..c973ed1a91c5ee30f1134d682d47e4cf97f021bf 100644 --- a/tests/util/test_json.py +++ b/tests/util/test_json.py @@ -159,7 +159,7 @@ async def test_deprecated_save_json( assert "should be updated to use homeassistant.helpers.json module" in caplog.text -async def test_loading_derived_class(): +async def test_loading_derived_class() -> None: """Test loading data from classes derived from str.""" class MyStr(str): diff --git a/tests/util/test_location.py b/tests/util/test_location.py index b9252c33e9d5a8b158c2ce038c5e5343d0e7bcf4..3af3ad2765a0b0d2cc43718eb0bc708b59c50971 100644 --- a/tests/util/test_location.py +++ b/tests/util/test_location.py @@ -5,6 +5,7 @@ from unittest.mock import Mock, patch import aiohttp import pytest +from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.util.location as location_util @@ -28,13 +29,13 @@ DISTANCE_MILES = 3632.78 @pytest.fixture -async def session(hass): +async def session(hass: HomeAssistant) -> aiohttp.ClientSession: """Return aioclient session.""" return async_get_clientsession(hass) @pytest.fixture -async def raising_session(): +async def raising_session() -> Mock: """Return an aioclient session that only fails.""" return Mock(get=Mock(side_effect=aiohttp.ClientError)) @@ -76,7 +77,7 @@ def test_get_miles() -> None: async def test_detect_location_info_whoami( - aioclient_mock: AiohttpClientMocker, session + aioclient_mock: AiohttpClientMocker, session: aiohttp.ClientSession ) -> None: """Test detect location info using services.home-assistant.io/whoami.""" aioclient_mock.get(location_util.WHOAMI_URL, text=load_fixture("whoami.json")) @@ -99,7 +100,9 @@ async def test_detect_location_info_whoami( assert info.use_metric -async def test_dev_url(aioclient_mock: AiohttpClientMocker, session) -> None: +async def test_dev_url( + aioclient_mock: AiohttpClientMocker, session: aiohttp.ClientSession +) -> None: """Test usage of dev URL.""" aioclient_mock.get(location_util.WHOAMI_URL_DEV, text=load_fixture("whoami.json")) with patch("homeassistant.util.location.HA_VERSION", "1.0.dev0"): @@ -110,7 +113,7 @@ async def test_dev_url(aioclient_mock: AiohttpClientMocker, session) -> None: assert info.currency == "XXX" -async def test_whoami_query_raises(raising_session) -> None: +async def test_whoami_query_raises(raising_session: Mock) -> None: """Test whoami query when the request to API fails.""" info = await location_util._get_whoami(raising_session) assert info is None diff --git a/tests/util/test_unit_system.py b/tests/util/test_unit_system.py index 0fa117624901819203e0a85a5a350f1c3877af75..033631563f472b8ed552242d44e4e298ed2894b6 100644 --- a/tests/util/test_unit_system.py +++ b/tests/util/test_unit_system.py @@ -4,8 +4,7 @@ from __future__ import annotations import pytest -from homeassistant.components.sensor import SensorDeviceClass -from homeassistant.components.sensor.const import DEVICE_CLASS_UNITS +from homeassistant.components.sensor import DEVICE_CLASS_UNITS, SensorDeviceClass from homeassistant.const import ( ACCUMULATED_PRECIPITATION, LENGTH, @@ -23,7 +22,7 @@ from homeassistant.const import ( UnitOfVolumetricFlux, ) from homeassistant.exceptions import HomeAssistantError -from homeassistant.util.unit_system import ( +from homeassistant.util.unit_system import ( # pylint: disable=hass-deprecated-import _CONF_UNIT_SYSTEM_IMPERIAL, _CONF_UNIT_SYSTEM_METRIC, _CONF_UNIT_SYSTEM_US_CUSTOMARY,