From 7a89e58873fbe4c69c234f7741ac87d85c76fc11 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:00:37 +0100 Subject: [PATCH] Use builtin TimeoutError [e-i] (#109679) --- homeassistant/components/eliqonline/sensor.py | 3 +-- homeassistant/components/elkm1/__init__.py | 4 ++-- homeassistant/components/elkm1/config_flow.py | 3 +-- homeassistant/components/emulated_hue/hue_api.py | 2 +- homeassistant/components/escea/config_flow.py | 2 +- homeassistant/components/evil_genius_labs/config_flow.py | 2 +- homeassistant/components/flick_electric/config_flow.py | 2 +- homeassistant/components/flock/notify.py | 2 +- homeassistant/components/flux_led/const.py | 3 +-- homeassistant/components/foobot/sensor.py | 5 ++--- homeassistant/components/forked_daapd/media_player.py | 4 ++-- homeassistant/components/freedns/__init__.py | 2 +- homeassistant/components/fully_kiosk/config_flow.py | 2 +- homeassistant/components/gardena_bluetooth/__init__.py | 3 +-- homeassistant/components/gios/config_flow.py | 2 +- homeassistant/components/google_assistant/http.py | 3 +-- homeassistant/components/google_assistant/smart_home.py | 2 +- homeassistant/components/google_cloud/tts.py | 2 +- homeassistant/components/google_domains/__init__.py | 2 +- homeassistant/components/govee_light_local/__init__.py | 2 +- .../components/govee_light_local/config_flow.py | 2 +- homeassistant/components/harmony/data.py | 3 +-- homeassistant/components/hassio/handler.py | 2 +- homeassistant/components/hassio/http.py | 3 +-- homeassistant/components/hlk_sw16/config_flow.py | 2 +- .../components/homeassistant_alerts/__init__.py | 3 +-- homeassistant/components/homekit_controller/__init__.py | 4 ++-- homeassistant/components/homekit_controller/const.py | 3 +-- homeassistant/components/honeywell/__init__.py | 3 +-- homeassistant/components/honeywell/climate.py | 5 ++--- homeassistant/components/honeywell/config_flow.py | 5 ++--- homeassistant/components/hue/bridge.py | 2 +- homeassistant/components/hue/config_flow.py | 2 +- homeassistant/components/huisbaasje/__init__.py | 2 +- .../components/hunterdouglas_powerview/const.py | 3 +-- .../components/hunterdouglas_powerview/cover.py | 2 +- homeassistant/components/ialarm/__init__.py | 2 +- homeassistant/components/iammeter/sensor.py | 5 ++--- homeassistant/components/iaqualink/__init__.py | 3 +-- homeassistant/components/image/__init__.py | 2 +- homeassistant/components/imap/__init__.py | 4 +--- homeassistant/components/imap/config_flow.py | 3 +-- homeassistant/components/imap/coordinator.py | 9 ++++----- homeassistant/components/incomfort/water_heater.py | 3 +-- homeassistant/components/ipma/__init__.py | 2 +- homeassistant/components/ipma/weather.py | 2 +- homeassistant/components/isy994/__init__.py | 2 +- homeassistant/components/izone/config_flow.py | 2 +- tests/components/esphome/test_config_flow.py | 3 +-- tests/components/esphome/test_dashboard.py | 5 ++--- tests/components/esphome/test_update.py | 5 ++--- tests/components/evil_genius_labs/test_config_flow.py | 3 +-- tests/components/flick_electric/test_config_flow.py | 3 +-- tests/components/foobot/test_sensor.py | 5 +---- tests/components/fully_kiosk/test_config_flow.py | 3 +-- tests/components/fully_kiosk/test_init.py | 3 +-- tests/components/generic/test_camera.py | 2 +- tests/components/gogogate2/test_init.py | 3 +-- tests/components/govee_light_local/test_light.py | 3 +-- tests/components/hassio/test_http.py | 3 +-- tests/components/hlk_sw16/test_config_flow.py | 2 +- tests/components/honeywell/test_config_flow.py | 3 +-- tests/components/hue/test_config_flow.py | 3 +-- tests/components/hue/test_light_v1.py | 5 ++--- tests/components/hue/test_sensor_v1.py | 3 +-- .../hunterdouglas_powerview/test_config_flow.py | 9 ++------- tests/components/iaqualink/test_init.py | 3 +-- tests/components/imap/test_config_flow.py | 7 +++---- tests/components/imap/test_init.py | 8 ++++---- 69 files changed, 88 insertions(+), 133 deletions(-) diff --git a/homeassistant/components/eliqonline/sensor.py b/homeassistant/components/eliqonline/sensor.py index bea60b94a1c..2a929db4b0a 100644 --- a/homeassistant/components/eliqonline/sensor.py +++ b/homeassistant/components/eliqonline/sensor.py @@ -1,7 +1,6 @@ """Monitors home energy use for the ELIQ Online service.""" from __future__ import annotations -import asyncio from datetime import timedelta import logging @@ -83,5 +82,5 @@ class EliqSensor(SensorEntity): _LOGGER.debug("Updated power from server %d W", self.native_value) except KeyError: _LOGGER.warning("Invalid response from ELIQ Online API") - except (OSError, asyncio.TimeoutError) as error: + except (OSError, TimeoutError) as error: _LOGGER.warning("Could not connect to the ELIQ Online API: %s", error) diff --git a/homeassistant/components/elkm1/__init__.py b/homeassistant/components/elkm1/__init__.py index b633e1ae620..c51cb30776a 100644 --- a/homeassistant/components/elkm1/__init__.py +++ b/homeassistant/components/elkm1/__init__.py @@ -296,7 +296,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: if not await async_wait_for_elk_to_sync(elk, LOGIN_TIMEOUT, SYNC_TIMEOUT): return False - except asyncio.TimeoutError as exc: + except TimeoutError as exc: raise ConfigEntryNotReady(f"Timed out connecting to {conf[CONF_HOST]}") from exc elk_temp_unit = elk.panel.temperature_units @@ -389,7 +389,7 @@ async def async_wait_for_elk_to_sync( try: async with asyncio.timeout(timeout): await event.wait() - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.debug("Timed out waiting for %s event", name) elk.disconnect() raise diff --git a/homeassistant/components/elkm1/config_flow.py b/homeassistant/components/elkm1/config_flow.py index ac7fc903330..e8d3f8cb0e4 100644 --- a/homeassistant/components/elkm1/config_flow.py +++ b/homeassistant/components/elkm1/config_flow.py @@ -1,7 +1,6 @@ """Config flow for Elk-M1 Control integration.""" from __future__ import annotations -import asyncio import logging from typing import Any @@ -244,7 +243,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: info = await validate_input(user_input, self.unique_id) - except asyncio.TimeoutError: + except TimeoutError: return {"base": "cannot_connect"}, None except InvalidAuth: return {CONF_PASSWORD: "invalid_auth"}, None diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 94ac97b6b36..5da2fcab967 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -934,7 +934,7 @@ async def wait_for_state_change_or_timeout( try: async with asyncio.timeout(STATE_CHANGE_WAIT_TIMEOUT): await ev.wait() - except asyncio.TimeoutError: + except TimeoutError: pass finally: unsub() diff --git a/homeassistant/components/escea/config_flow.py b/homeassistant/components/escea/config_flow.py index 8766c30c04a..eb50e7d0fdc 100644 --- a/homeassistant/components/escea/config_flow.py +++ b/homeassistant/components/escea/config_flow.py @@ -31,7 +31,7 @@ async def _async_has_devices(hass: HomeAssistant) -> bool: discovery_service = await async_start_discovery_service(hass) - with suppress(asyncio.TimeoutError): + with suppress(TimeoutError): async with asyncio.timeout(TIMEOUT_DISCOVERY): await controller_ready.wait() diff --git a/homeassistant/components/evil_genius_labs/config_flow.py b/homeassistant/components/evil_genius_labs/config_flow.py index beb16115bd7..ab2e116b2a6 100644 --- a/homeassistant/components/evil_genius_labs/config_flow.py +++ b/homeassistant/components/evil_genius_labs/config_flow.py @@ -63,7 +63,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: info = await validate_input(self.hass, user_input) - except asyncio.TimeoutError: + except TimeoutError: errors["base"] = "timeout" except CannotConnect: errors["base"] = "cannot_connect" diff --git a/homeassistant/components/flick_electric/config_flow.py b/homeassistant/components/flick_electric/config_flow.py index 557d0492320..842706172f1 100644 --- a/homeassistant/components/flick_electric/config_flow.py +++ b/homeassistant/components/flick_electric/config_flow.py @@ -46,7 +46,7 @@ class FlickConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: async with asyncio.timeout(60): token = await auth.async_get_access_token() - except asyncio.TimeoutError as err: + except TimeoutError as err: raise CannotConnect() from err except AuthException as err: raise InvalidAuth() from err diff --git a/homeassistant/components/flock/notify.py b/homeassistant/components/flock/notify.py index 3fdd54dd40d..c5926e3158e 100644 --- a/homeassistant/components/flock/notify.py +++ b/homeassistant/components/flock/notify.py @@ -58,5 +58,5 @@ class FlockNotificationService(BaseNotificationService): response.status, result, ) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.error("Timeout accessing Flock at %s", self._url) diff --git a/homeassistant/components/flux_led/const.py b/homeassistant/components/flux_led/const.py index 8b42f5f2e0d..08e1d274ea7 100644 --- a/homeassistant/components/flux_led/const.py +++ b/homeassistant/components/flux_led/const.py @@ -1,6 +1,5 @@ """Constants of the FluxLed/MagicHome Integration.""" -import asyncio import socket from typing import Final @@ -38,7 +37,7 @@ DEFAULT_EFFECT_SPEED: Final = 50 FLUX_LED_DISCOVERY: Final = "flux_led_discovery" FLUX_LED_EXCEPTIONS: Final = ( - asyncio.TimeoutError, + TimeoutError, socket.error, RuntimeError, BrokenPipeError, diff --git a/homeassistant/components/foobot/sensor.py b/homeassistant/components/foobot/sensor.py index a865dd33053..0af1206dbd3 100644 --- a/homeassistant/components/foobot/sensor.py +++ b/homeassistant/components/foobot/sensor.py @@ -1,7 +1,6 @@ """Support for the Foobot indoor air quality monitor.""" from __future__ import annotations -import asyncio from datetime import timedelta import logging from typing import Any @@ -118,7 +117,7 @@ async def async_setup_platform( ) except ( aiohttp.client_exceptions.ClientConnectorError, - asyncio.TimeoutError, + TimeoutError, FoobotClient.TooManyRequests, FoobotClient.InternalError, ) as err: @@ -175,7 +174,7 @@ class FoobotData: ) except ( aiohttp.client_exceptions.ClientConnectorError, - asyncio.TimeoutError, + TimeoutError, self._client.TooManyRequests, self._client.InternalError, ): diff --git a/homeassistant/components/forked_daapd/media_player.py b/homeassistant/components/forked_daapd/media_player.py index 48c2be07c76..df12de944ae 100644 --- a/homeassistant/components/forked_daapd/media_player.py +++ b/homeassistant/components/forked_daapd/media_player.py @@ -668,7 +668,7 @@ class ForkedDaapdMaster(MediaPlayerEntity): try: async with asyncio.timeout(CALLBACK_TIMEOUT): await self._paused_event.wait() # wait for paused - except asyncio.TimeoutError: + except TimeoutError: self._pause_requested = False self._paused_event.clear() @@ -764,7 +764,7 @@ class ForkedDaapdMaster(MediaPlayerEntity): async with asyncio.timeout(TTS_TIMEOUT): await self._tts_playing_event.wait() # we have started TTS, now wait for completion - except asyncio.TimeoutError: + except TimeoutError: self._tts_requested = False _LOGGER.warning("TTS request timed out") await asyncio.sleep( diff --git a/homeassistant/components/freedns/__init__.py b/homeassistant/components/freedns/__init__.py index e65856e03f4..feb1fb9fed9 100644 --- a/homeassistant/components/freedns/__init__.py +++ b/homeassistant/components/freedns/__init__.py @@ -96,7 +96,7 @@ async def _update_freedns(hass, session, url, auth_token): except aiohttp.ClientError: _LOGGER.warning("Can't connect to FreeDNS API") - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning("Timeout from FreeDNS API at %s", url) return False diff --git a/homeassistant/components/fully_kiosk/config_flow.py b/homeassistant/components/fully_kiosk/config_flow.py index 4f9dadd6901..00eb1dd7101 100644 --- a/homeassistant/components/fully_kiosk/config_flow.py +++ b/homeassistant/components/fully_kiosk/config_flow.py @@ -58,7 +58,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): except ( ClientConnectorError, FullyKioskError, - asyncio.TimeoutError, + TimeoutError, ) as error: LOGGER.debug(error.args, exc_info=True) errors["base"] = "cannot_connect" diff --git a/homeassistant/components/gardena_bluetooth/__init__.py b/homeassistant/components/gardena_bluetooth/__init__.py index df41b0a1c43..99c8fa69acf 100644 --- a/homeassistant/components/gardena_bluetooth/__init__.py +++ b/homeassistant/components/gardena_bluetooth/__init__.py @@ -1,7 +1,6 @@ """The Gardena Bluetooth integration.""" from __future__ import annotations -import asyncio import logging from bleak.backends.device import BLEDevice @@ -60,7 +59,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ) uuids = await client.get_all_characteristics_uuid() await client.update_timestamp(dt_util.now()) - except (asyncio.TimeoutError, CommunicationFailure, DeviceUnavailable) as exception: + except (TimeoutError, CommunicationFailure, DeviceUnavailable) as exception: await client.disconnect() raise ConfigEntryNotReady( f"Unable to connect to device {address} due to {exception}" diff --git a/homeassistant/components/gios/config_flow.py b/homeassistant/components/gios/config_flow.py index ffc34bd2b78..1595b7ad131 100644 --- a/homeassistant/components/gios/config_flow.py +++ b/homeassistant/components/gios/config_flow.py @@ -45,7 +45,7 @@ class GiosFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): title=gios.station_name, data=user_input, ) - except (ApiError, ClientConnectorError, asyncio.TimeoutError): + except (ApiError, ClientConnectorError, TimeoutError): errors["base"] = "cannot_connect" except NoStationError: errors[CONF_STATION_ID] = "wrong_station_id" diff --git a/homeassistant/components/google_assistant/http.py b/homeassistant/components/google_assistant/http.py index c0e4f715c16..226c37fb717 100644 --- a/homeassistant/components/google_assistant/http.py +++ b/homeassistant/components/google_assistant/http.py @@ -1,7 +1,6 @@ """Support for Google Actions Smart Home Control.""" from __future__ import annotations -import asyncio from datetime import timedelta from http import HTTPStatus import logging @@ -216,7 +215,7 @@ class GoogleConfig(AbstractConfig): except ClientResponseError as error: _LOGGER.error("Request for %s failed: %d", url, error.status) return error.status - except (asyncio.TimeoutError, ClientError): + except (TimeoutError, ClientError): _LOGGER.error("Could not contact %s", url) return HTTPStatus.INTERNAL_SERVER_ERROR diff --git a/homeassistant/components/google_assistant/smart_home.py b/homeassistant/components/google_assistant/smart_home.py index 7d8cc752342..19f097151d7 100644 --- a/homeassistant/components/google_assistant/smart_home.py +++ b/homeassistant/components/google_assistant/smart_home.py @@ -255,7 +255,7 @@ async def handle_devices_execute( for entity_id, result in zip(executions, execute_results): if result is not None: results[entity_id] = result - except asyncio.TimeoutError: + except TimeoutError: pass final_results = list(results.values()) diff --git a/homeassistant/components/google_cloud/tts.py b/homeassistant/components/google_cloud/tts.py index 720c7d9aa2b..8f30448ad61 100644 --- a/homeassistant/components/google_cloud/tts.py +++ b/homeassistant/components/google_cloud/tts.py @@ -292,7 +292,7 @@ class GoogleCloudTTSProvider(Provider): ) return _encoding, response.audio_content - except asyncio.TimeoutError as ex: + except TimeoutError as ex: _LOGGER.error("Timeout for Google Cloud TTS call: %s", ex) except Exception as ex: # pylint: disable=broad-except _LOGGER.exception("Error occurred during Google Cloud TTS call: %s", ex) diff --git a/homeassistant/components/google_domains/__init__.py b/homeassistant/components/google_domains/__init__.py index 52dcdb61e8f..1d420cb1497 100644 --- a/homeassistant/components/google_domains/__init__.py +++ b/homeassistant/components/google_domains/__init__.py @@ -80,7 +80,7 @@ async def _update_google_domains(hass, session, domain, user, password, timeout) except aiohttp.ClientError: _LOGGER.warning("Can't connect to Google Domains API") - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning("Timeout from Google Domains API for domain: %s", domain) return False diff --git a/homeassistant/components/govee_light_local/__init__.py b/homeassistant/components/govee_light_local/__init__.py index ab20f4cefcd..2d4594755c4 100644 --- a/homeassistant/components/govee_light_local/__init__.py +++ b/homeassistant/components/govee_light_local/__init__.py @@ -28,7 +28,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async with asyncio.timeout(delay=5): while not coordinator.devices: await asyncio.sleep(delay=1) - except asyncio.TimeoutError as ex: + except TimeoutError as ex: raise ConfigEntryNotReady from ex hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator diff --git a/homeassistant/components/govee_light_local/config_flow.py b/homeassistant/components/govee_light_local/config_flow.py index 8ab14966828..8058668f0ca 100644 --- a/homeassistant/components/govee_light_local/config_flow.py +++ b/homeassistant/components/govee_light_local/config_flow.py @@ -44,7 +44,7 @@ async def _async_has_devices(hass: HomeAssistant) -> bool: async with asyncio.timeout(delay=5): while not controller.devices: await asyncio.sleep(delay=1) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.debug("No devices found") devices_count = len(controller.devices) diff --git a/homeassistant/components/harmony/data.py b/homeassistant/components/harmony/data.py index 44c0fde19c1..f7eb96d6a8f 100644 --- a/homeassistant/components/harmony/data.py +++ b/homeassistant/components/harmony/data.py @@ -1,7 +1,6 @@ """Harmony data object which contains the Harmony Client.""" from __future__ import annotations -import asyncio from collections.abc import Iterable import logging @@ -121,7 +120,7 @@ class HarmonyData(HarmonySubscriberMixin): connected = False try: connected = await self._client.connect() - except (asyncio.TimeoutError, aioexc.TimeOut) as err: + except (TimeoutError, aioexc.TimeOut) as err: await self._client.close() raise ConfigEntryNotReady( f"{self._name}: Connection timed-out to {self._address}:8088" diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index c3532d553f4..f335c3dc488 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -593,7 +593,7 @@ class HassIO: return await request.json(encoding="utf-8") - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.error("Timeout on %s request", command) except aiohttp.ClientError as err: diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index 9d72d5842fd..8ba389f9054 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -1,7 +1,6 @@ """HTTP Support for Hass.io.""" from __future__ import annotations -import asyncio from http import HTTPStatus import logging import os @@ -193,7 +192,7 @@ class HassIOView(HomeAssistantView): except aiohttp.ClientError as err: _LOGGER.error("Client error on api %s request %s", path, err) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.error("Client timeout error on API request %s", path) raise HTTPBadGateway() diff --git a/homeassistant/components/hlk_sw16/config_flow.py b/homeassistant/components/hlk_sw16/config_flow.py index 01f695ad1a6..6ea5f9d43db 100644 --- a/homeassistant/components/hlk_sw16/config_flow.py +++ b/homeassistant/components/hlk_sw16/config_flow.py @@ -43,7 +43,7 @@ async def validate_input(hass: HomeAssistant, user_input): """Validate the user input allows us to connect.""" try: client = await connect_client(hass, user_input) - except asyncio.TimeoutError as err: + except TimeoutError as err: raise CannotConnect from err try: diff --git a/homeassistant/components/homeassistant_alerts/__init__.py b/homeassistant/components/homeassistant_alerts/__init__.py index 036eb07e067..f391b990761 100644 --- a/homeassistant/components/homeassistant_alerts/__init__.py +++ b/homeassistant/components/homeassistant_alerts/__init__.py @@ -1,7 +1,6 @@ """The Home Assistant alerts integration.""" from __future__ import annotations -import asyncio import dataclasses from datetime import timedelta import logging @@ -53,7 +52,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: f"https://alerts.home-assistant.io/alerts/{alert.alert_id}.json", timeout=aiohttp.ClientTimeout(total=30), ) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning("Error fetching %s: timeout", alert.filename) continue diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index ed9b8ca4622..1043164c801 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -43,13 +43,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: await conn.async_setup() except ( - asyncio.TimeoutError, + TimeoutError, AccessoryNotFoundError, EncryptionError, AccessoryDisconnectedError, ) as ex: del hass.data[KNOWN_DEVICES][conn.unique_id] - with contextlib.suppress(asyncio.TimeoutError): + with contextlib.suppress(TimeoutError): await conn.pairing.close() raise ConfigEntryNotReady from ex diff --git a/homeassistant/components/homekit_controller/const.py b/homeassistant/components/homekit_controller/const.py index cc2c28cb5dc..939657eb8a5 100644 --- a/homeassistant/components/homekit_controller/const.py +++ b/homeassistant/components/homekit_controller/const.py @@ -1,5 +1,4 @@ """Constants for the homekit_controller component.""" -import asyncio from aiohomekit.exceptions import ( AccessoryDisconnectedError, @@ -108,7 +107,7 @@ CHARACTERISTIC_PLATFORMS = { } STARTUP_EXCEPTIONS = ( - asyncio.TimeoutError, + TimeoutError, AccessoryNotFoundError, EncryptionError, AccessoryDisconnectedError, diff --git a/homeassistant/components/honeywell/__init__.py b/homeassistant/components/honeywell/__init__.py index baabf4ca4d8..f58db72a07e 100644 --- a/homeassistant/components/honeywell/__init__.py +++ b/homeassistant/components/honeywell/__init__.py @@ -1,5 +1,4 @@ """Support for Honeywell (US) Total Connect Comfort climate systems.""" -import asyncio from dataclasses import dataclass import aiosomecomfort @@ -68,7 +67,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b aiosomecomfort.device.ConnectionError, aiosomecomfort.device.ConnectionTimeout, aiosomecomfort.device.SomeComfortError, - asyncio.TimeoutError, + TimeoutError, ) as ex: raise ConfigEntryNotReady( "Failed to initialize the Honeywell client: Connection error" diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index efd06ba2905..9d2768334ff 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -1,7 +1,6 @@ """Support for Honeywell (US) Total Connect Comfort climate systems.""" from __future__ import annotations -import asyncio import datetime from typing import Any @@ -508,7 +507,7 @@ class HoneywellUSThermostat(ClimateEntity): AuthError, ClientConnectionError, AscConnectionError, - asyncio.TimeoutError, + TimeoutError, ): self._retry += 1 self._attr_available = self._retry <= RETRY @@ -524,7 +523,7 @@ class HoneywellUSThermostat(ClimateEntity): await _login() return - except (AscConnectionError, ClientConnectionError, asyncio.TimeoutError): + except (AscConnectionError, ClientConnectionError, TimeoutError): self._retry += 1 self._attr_available = self._retry <= RETRY return diff --git a/homeassistant/components/honeywell/config_flow.py b/homeassistant/components/honeywell/config_flow.py index 43d08ee2294..aeb72899e11 100644 --- a/homeassistant/components/honeywell/config_flow.py +++ b/homeassistant/components/honeywell/config_flow.py @@ -1,7 +1,6 @@ """Config flow to configure the honeywell integration.""" from __future__ import annotations -import asyncio from collections.abc import Mapping from typing import Any @@ -61,7 +60,7 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): except ( aiosomecomfort.ConnectionError, aiosomecomfort.ConnectionTimeout, - asyncio.TimeoutError, + TimeoutError, ): errors["base"] = "cannot_connect" @@ -93,7 +92,7 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): except ( aiosomecomfort.ConnectionError, aiosomecomfort.ConnectionTimeout, - asyncio.TimeoutError, + TimeoutError, ): errors["base"] = "cannot_connect" diff --git a/homeassistant/components/hue/bridge.py b/homeassistant/components/hue/bridge.py index c5ceebec3f8..abf91cf4577 100644 --- a/homeassistant/components/hue/bridge.py +++ b/homeassistant/components/hue/bridge.py @@ -83,7 +83,7 @@ class HueBridge: create_config_flow(self.hass, self.host) return False except ( - asyncio.TimeoutError, + TimeoutError, client_exceptions.ClientOSError, client_exceptions.ServerDisconnectedError, client_exceptions.ContentTypeError, diff --git a/homeassistant/components/hue/config_flow.py b/homeassistant/components/hue/config_flow.py index 7262dea39ef..a1345cf3bba 100644 --- a/homeassistant/components/hue/config_flow.py +++ b/homeassistant/components/hue/config_flow.py @@ -111,7 +111,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): bridges = await discover_nupnp( websession=aiohttp_client.async_get_clientsession(self.hass) ) - except asyncio.TimeoutError: + except TimeoutError: return self.async_abort(reason="discover_timeout") if bridges: diff --git a/homeassistant/components/huisbaasje/__init__.py b/homeassistant/components/huisbaasje/__init__.py index b1c2d865e0c..9ea4b547596 100644 --- a/homeassistant/components/huisbaasje/__init__.py +++ b/homeassistant/components/huisbaasje/__init__.py @@ -84,7 +84,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_update_huisbaasje(energyflip: EnergyFlip) -> dict[str, dict[str, Any]]: """Update the data by performing a request to Huisbaasje.""" try: - # Note: asyncio.TimeoutError and aiohttp.ClientError are already + # Note: TimeoutError and aiohttp.ClientError are already # handled by the data update coordinator. async with asyncio.timeout(FETCH_TIMEOUT): if not energyflip.is_authenticated(): diff --git a/homeassistant/components/hunterdouglas_powerview/const.py b/homeassistant/components/hunterdouglas_powerview/const.py index 7dd4c229c48..319ea0c5b73 100644 --- a/homeassistant/components/hunterdouglas_powerview/const.py +++ b/homeassistant/components/hunterdouglas_powerview/const.py @@ -1,6 +1,5 @@ """Support for Powerview scenes from a Powerview hub.""" -import asyncio from aiohttp.client_exceptions import ServerDisconnectedError from aiopvapi.helpers.aiorequest import PvApiConnectionError, PvApiResponseStatusError @@ -53,7 +52,7 @@ STATE_ATTRIBUTE_ROOM_NAME = "roomName" HUB_EXCEPTIONS = ( ServerDisconnectedError, - asyncio.TimeoutError, + TimeoutError, PvApiConnectionError, PvApiResponseStatusError, ) diff --git a/homeassistant/components/hunterdouglas_powerview/cover.py b/homeassistant/components/hunterdouglas_powerview/cover.py index 6d050bc1dbd..f9920c26f3a 100644 --- a/homeassistant/components/hunterdouglas_powerview/cover.py +++ b/homeassistant/components/hunterdouglas_powerview/cover.py @@ -82,7 +82,7 @@ async def async_setup_entry( # so we force a refresh when we add it if possible shade: BaseShade = PvShade(raw_shade, pv_entry.api) name_before_refresh = shade.name - with suppress(asyncio.TimeoutError): + with suppress(TimeoutError): async with asyncio.timeout(1): await shade.refresh() diff --git a/homeassistant/components/ialarm/__init__.py b/homeassistant/components/ialarm/__init__.py index 1b821025953..ff54c02a2d4 100644 --- a/homeassistant/components/ialarm/__init__.py +++ b/homeassistant/components/ialarm/__init__.py @@ -28,7 +28,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: async with asyncio.timeout(10): mac = await hass.async_add_executor_job(ialarm.get_mac) - except (asyncio.TimeoutError, ConnectionError) as ex: + except (TimeoutError, ConnectionError) as ex: raise ConfigEntryNotReady from ex coordinator = IAlarmDataUpdateCoordinator(hass, ialarm, mac) diff --git a/homeassistant/components/iammeter/sensor.py b/homeassistant/components/iammeter/sensor.py index df3a873b6c1..3537737f122 100644 --- a/homeassistant/components/iammeter/sensor.py +++ b/homeassistant/components/iammeter/sensor.py @@ -1,7 +1,6 @@ """Support for iammeter via local API.""" from __future__ import annotations -import asyncio from asyncio import timeout from collections.abc import Callable from dataclasses import dataclass @@ -117,7 +116,7 @@ async def async_setup_platform( api = await hass.async_add_executor_job( IamMeter, config_host, config_port, config_name ) - except asyncio.TimeoutError as err: + except TimeoutError as err: _LOGGER.error("Device is not ready") raise PlatformNotReady from err @@ -125,7 +124,7 @@ async def async_setup_platform( try: async with timeout(PLATFORM_TIMEOUT): return await hass.async_add_executor_job(api.client.get_data) - except asyncio.TimeoutError as err: + except TimeoutError as err: raise UpdateFailed from err coordinator = DataUpdateCoordinator( diff --git a/homeassistant/components/iaqualink/__init__.py b/homeassistant/components/iaqualink/__init__.py index 062548666c4..49eaa2b24a5 100644 --- a/homeassistant/components/iaqualink/__init__.py +++ b/homeassistant/components/iaqualink/__init__.py @@ -1,7 +1,6 @@ """Component to embed Aqualink devices.""" from __future__ import annotations -import asyncio from collections.abc import Awaitable, Callable, Coroutine from datetime import datetime from functools import wraps @@ -79,7 +78,7 @@ async def async_setup_entry( # noqa: C901 _LOGGER.error("Failed to login: %s", login_exception) await aqualink.close() return False - except (asyncio.TimeoutError, httpx.HTTPError) as aio_exception: + except (TimeoutError, httpx.HTTPError) as aio_exception: await aqualink.close() raise ConfigEntryNotReady( f"Error while attempting login: {aio_exception}" diff --git a/homeassistant/components/image/__init__.py b/homeassistant/components/image/__init__.py index 4c5a9df8810..17ceac9c8db 100644 --- a/homeassistant/components/image/__init__.py +++ b/homeassistant/components/image/__init__.py @@ -75,7 +75,7 @@ def valid_image_content_type(content_type: str | None) -> str: async def _async_get_image(image_entity: ImageEntity, timeout: int) -> Image: """Fetch image from an image entity.""" - with suppress(asyncio.CancelledError, asyncio.TimeoutError, ImageContentTypeError): + with suppress(asyncio.CancelledError, TimeoutError, ImageContentTypeError): async with asyncio.timeout(timeout): if image_bytes := await image_entity.async_image(): content_type = valid_image_content_type(image_entity.content_type) diff --git a/homeassistant/components/imap/__init__.py b/homeassistant/components/imap/__init__.py index fea2583a27a..924408c30b9 100644 --- a/homeassistant/components/imap/__init__.py +++ b/homeassistant/components/imap/__init__.py @@ -1,8 +1,6 @@ """The imap integration.""" from __future__ import annotations -import asyncio - from aioimaplib import IMAP4_SSL, AioImapException from homeassistant.config_entries import ConfigEntry @@ -33,7 +31,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise ConfigEntryAuthFailed from err except InvalidFolder as err: raise ConfigEntryError("Selected mailbox folder is invalid.") from err - except (asyncio.TimeoutError, AioImapException) as err: + except (TimeoutError, AioImapException) as err: raise ConfigEntryNotReady from err coordinator_class: type[ diff --git a/homeassistant/components/imap/config_flow.py b/homeassistant/components/imap/config_flow.py index dea7a0e2e71..15b52ce6333 100644 --- a/homeassistant/components/imap/config_flow.py +++ b/homeassistant/components/imap/config_flow.py @@ -1,7 +1,6 @@ """Config flow for imap integration.""" from __future__ import annotations -import asyncio from collections.abc import Mapping import ssl from typing import Any @@ -108,7 +107,7 @@ async def validate_input( # See https://github.com/bamthomas/aioimaplib/issues/91 # This handler is added to be able to supply a better error message errors["base"] = "ssl_error" - except (asyncio.TimeoutError, AioImapException, ConnectionRefusedError): + except (TimeoutError, AioImapException, ConnectionRefusedError): errors["base"] = "cannot_connect" else: if result != "OK": diff --git a/homeassistant/components/imap/coordinator.py b/homeassistant/components/imap/coordinator.py index 2941b65be5c..3b2a3601eec 100644 --- a/homeassistant/components/imap/coordinator.py +++ b/homeassistant/components/imap/coordinator.py @@ -347,7 +347,7 @@ class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]): await self.imap_client.stop_wait_server_push() await self.imap_client.close() await self.imap_client.logout() - except (AioImapException, asyncio.TimeoutError): + except (AioImapException, TimeoutError): if log_error: _LOGGER.debug("Error while cleaning up imap connection") finally: @@ -379,7 +379,7 @@ class ImapPollingDataUpdateCoordinator(ImapDataUpdateCoordinator): except ( AioImapException, UpdateFailed, - asyncio.TimeoutError, + TimeoutError, ) as ex: await self._cleanup() self.async_set_update_error(ex) @@ -451,7 +451,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator): except ( UpdateFailed, AioImapException, - asyncio.TimeoutError, + TimeoutError, ) as ex: await self._cleanup() self.async_set_update_error(ex) @@ -467,8 +467,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator): async with asyncio.timeout(10): await idle - # From python 3.11 asyncio.TimeoutError is an alias of TimeoutError - except (AioImapException, asyncio.TimeoutError): + except (AioImapException, TimeoutError): _LOGGER.debug( "Lost %s (will attempt to reconnect after %s s)", self.config_entry.data[CONF_SERVER], diff --git a/homeassistant/components/incomfort/water_heater.py b/homeassistant/components/incomfort/water_heater.py index f906270b2f5..367af73810b 100644 --- a/homeassistant/components/incomfort/water_heater.py +++ b/homeassistant/components/incomfort/water_heater.py @@ -1,7 +1,6 @@ """Support for an Intergas boiler via an InComfort/Intouch Lan2RF gateway.""" from __future__ import annotations -import asyncio import logging from typing import Any @@ -101,7 +100,7 @@ class IncomfortWaterHeater(IncomfortEntity, WaterHeaterEntity): try: await self._heater.update() - except (ClientResponseError, asyncio.TimeoutError) as err: + except (ClientResponseError, TimeoutError) as err: _LOGGER.warning("Update failed, message is: %s", err) else: diff --git a/homeassistant/components/ipma/__init__.py b/homeassistant/components/ipma/__init__.py index 4cb8f921ba4..7668802c9e0 100644 --- a/homeassistant/components/ipma/__init__.py +++ b/homeassistant/components/ipma/__init__.py @@ -33,7 +33,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b try: async with asyncio.timeout(30): location = await Location.get(api, float(latitude), float(longitude)) - except (IPMAException, asyncio.TimeoutError) as err: + except (IPMAException, TimeoutError) as err: raise ConfigEntryNotReady( f"Could not get location for ({latitude},{longitude})" ) from err diff --git a/homeassistant/components/ipma/weather.py b/homeassistant/components/ipma/weather.py index f9b93cbe954..866f44f0617 100644 --- a/homeassistant/components/ipma/weather.py +++ b/homeassistant/components/ipma/weather.py @@ -217,7 +217,7 @@ class IPMAWeather(WeatherEntity, IPMADevice): period: int, ) -> None: """Try to update weather forecast.""" - with contextlib.suppress(asyncio.TimeoutError): + with contextlib.suppress(TimeoutError): async with asyncio.timeout(10): await self._update_forecast(forecast_type, period, False) diff --git a/homeassistant/components/isy994/__init__.py b/homeassistant/components/isy994/__init__.py index c611bf83050..0c5ea27a0b9 100644 --- a/homeassistant/components/isy994/__init__.py +++ b/homeassistant/components/isy994/__init__.py @@ -102,7 +102,7 @@ async def async_setup_entry( try: async with asyncio.timeout(60): await isy.initialize() - except asyncio.TimeoutError as err: + except TimeoutError as err: raise ConfigEntryNotReady( "Timed out initializing the ISY; device may be busy, trying again later:" f" {err}" diff --git a/homeassistant/components/izone/config_flow.py b/homeassistant/components/izone/config_flow.py index 8e6fe584456..d56fb93d4e6 100644 --- a/homeassistant/components/izone/config_flow.py +++ b/homeassistant/components/izone/config_flow.py @@ -25,7 +25,7 @@ async def _async_has_devices(hass: HomeAssistant) -> bool: disco = await async_start_discovery_service(hass) - with suppress(asyncio.TimeoutError): + with suppress(TimeoutError): async with asyncio.timeout(TIMEOUT_DISCOVERY): await controller_ready.wait() diff --git a/tests/components/esphome/test_config_flow.py b/tests/components/esphome/test_config_flow.py index 4161e69efd0..04f8dc9e5aa 100644 --- a/tests/components/esphome/test_config_flow.py +++ b/tests/components/esphome/test_config_flow.py @@ -1,5 +1,4 @@ """Test config flow.""" -import asyncio from ipaddress import ip_address import json from unittest.mock import AsyncMock, MagicMock, patch @@ -500,7 +499,7 @@ async def test_user_discovers_name_and_dashboard_is_unavailable( with patch( "esphome_dashboard_api.ESPHomeDashboardAPI.get_devices", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): await dashboard.async_get_dashboard(hass).async_refresh() result = await hass.config_entries.flow.async_init( diff --git a/tests/components/esphome/test_dashboard.py b/tests/components/esphome/test_dashboard.py index 320b20832c8..11db8a73731 100644 --- a/tests/components/esphome/test_dashboard.py +++ b/tests/components/esphome/test_dashboard.py @@ -1,5 +1,4 @@ """Test ESPHome dashboard features.""" -import asyncio from unittest.mock import patch from aioesphomeapi import DeviceInfo, InvalidAuthAPIError @@ -69,7 +68,7 @@ async def test_setup_dashboard_fails( ) -> MockConfigEntry: """Test that nothing is stored on failed dashboard setup when there was no dashboard before.""" with patch.object( - dashboard.ESPHomeDashboardAPI, "get_devices", side_effect=asyncio.TimeoutError + dashboard.ESPHomeDashboardAPI, "get_devices", side_effect=TimeoutError ) as mock_get_devices: await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() @@ -99,7 +98,7 @@ async def test_setup_dashboard_fails_when_already_setup( await hass.async_block_till_done() with patch.object( - dashboard.ESPHomeDashboardAPI, "get_devices", side_effect=asyncio.TimeoutError + dashboard.ESPHomeDashboardAPI, "get_devices", side_effect=TimeoutError ) as mock_get_devices, patch( "homeassistant.components.esphome.async_setup_entry", return_value=True ) as mock_setup: diff --git a/tests/components/esphome/test_update.py b/tests/components/esphome/test_update.py index d267a13145f..842480d9433 100644 --- a/tests/components/esphome/test_update.py +++ b/tests/components/esphome/test_update.py @@ -1,5 +1,4 @@ """Test ESPHome update entities.""" -import asyncio from collections.abc import Awaitable, Callable import dataclasses from unittest.mock import Mock, patch @@ -280,7 +279,7 @@ async def test_update_entity_dashboard_not_available_startup( return_value=Mock(available=True, device_info=mock_device_info), ), patch( "esphome_dashboard_api.ESPHomeDashboardAPI.get_devices", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): await async_get_dashboard(hass).async_refresh() assert await hass.config_entries.async_forward_entry_setup( @@ -324,7 +323,7 @@ async def test_update_entity_dashboard_discovered_after_startup_but_update_faile """Test ESPHome update entity when dashboard is discovered after startup and the first update fails.""" with patch( "esphome_dashboard_api.ESPHomeDashboardAPI.get_devices", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): await async_get_dashboard(hass).async_refresh() await hass.async_block_till_done() diff --git a/tests/components/evil_genius_labs/test_config_flow.py b/tests/components/evil_genius_labs/test_config_flow.py index c3d3c57d324..7826104b326 100644 --- a/tests/components/evil_genius_labs/test_config_flow.py +++ b/tests/components/evil_genius_labs/test_config_flow.py @@ -1,5 +1,4 @@ """Test the Evil Genius Labs config flow.""" -import asyncio from unittest.mock import patch import aiohttp @@ -82,7 +81,7 @@ async def test_form_timeout(hass: HomeAssistant) -> None: with patch( "pyevilgenius.EvilGeniusDevice.get_all", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/flick_electric/test_config_flow.py b/tests/components/flick_electric/test_config_flow.py index 9f212b2a1a9..bd77f1b6002 100644 --- a/tests/components/flick_electric/test_config_flow.py +++ b/tests/components/flick_electric/test_config_flow.py @@ -1,5 +1,4 @@ """Test the Flick Electric config flow.""" -import asyncio from unittest.mock import patch from pyflick.authentication import AuthException @@ -86,7 +85,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: """Test we handle cannot connect error.""" with patch( "homeassistant.components.flick_electric.config_flow.SimpleFlickAuth.async_get_access_token", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): result = await _flow_submit(hass) diff --git a/tests/components/foobot/test_sensor.py b/tests/components/foobot/test_sensor.py index 59fcde57a06..27e56816176 100644 --- a/tests/components/foobot/test_sensor.py +++ b/tests/components/foobot/test_sensor.py @@ -1,5 +1,4 @@ """The tests for the Foobot sensor platform.""" -import asyncio from http import HTTPStatus import re from unittest.mock import MagicMock @@ -65,9 +64,7 @@ async def test_setup_timeout_error( """Expected failures caused by a timeout in API response.""" fake_async_add_entities = MagicMock() - aioclient_mock.get( - re.compile("api.foobot.io/v2/owner/.*"), exc=asyncio.TimeoutError() - ) + aioclient_mock.get(re.compile("api.foobot.io/v2/owner/.*"), exc=TimeoutError()) with pytest.raises(PlatformNotReady): await foobot.async_setup_platform(hass, VALID_CONFIG, fake_async_add_entities) diff --git a/tests/components/fully_kiosk/test_config_flow.py b/tests/components/fully_kiosk/test_config_flow.py index 018a62b5dc7..b66940f9fc7 100644 --- a/tests/components/fully_kiosk/test_config_flow.py +++ b/tests/components/fully_kiosk/test_config_flow.py @@ -1,6 +1,5 @@ """Test the Fully Kiosk Browser config flow.""" -import asyncio from unittest.mock import AsyncMock, MagicMock, Mock from aiohttp.client_exceptions import ClientConnectorError @@ -67,7 +66,7 @@ async def test_user_flow( [ (FullyKioskError("error", "status"), "cannot_connect"), (ClientConnectorError(None, Mock()), "cannot_connect"), - (asyncio.TimeoutError, "cannot_connect"), + (TimeoutError, "cannot_connect"), (RuntimeError, "unknown"), ], ) diff --git a/tests/components/fully_kiosk/test_init.py b/tests/components/fully_kiosk/test_init.py index 2e77cdb2f1d..e74da6434cd 100644 --- a/tests/components/fully_kiosk/test_init.py +++ b/tests/components/fully_kiosk/test_init.py @@ -1,5 +1,4 @@ """Tests for the Fully Kiosk Browser integration.""" -import asyncio import json from unittest.mock import MagicMock, patch @@ -45,7 +44,7 @@ async def test_load_unload_config_entry( @pytest.mark.parametrize( "side_effect", - [FullyKioskError("error", "status"), asyncio.TimeoutError], + [FullyKioskError("error", "status"), TimeoutError], ) async def test_config_entry_not_ready( hass: HomeAssistant, diff --git a/tests/components/generic/test_camera.py b/tests/components/generic/test_camera.py index 5a4bae22e9f..ba7f4d3d4a1 100644 --- a/tests/components/generic/test_camera.py +++ b/tests/components/generic/test_camera.py @@ -249,7 +249,7 @@ async def test_limit_refetch( hass.states.async_set("sensor.temp", "5") with pytest.raises(aiohttp.ServerTimeoutError), patch( - "asyncio.timeout", side_effect=asyncio.TimeoutError() + "asyncio.timeout", side_effect=TimeoutError() ): resp = await client.get("/api/camera_proxy/camera.config_test") diff --git a/tests/components/gogogate2/test_init.py b/tests/components/gogogate2/test_init.py index 1cfbf52284f..5c0755bb91b 100644 --- a/tests/components/gogogate2/test_init.py +++ b/tests/components/gogogate2/test_init.py @@ -1,5 +1,4 @@ """Tests for the GogoGate2 component.""" -import asyncio from unittest.mock import MagicMock, patch from ismartgate import GogoGate2Api @@ -94,6 +93,6 @@ async def test_api_failure_on_startup(hass: HomeAssistant) -> None: with patch( "homeassistant.components.gogogate2.common.ISmartGateApi.async_info", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ), pytest.raises(ConfigEntryNotReady): await async_setup_entry(hass, config_entry) diff --git a/tests/components/govee_light_local/test_light.py b/tests/components/govee_light_local/test_light.py index 1e211610d7a..66f471df267 100644 --- a/tests/components/govee_light_local/test_light.py +++ b/tests/components/govee_light_local/test_light.py @@ -1,6 +1,5 @@ """Test Govee light local.""" -import asyncio from unittest.mock import AsyncMock, MagicMock, patch from govee_local_api import GoveeDevice @@ -133,7 +132,7 @@ async def test_light_setup_retry( with patch( "homeassistant.components.govee_light_local.asyncio.timeout", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): await hass.config_entries.async_setup(entry.entry_id) assert entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/hassio/test_http.py b/tests/components/hassio/test_http.py index 2e14c21f20a..4e1e7436a58 100644 --- a/tests/components/hassio/test_http.py +++ b/tests/components/hassio/test_http.py @@ -1,5 +1,4 @@ """The tests for the hassio component.""" -import asyncio from http import HTTPStatus from unittest.mock import patch @@ -396,7 +395,7 @@ async def test_bad_gateway_when_cannot_find_supervisor( hassio_client, aioclient_mock: AiohttpClientMocker ) -> None: """Test we get a bad gateway error if we can't find supervisor.""" - aioclient_mock.get("http://127.0.0.1/app/entrypoint.js", exc=asyncio.TimeoutError) + aioclient_mock.get("http://127.0.0.1/app/entrypoint.js", exc=TimeoutError) resp = await hassio_client.get("/api/hassio/app/entrypoint.js") assert resp.status == HTTPStatus.BAD_GATEWAY diff --git a/tests/components/hlk_sw16/test_config_flow.py b/tests/components/hlk_sw16/test_config_flow.py index 6e90706eade..d390bcc6c79 100644 --- a/tests/components/hlk_sw16/test_config_flow.py +++ b/tests/components/hlk_sw16/test_config_flow.py @@ -189,7 +189,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: with patch( "homeassistant.components.hlk_sw16.config_flow.connect_client", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, return_value=None, ): result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/honeywell/test_config_flow.py b/tests/components/honeywell/test_config_flow.py index 25ffa0a6093..b76eb1bf1e4 100644 --- a/tests/components/honeywell/test_config_flow.py +++ b/tests/components/honeywell/test_config_flow.py @@ -1,5 +1,4 @@ """Tests for honeywell config flow.""" -import asyncio from unittest.mock import MagicMock, patch import aiosomecomfort @@ -213,7 +212,7 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, client: MagicMock) -> [ aiosomecomfort.device.ConnectionError, aiosomecomfort.device.ConnectionTimeout, - asyncio.TimeoutError, + TimeoutError, ], ) async def test_reauth_flow_connnection_error( diff --git a/tests/components/hue/test_config_flow.py b/tests/components/hue/test_config_flow.py index 51e0a7dde7a..30d2a8c0b42 100644 --- a/tests/components/hue/test_config_flow.py +++ b/tests/components/hue/test_config_flow.py @@ -1,5 +1,4 @@ """Tests for Philips Hue config flow.""" -import asyncio from ipaddress import ip_address from unittest.mock import Mock, patch @@ -254,7 +253,7 @@ async def test_flow_timeout_discovery(hass: HomeAssistant) -> None: """Test config flow .""" with patch( "homeassistant.components.hue.config_flow.discover_nupnp", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): result = await hass.config_entries.flow.async_init( const.DOMAIN, context={"source": config_entries.SOURCE_USER} diff --git a/tests/components/hue/test_light_v1.py b/tests/components/hue/test_light_v1.py index c03e04b633d..d1fd9cdc62f 100644 --- a/tests/components/hue/test_light_v1.py +++ b/tests/components/hue/test_light_v1.py @@ -1,5 +1,4 @@ """Philips Hue lights platform tests.""" -import asyncio from unittest.mock import Mock import aiohue @@ -558,8 +557,8 @@ async def test_other_light_update(hass: HomeAssistant, mock_bridge_v1) -> None: async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1) -> None: """Test bridge marked as not available if timeout error during update.""" - mock_bridge_v1.api.lights.update = Mock(side_effect=asyncio.TimeoutError) - mock_bridge_v1.api.groups.update = Mock(side_effect=asyncio.TimeoutError) + mock_bridge_v1.api.lights.update = Mock(side_effect=TimeoutError) + mock_bridge_v1.api.groups.update = Mock(side_effect=TimeoutError) await setup_bridge(hass, mock_bridge_v1) assert len(mock_bridge_v1.mock_requests) == 0 assert len(hass.states.async_all()) == 0 diff --git a/tests/components/hue/test_sensor_v1.py b/tests/components/hue/test_sensor_v1.py index 1edaf18774f..df8c45119df 100644 --- a/tests/components/hue/test_sensor_v1.py +++ b/tests/components/hue/test_sensor_v1.py @@ -1,5 +1,4 @@ """Philips Hue sensors platform tests.""" -import asyncio from unittest.mock import Mock import aiohue @@ -433,7 +432,7 @@ async def test_sensor_removed(hass: HomeAssistant, mock_bridge_v1) -> None: async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1) -> None: """Test bridge marked as not available if timeout error during update.""" - mock_bridge_v1.api.sensors.update = Mock(side_effect=asyncio.TimeoutError) + mock_bridge_v1.api.sensors.update = Mock(side_effect=TimeoutError) await setup_platform(hass, mock_bridge_v1, ["binary_sensor", "sensor"]) assert len(mock_bridge_v1.mock_requests) == 0 assert len(hass.states.async_all()) == 0 diff --git a/tests/components/hunterdouglas_powerview/test_config_flow.py b/tests/components/hunterdouglas_powerview/test_config_flow.py index 0511e7bf821..5a8017d3276 100644 --- a/tests/components/hunterdouglas_powerview/test_config_flow.py +++ b/tests/components/hunterdouglas_powerview/test_config_flow.py @@ -1,5 +1,4 @@ """Test the Hunter Douglas Powerview config flow.""" -import asyncio from ipaddress import ip_address import json from unittest.mock import AsyncMock, MagicMock, patch @@ -191,9 +190,7 @@ async def test_form_homekit_and_dhcp_cannot_connect( ) ignored_config_entry.add_to_hass(hass) - mock_powerview_userdata = _get_mock_powerview_userdata( - get_resources=asyncio.TimeoutError - ) + mock_powerview_userdata = _get_mock_powerview_userdata(get_resources=TimeoutError) with patch( "homeassistant.components.hunterdouglas_powerview.UserData", return_value=mock_powerview_userdata, @@ -300,9 +297,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - mock_powerview_userdata = _get_mock_powerview_userdata( - get_resources=asyncio.TimeoutError - ) + mock_powerview_userdata = _get_mock_powerview_userdata(get_resources=TimeoutError) with patch( "homeassistant.components.hunterdouglas_powerview.UserData", return_value=mock_powerview_userdata, diff --git a/tests/components/iaqualink/test_init.py b/tests/components/iaqualink/test_init.py index 646e9e4da86..a1e3ee6ac35 100644 --- a/tests/components/iaqualink/test_init.py +++ b/tests/components/iaqualink/test_init.py @@ -1,5 +1,4 @@ """Tests for iAqualink integration.""" -import asyncio import logging from unittest.mock import AsyncMock, patch @@ -56,7 +55,7 @@ async def test_setup_login_timeout(hass: HomeAssistant, config_entry) -> None: with patch( "homeassistant.components.iaqualink.AqualinkClient.login", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/imap/test_config_flow.py b/tests/components/imap/test_config_flow.py index 0561085823d..177aba04950 100644 --- a/tests/components/imap/test_config_flow.py +++ b/tests/components/imap/test_config_flow.py @@ -1,5 +1,4 @@ """Test the imap config flow.""" -import asyncio import ssl from unittest.mock import AsyncMock, patch @@ -117,7 +116,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None: @pytest.mark.parametrize( ("exc", "error"), [ - (asyncio.TimeoutError, "cannot_connect"), + (TimeoutError, "cannot_connect"), (AioImapException(""), "cannot_connect"), (ssl.SSLError, "ssl_error"), ], @@ -306,7 +305,7 @@ async def test_reauth_failed_conn_error(hass: HomeAssistant) -> None: with patch( "homeassistant.components.imap.config_flow.connect_to_server", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -520,7 +519,7 @@ async def test_config_flow_from_with_advanced_settings( with patch( "homeassistant.components.imap.config_flow.connect_to_server", - side_effect=asyncio.TimeoutError, + side_effect=TimeoutError, ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], config diff --git a/tests/components/imap/test_init.py b/tests/components/imap/test_init.py index 8a8ac88c8aa..9c194bf08a0 100644 --- a/tests/components/imap/test_init.py +++ b/tests/components/imap/test_init.py @@ -82,7 +82,7 @@ async def test_entry_startup_and_unload( [ InvalidAuth, InvalidFolder, - asyncio.TimeoutError, + TimeoutError, ], ) async def test_entry_startup_fails( @@ -417,7 +417,7 @@ async def test_late_folder_error( "imap_close", [ AsyncMock(side_effect=AioImapException("Something went wrong")), - AsyncMock(side_effect=asyncio.TimeoutError), + AsyncMock(side_effect=TimeoutError), ], ids=["AioImapException", "TimeoutError"], ) @@ -460,7 +460,7 @@ async def test_handle_cleanup_exception( "imap_wait_server_push_exception", [ AioImapException("Something went wrong"), - asyncio.TimeoutError, + TimeoutError, ], ids=["AioImapException", "TimeoutError"], ) @@ -468,7 +468,7 @@ async def test_lost_connection_with_imap_push( hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mock_imap_protocol: MagicMock, - imap_wait_server_push_exception: AioImapException | asyncio.TimeoutError, + imap_wait_server_push_exception: AioImapException | TimeoutError, ) -> None: """Test error handling when the connection is lost.""" # Mock an error in waiting for a pushed update