diff --git a/homeassistant/components/iaqualink/config_flow.py b/homeassistant/components/iaqualink/config_flow.py index e75508cb772..b828c25c945 100644 --- a/homeassistant/components/iaqualink/config_flow.py +++ b/homeassistant/components/iaqualink/config_flow.py @@ -46,7 +46,7 @@ class AqualinkFlowHandler(ConfigFlow, domain=DOMAIN): pass except AqualinkServiceUnauthorizedException: errors["base"] = "invalid_auth" - except (AqualinkServiceException, httpx.HTTPError): + except AqualinkServiceException, httpx.HTTPError: errors["base"] = "cannot_connect" else: return self.async_create_entry(title=username, data=user_input) diff --git a/homeassistant/components/icloud/config_flow.py b/homeassistant/components/icloud/config_flow.py index f1d7dc47455..d45863547a7 100644 --- a/homeassistant/components/icloud/config_flow.py +++ b/homeassistant/components/icloud/config_flow.py @@ -142,7 +142,7 @@ class IcloudFlowHandler(ConfigFlow, domain=DOMAIN): ) if not devices: raise PyiCloudNoDevicesException # noqa: TRY301 - except (PyiCloudServiceNotActivatedException, PyiCloudNoDevicesException): + except PyiCloudServiceNotActivatedException, PyiCloudNoDevicesException: _LOGGER.error("No device found in the iCloud account: %s", self._username) self.api = None return self.async_abort(reason="no_device") diff --git a/homeassistant/components/igloohome/sensor.py b/homeassistant/components/igloohome/sensor.py index 10a9ece6771..994cd708a51 100644 --- a/homeassistant/components/igloohome/sensor.py +++ b/homeassistant/components/igloohome/sensor.py @@ -61,7 +61,7 @@ class IgloohomeBatteryEntity(IgloohomeBaseEntity, SensorEntity): response = await self.api.get_device_info( deviceId=self.api_device_info.deviceId ) - except (ApiException, ClientError): + except ApiException, ClientError: self._attr_available = False else: self._attr_available = True diff --git a/homeassistant/components/imap/config_flow.py b/homeassistant/components/imap/config_flow.py index df0e63e200a..a7e51e29dab 100644 --- a/homeassistant/components/imap/config_flow.py +++ b/homeassistant/components/imap/config_flow.py @@ -130,7 +130,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 (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 af8fcc91155..157db4da174 100644 --- a/homeassistant/components/imap/coordinator.py +++ b/homeassistant/components/imap/coordinator.py @@ -395,7 +395,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, TimeoutError): + except AioImapException, TimeoutError: if log_error: _LOGGER.debug("Error while cleaning up imap connection") finally: @@ -534,7 +534,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator): async with asyncio.timeout(10): await idle - except (AioImapException, 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/imgw_pib/config_flow.py b/homeassistant/components/imgw_pib/config_flow.py index 78d77737a39..fc4ff0e9f54 100644 --- a/homeassistant/components/imgw_pib/config_flow.py +++ b/homeassistant/components/imgw_pib/config_flow.py @@ -50,7 +50,7 @@ class ImgwPibFlowHandler(ConfigFlow, domain=DOMAIN): hydrological_details=False, ) hydrological_data = await imgwpib.get_hydrological_data() - except (ClientError, TimeoutError, ApiError): + except ClientError, TimeoutError, ApiError: errors["base"] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception") @@ -62,7 +62,7 @@ class ImgwPibFlowHandler(ConfigFlow, domain=DOMAIN): try: imgwpib = await ImgwPib.create(client_session) await imgwpib.update_hydrological_stations() - except (ClientError, TimeoutError, ApiError): + except ClientError, TimeoutError, ApiError: return self.async_abort(reason="cannot_connect") options: list[SelectOptionDict] = [ diff --git a/homeassistant/components/influxdb/__init__.py b/homeassistant/components/influxdb/__init__.py index d0cf7c3f8c9..d2c049e1637 100644 --- a/homeassistant/components/influxdb/__init__.py +++ b/homeassistant/components/influxdb/__init__.py @@ -302,7 +302,7 @@ def _generate_event_to_json(conf: dict) -> Callable[[Event], dict[str, Any] | No # as string add "_str" postfix to the field key try: json[INFLUX_CONF_FIELDS][key] = float(value) - except (ValueError, TypeError): + except ValueError, TypeError: new_key = f"{key}_str" new_value = str(value) json[INFLUX_CONF_FIELDS][new_key] = new_value diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index 49a032899be..4011caaa649 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/sensor.py @@ -170,7 +170,7 @@ class _Right(_IntegrationMethod): def _decimal_state(state: str) -> Decimal | None: try: return Decimal(state) - except (InvalidOperation, TypeError): + except InvalidOperation, TypeError: return None diff --git a/homeassistant/components/intellifire/config_flow.py b/homeassistant/components/intellifire/config_flow.py index 35c3bc09010..f6131ede00a 100644 --- a/homeassistant/components/intellifire/config_flow.py +++ b/homeassistant/components/intellifire/config_flow.py @@ -252,7 +252,7 @@ class IntelliFireConfigFlow(ConfigFlow, domain=DOMAIN): self._dhcp_discovered_serial = await _async_poll_local_fireplace_for_serial( ip_address, dhcp_mode=True ) - except (ConnectionError, ClientConnectionError): + except ConnectionError, ClientConnectionError: LOGGER.debug( "DHCP Discovery has determined %s is not an IntelliFire device", ip_address, diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index 4d0c43242e4..4c3423df378 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -74,7 +74,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): info = await validate_input(self.hass, user_input) except IPPConnectionUpgradeRequired: return self._show_setup_form({"base": "connection_upgrade"}) - except (IPPConnectionError, IPPResponseError): + except IPPConnectionError, IPPResponseError: _LOGGER.debug("IPP Connection/Response Error", exc_info=True) return self._show_setup_form({"base": "cannot_connect"}) except IPPParseError: @@ -142,7 +142,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): info = await validate_input(self.hass, self.discovery_info) except IPPConnectionUpgradeRequired: return self.async_abort(reason="connection_upgrade") - except (IPPConnectionError, IPPResponseError): + except IPPConnectionError, IPPResponseError: _LOGGER.debug("IPP Connection/Response Error", exc_info=True) return self.async_abort(reason="cannot_connect") except IPPParseError: diff --git a/homeassistant/components/iron_os/config_flow.py b/homeassistant/components/iron_os/config_flow.py index bb80f088c96..d8df13d4a55 100644 --- a/homeassistant/components/iron_os/config_flow.py +++ b/homeassistant/components/iron_os/config_flow.py @@ -52,7 +52,7 @@ class IronOSConfigFlow(ConfigFlow, domain=DOMAIN): device = Pynecil(discovery_info.address) try: await device.connect() - except (CommunicationError, BleakError, TimeoutError): + except CommunicationError, BleakError, TimeoutError: _LOGGER.debug("Cannot connect:", exc_info=True) errors["base"] = "cannot_connect" except Exception: @@ -87,7 +87,7 @@ class IronOSConfigFlow(ConfigFlow, domain=DOMAIN): device = Pynecil(address) try: await device.connect() - except (CommunicationError, BleakError, TimeoutError): + except CommunicationError, BleakError, TimeoutError: _LOGGER.debug("Cannot connect:", exc_info=True) errors["base"] = "cannot_connect" except Exception: diff --git a/homeassistant/components/iron_os/coordinator.py b/homeassistant/components/iron_os/coordinator.py index 7214db0a12f..2a94794f2b8 100644 --- a/homeassistant/components/iron_os/coordinator.py +++ b/homeassistant/components/iron_os/coordinator.py @@ -84,7 +84,7 @@ class IronOSBaseCoordinator[_DataT](DataUpdateCoordinator[_DataT]): try: self.device_info = await self.device.get_device_info() - except (CommunicationError, TimeoutError): + except CommunicationError, TimeoutError: self.device_info = DeviceInfoResponse() self.v223_features = ( diff --git a/homeassistant/components/ista_ecotrend/config_flow.py b/homeassistant/components/ista_ecotrend/config_flow.py index ee69e52e580..3eb7c4720b2 100644 --- a/homeassistant/components/ista_ecotrend/config_flow.py +++ b/homeassistant/components/ista_ecotrend/config_flow.py @@ -58,7 +58,7 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN): info = ista.get_account() except ServerError: errors["base"] = "cannot_connect" - except (LoginError, KeycloakError): + except LoginError, KeycloakError: errors["base"] = "invalid_auth" except Exception: _LOGGER.exception("Unexpected exception") @@ -119,7 +119,7 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN): except ServerError: errors["base"] = "cannot_connect" - except (LoginError, KeycloakError): + except LoginError, KeycloakError: errors["base"] = "invalid_auth" except Exception: _LOGGER.exception("Unexpected exception") diff --git a/homeassistant/components/kaleidescape/__init__.py b/homeassistant/components/kaleidescape/__init__.py index c6639e096d7..3f6277b85cc 100644 --- a/homeassistant/components/kaleidescape/__init__.py +++ b/homeassistant/components/kaleidescape/__init__.py @@ -75,7 +75,7 @@ async def validate_host(host: str) -> KaleidescapeDeviceInfo: try: await device.connect() - except (KaleidescapeError, ConnectionError): + except KaleidescapeError, ConnectionError: await device.disconnect() raise diff --git a/homeassistant/components/keyboard_remote/__init__.py b/homeassistant/components/keyboard_remote/__init__.py index 979aeb73e45..7a5eae0eec6 100644 --- a/homeassistant/components/keyboard_remote/__init__.py +++ b/homeassistant/components/keyboard_remote/__init__.py @@ -364,7 +364,7 @@ class KeyboardRemote: ): repeat_tasks[event.code].cancel() del repeat_tasks[event.code] - except (OSError, asyncio.CancelledError): + except OSError, asyncio.CancelledError: # cancel key repeat tasks for task in repeat_tasks.values(): task.cancel() diff --git a/homeassistant/components/knx/config_flow.py b/homeassistant/components/knx/config_flow.py index 5c72fed4820..bcfcbd18a2a 100644 --- a/homeassistant/components/knx/config_flow.py +++ b/homeassistant/components/knx/config_flow.py @@ -442,7 +442,7 @@ class KNXConfigFlow(ConfigFlow, domain=DOMAIN): _host = user_input[CONF_HOST] _host_ip = await xknx_validate_ip(_host) ip_v4_validator(_host_ip, multicast=False) - except (vol.Invalid, XKNXException): + except vol.Invalid, XKNXException: errors[CONF_HOST] = "invalid_ip_address" _local_ip = None @@ -450,7 +450,7 @@ class KNXConfigFlow(ConfigFlow, domain=DOMAIN): try: _local_ip = await xknx_validate_ip(_local) ip_v4_validator(_local_ip, multicast=False) - except (vol.Invalid, XKNXException): + except vol.Invalid, XKNXException: errors[CONF_KNX_LOCAL_IP] = "invalid_ip_address" selected_tunneling_type = user_input[CONF_KNX_TUNNELING_TYPE] @@ -831,7 +831,7 @@ class KNXConfigFlow(ConfigFlow, domain=DOMAIN): try: _local_ip = await xknx_validate_ip(_local) ip_v4_validator(_local_ip, multicast=False) - except (vol.Invalid, XKNXException): + except vol.Invalid, XKNXException: errors[CONF_KNX_LOCAL_IP] = "invalid_ip_address" if not errors: diff --git a/homeassistant/components/kodi/media_player.py b/homeassistant/components/kodi/media_player.py index a6b93436876..52030ec74f2 100644 --- a/homeassistant/components/kodi/media_player.py +++ b/homeassistant/components/kodi/media_player.py @@ -293,7 +293,7 @@ class KodiEntity(MediaPlayerEntity): try: await self._connection.connect() await self._on_ws_connected() - except (TransportError, CannotConnectError): + except TransportError, CannotConnectError: if not self._connect_error: self._connect_error = True _LOGGER.warning("Unable to connect to Kodi via websocket") @@ -304,7 +304,7 @@ class KodiEntity(MediaPlayerEntity): async def _ping(self): try: await self._kodi.ping() - except (TransportError, CannotConnectError): + except TransportError, CannotConnectError: if not self._connect_error: self._connect_error = True _LOGGER.warning("Unable to ping Kodi via websocket") @@ -346,7 +346,7 @@ class KodiEntity(MediaPlayerEntity): try: self._players = await self._kodi.get_players() - except (TransportError, ProtocolError): + except TransportError, ProtocolError: if not self._connection.can_subscribe: self._reset_state() return @@ -836,7 +836,7 @@ class KodiEntity(MediaPlayerEntity): image_url, _, _ = await get_media_info( self._kodi, media_content_id, media_content_type ) - except (ProtocolError, TransportError): + except ProtocolError, TransportError: return (None, None) if image_url: diff --git a/homeassistant/components/kostal_plenticore/config_flow.py b/homeassistant/components/kostal_plenticore/config_flow.py index cce220006c5..b1a993b48a4 100644 --- a/homeassistant/components/kostal_plenticore/config_flow.py +++ b/homeassistant/components/kostal_plenticore/config_flow.py @@ -62,7 +62,7 @@ class KostalPlenticoreConfigFlow(ConfigFlow, domain=DOMAIN): except AuthenticationException as ex: errors[CONF_PASSWORD] = "invalid_auth" _LOGGER.error("Error response: %s", ex) - except (ClientError, TimeoutError): + except ClientError, TimeoutError: errors[CONF_HOST] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception") @@ -87,7 +87,7 @@ class KostalPlenticoreConfigFlow(ConfigFlow, domain=DOMAIN): except AuthenticationException as ex: errors[CONF_PASSWORD] = "invalid_auth" _LOGGER.error("Error response: %s", ex) - except (ClientError, TimeoutError): + except ClientError, TimeoutError: errors[CONF_HOST] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception") diff --git a/homeassistant/components/kostal_plenticore/helper.py b/homeassistant/components/kostal_plenticore/helper.py index eaa2a271de4..1324cf5cd07 100644 --- a/homeassistant/components/kostal_plenticore/helper.py +++ b/homeassistant/components/kostal_plenticore/helper.py @@ -53,7 +53,7 @@ class PlenticoreDataFormatter: """Return the given state value as rounded integer.""" try: return round(float(state)) - except (TypeError, ValueError): + except TypeError, ValueError: return state @staticmethod @@ -68,7 +68,7 @@ class PlenticoreDataFormatter: int_value = round(value) return str(int_value) - except (TypeError, ValueError): + except TypeError, ValueError: return "" @staticmethod @@ -76,7 +76,7 @@ class PlenticoreDataFormatter: """Return the given state value as float rounded to three decimal places.""" try: return round(float(state), 3) - except (TypeError, ValueError): + except TypeError, ValueError: return state @staticmethod @@ -84,7 +84,7 @@ class PlenticoreDataFormatter: """Return the given state value as energy value, scaled to kWh.""" try: return round(float(state) / 1000, 1) - except (TypeError, ValueError): + except TypeError, ValueError: return state @staticmethod @@ -92,7 +92,7 @@ class PlenticoreDataFormatter: """Return a readable string of the inverter state.""" try: value = int(state) - except (TypeError, ValueError): + except TypeError, ValueError: return state return PlenticoreDataFormatter.INVERTER_STATES.get(value) @@ -102,7 +102,7 @@ class PlenticoreDataFormatter: """Return a readable state of the energy manager.""" try: value = int(state) - except (TypeError, ValueError): + except TypeError, ValueError: return state return PlenticoreDataFormatter.EM_STATES.get(value) diff --git a/homeassistant/components/lg_netcast/media_player.py b/homeassistant/components/lg_netcast/media_player.py index ca533a0e3c3..9383c0e6bd1 100644 --- a/homeassistant/components/lg_netcast/media_player.py +++ b/homeassistant/components/lg_netcast/media_player.py @@ -108,7 +108,7 @@ class LgTVDevice(MediaPlayerEntity): try: with self._client as client: client.send_command(command) - except (LgNetCastError, RequestException): + except LgNetCastError, RequestException: self._attr_state = MediaPlayerState.OFF def update(self) -> None: @@ -150,7 +150,7 @@ class LgTVDevice(MediaPlayerEntity): source_tuples, key=lambda channel: int(channel[1]) ) self._source_names = [n for n, k in sorted_sources] - except (LgNetCastError, RequestException): + except LgNetCastError, RequestException: self._attr_state = MediaPlayerState.OFF def __update_volume(self): diff --git a/homeassistant/components/lg_thinq/mqtt.py b/homeassistant/components/lg_thinq/mqtt.py index d6ff1f72b8f..1eebf5fe863 100644 --- a/homeassistant/components/lg_thinq/mqtt.py +++ b/homeassistant/components/lg_thinq/mqtt.py @@ -60,7 +60,7 @@ class ThinQMQTT: if self.client is not None: try: await self.client.async_disconnect() - except (ThinQAPIException, TypeError, ValueError): + except ThinQAPIException, TypeError, ValueError: _LOGGER.exception("Failed to disconnect") def _get_failed_device_count( diff --git a/homeassistant/components/lidarr/config_flow.py b/homeassistant/components/lidarr/config_flow.py index dfbfff2cdfd..dda24c0a7e2 100644 --- a/homeassistant/components/lidarr/config_flow.py +++ b/homeassistant/components/lidarr/config_flow.py @@ -51,7 +51,7 @@ class LidarrConfigFlow(ConfigFlow, domain=DOMAIN): user_input[CONF_API_KEY] = result[1] except exceptions.ArrAuthenticationException: errors = {"base": "invalid_auth"} - except (ClientConnectorError, exceptions.ArrConnectionException): + except ClientConnectorError, exceptions.ArrConnectionException: errors = {"base": "cannot_connect"} except exceptions.ArrWrongAppException: errors = {"base": "wrong_app"} diff --git a/homeassistant/components/lifx_cloud/scene.py b/homeassistant/components/lifx_cloud/scene.py index f6ba01dbdae..b3c36b051f4 100644 --- a/homeassistant/components/lifx_cloud/scene.py +++ b/homeassistant/components/lifx_cloud/scene.py @@ -51,7 +51,7 @@ async def async_setup_platform( async with asyncio.timeout(timeout): scenes_resp = await httpsession.get(url, headers=headers) - except (TimeoutError, aiohttp.ClientError): + except TimeoutError, aiohttp.ClientError: _LOGGER.exception("Error on %s", url) return @@ -93,5 +93,5 @@ class LifxCloudScene(Scene): async with asyncio.timeout(self._timeout): await httpsession.put(url, headers=self._headers) - except (TimeoutError, aiohttp.ClientError): + except TimeoutError, aiohttp.ClientError: _LOGGER.exception("Error on %s", url) diff --git a/homeassistant/components/linksys_smart/device_tracker.py b/homeassistant/components/linksys_smart/device_tracker.py index c3b0b666d50..dd97a0dd033 100644 --- a/homeassistant/components/linksys_smart/device_tracker.py +++ b/homeassistant/components/linksys_smart/device_tracker.py @@ -93,7 +93,7 @@ class LinksysSmartWifiDeviceScanner(DeviceScanner): _LOGGER.debug("Device %s is connected", mac) self.last_results[mac] = name - except (KeyError, IndexError): + except KeyError, IndexError: _LOGGER.exception("Router returned unexpected response") return False return True diff --git a/homeassistant/components/lookin/config_flow.py b/homeassistant/components/lookin/config_flow.py index abf2982765d..6aafc89d0b0 100644 --- a/homeassistant/components/lookin/config_flow.py +++ b/homeassistant/components/lookin/config_flow.py @@ -38,7 +38,7 @@ class LookinFlowHandler(ConfigFlow, domain=DOMAIN): try: device: Device = await self._validate_device(host=host) - except (aiohttp.ClientError, NoUsableService): + except aiohttp.ClientError, NoUsableService: return self.async_abort(reason="cannot_connect") except Exception: LOGGER.exception("Unexpected exception") @@ -63,7 +63,7 @@ class LookinFlowHandler(ConfigFlow, domain=DOMAIN): host = user_input[CONF_HOST] try: device = await self._validate_device(host=host) - except (aiohttp.ClientError, NoUsableService): + except aiohttp.ClientError, NoUsableService: errors[CONF_HOST] = "cannot_connect" except Exception: LOGGER.exception("Unexpected exception") diff --git a/homeassistant/components/lovelace/__init__.py b/homeassistant/components/lovelace/__init__.py index 4d8ec18c992..295042405ee 100644 --- a/homeassistant/components/lovelace/__init__.py +++ b/homeassistant/components/lovelace/__init__.py @@ -432,7 +432,7 @@ async def _async_migrate_default_config( CONF_URL_PATH: DOMAIN, } ) - except (HomeAssistantError, vol.Invalid): + except HomeAssistantError, vol.Invalid: _LOGGER.exception("Failed to create dashboard entry during migration") return diff --git a/homeassistant/components/madvr/sensor.py b/homeassistant/components/madvr/sensor.py index 783004f3b84..2f0d9f17507 100644 --- a/homeassistant/components/madvr/sensor.py +++ b/homeassistant/components/madvr/sensor.py @@ -57,7 +57,7 @@ def get_temperature(coordinator: MadVRCoordinator, key: str) -> float | None: """Get temperature value if valid, otherwise return None.""" try: temp = float(coordinator.data.get(key, 0)) - except (AttributeError, ValueError): + except AttributeError, ValueError: return None else: return temp if is_valid_temperature(temp) else None diff --git a/homeassistant/components/maxcube/climate.py b/homeassistant/components/maxcube/climate.py index c20a855d656..862e811fb6f 100644 --- a/homeassistant/components/maxcube/climate.py +++ b/homeassistant/components/maxcube/climate.py @@ -149,7 +149,7 @@ class MaxCubeClimate(ClimateEntity): with self._cubehandle.mutex: try: self._cubehandle.cube.set_temperature_mode(self._device, temp, mode) - except (TimeoutError, OSError): + except TimeoutError, OSError: _LOGGER.error("Setting HVAC mode failed") @property diff --git a/homeassistant/components/melcloud/config_flow.py b/homeassistant/components/melcloud/config_flow.py index 87fe14dce81..22dce40c5d6 100644 --- a/homeassistant/components/melcloud/config_flow.py +++ b/homeassistant/components/melcloud/config_flow.py @@ -54,7 +54,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): if err.status in (HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN): return self.async_abort(reason="invalid_auth") return self.async_abort(reason="cannot_connect") - except (TimeoutError, ClientError): + except TimeoutError, ClientError: return self.async_abort(reason="cannot_connect") except AttributeError: # python-melcloud library bug: login() raises AttributeError on invalid @@ -131,7 +131,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): errors["base"] = "invalid_auth" else: errors["base"] = "cannot_connect" - except (TimeoutError, ClientError): + except TimeoutError, ClientError: errors["base"] = "cannot_connect" return acquired_token, errors diff --git a/homeassistant/components/min_max/sensor.py b/homeassistant/components/min_max/sensor.py index 8fea92902ed..4664dd00d1b 100644 --- a/homeassistant/components/min_max/sensor.py +++ b/homeassistant/components/min_max/sensor.py @@ -365,7 +365,7 @@ class MinMaxSensor(SensorEntity): device_classes.append(SensorDeviceClass(device_class)) else: device_classes.append(None) - except (HomeAssistantError, ValueError): + except HomeAssistantError, ValueError: # If we can't get device class for any entity, don't set it device_classes.append(None) diff --git a/homeassistant/components/mjpeg/config_flow.py b/homeassistant/components/mjpeg/config_flow.py index a0efb56c224..5afd796f73f 100644 --- a/homeassistant/components/mjpeg/config_flow.py +++ b/homeassistant/components/mjpeg/config_flow.py @@ -123,7 +123,7 @@ async def async_validate_input( ) except InvalidAuth: errors["username"] = "invalid_auth" - except (OSError, HTTPError, Timeout): + except OSError, HTTPError, Timeout: LOGGER.exception("Cannot connect to %s", user_input[CONF_MJPEG_URL]) errors[field] = "cannot_connect" diff --git a/homeassistant/components/modbus/validators.py b/homeassistant/components/modbus/validators.py index a9e246c2c96..e2833f06ec2 100644 --- a/homeassistant/components/modbus/validators.py +++ b/homeassistant/components/modbus/validators.py @@ -226,7 +226,7 @@ def nan_validator(value: Any) -> int: return value try: return int(value) - except (TypeError, ValueError): + except TypeError, ValueError: pass try: return int(value, 16) diff --git a/homeassistant/components/moehlenhoff_alpha2/config_flow.py b/homeassistant/components/moehlenhoff_alpha2/config_flow.py index 3651885e4e1..2b6be9f9b1c 100644 --- a/homeassistant/components/moehlenhoff_alpha2/config_flow.py +++ b/homeassistant/components/moehlenhoff_alpha2/config_flow.py @@ -26,7 +26,7 @@ async def validate_input(data: dict[str, Any]) -> dict[str, str]: base = Alpha2Base(data[CONF_HOST]) try: await base.update_data() - except (aiohttp.client_exceptions.ClientConnectorError, TimeoutError): + except aiohttp.client_exceptions.ClientConnectorError, TimeoutError: return {"error": "cannot_connect"} except Exception: _LOGGER.exception("Unexpected exception") diff --git a/homeassistant/components/monzo/sensor.py b/homeassistant/components/monzo/sensor.py index 0b6ab2b70a5..e17f72dd4ac 100644 --- a/homeassistant/components/monzo/sensor.py +++ b/homeassistant/components/monzo/sensor.py @@ -115,7 +115,7 @@ class MonzoSensor(MonzoBaseEntity, SensorEntity): try: state = self.entity_description.value_fn(self.data) - except (KeyError, ValueError): + except KeyError, ValueError: return None return state diff --git a/homeassistant/components/motion_blinds/coordinator.py b/homeassistant/components/motion_blinds/coordinator.py index 79e26e5aed4..8de793c405f 100644 --- a/homeassistant/components/motion_blinds/coordinator.py +++ b/homeassistant/components/motion_blinds/coordinator.py @@ -52,7 +52,7 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator): """Fetch data from gateway.""" try: self._gateway.Update() - except (TimeoutError, ParseException): + except TimeoutError, ParseException: # let the error be logged and handled by the motionblinds library return {ATTR_AVAILABLE: False} @@ -67,7 +67,7 @@ class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator): blind.Update() else: blind.Update_trigger() - except (TimeoutError, ParseException): + except TimeoutError, ParseException: # let the error be logged and handled by the motionblinds library return {ATTR_AVAILABLE: False} diff --git a/homeassistant/components/motioneye/__init__.py b/homeassistant/components/motioneye/__init__.py index fec176847da..9984175fde9 100644 --- a/homeassistant/components/motioneye/__init__.py +++ b/homeassistant/components/motioneye/__init__.py @@ -400,7 +400,7 @@ async def handle_webhook( try: data = await request.json() - except (json.decoder.JSONDecodeError, UnicodeDecodeError): + except json.decoder.JSONDecodeError, UnicodeDecodeError: return Response( text="Could not decode request", status=HTTPStatus.BAD_REQUEST, diff --git a/homeassistant/components/motionmount/config_flow.py b/homeassistant/components/motionmount/config_flow.py index 283f1f01d6e..c7cb76779de 100644 --- a/homeassistant/components/motionmount/config_flow.py +++ b/homeassistant/components/motionmount/config_flow.py @@ -52,7 +52,7 @@ class MotionMountFlowHandler(ConfigFlow, domain=DOMAIN): info = {} try: info = await self._validate_input_connect(self.connection_data) - except (ConnectionError, socket.gaierror): + except ConnectionError, socket.gaierror: return self.async_abort(reason="cannot_connect") except TimeoutError: return self.async_abort(reason="time_out") @@ -118,7 +118,7 @@ class MotionMountFlowHandler(ConfigFlow, domain=DOMAIN): try: info = await self._validate_input_connect(self.connection_data) - except (ConnectionError, socket.gaierror): + except ConnectionError, socket.gaierror: return self.async_abort(reason="cannot_connect") except TimeoutError: return self.async_abort(reason="time_out") diff --git a/homeassistant/components/motionmount/select.py b/homeassistant/components/motionmount/select.py index d02b286c296..916e037a6e5 100644 --- a/homeassistant/components/motionmount/select.py +++ b/homeassistant/components/motionmount/select.py @@ -69,7 +69,7 @@ class MotionMountPresets(MotionMountEntity, SelectEntity): return True try: await self.mm.connect() - except (ConnectionError, TimeoutError, socket.gaierror): + except ConnectionError, TimeoutError, socket.gaierror: # We're not interested in exceptions here. In case of a failed connection # the try/except from the caller will report it. # The purpose of `_ensure_connected()` is only to make sure we try to diff --git a/homeassistant/components/music_assistant/config_flow.py b/homeassistant/components/music_assistant/config_flow.py index 6404071cd17..74a6c84dd50 100644 --- a/homeassistant/components/music_assistant/config_flow.py +++ b/homeassistant/components/music_assistant/config_flow.py @@ -214,7 +214,7 @@ class MusicAssistantConfigFlow(ConfigFlow, domain=DOMAIN): try: # Parse zeroconf properties (strings) to ServerInfoMessage server_info = _parse_zeroconf_server_info(discovery_info.properties) - except (LookupError, KeyError, ValueError): + except LookupError, KeyError, ValueError: return self.async_abort(reason="invalid_discovery_info") if server_info.schema_version >= HASSIO_DISCOVERY_SCHEMA_VERSION: @@ -321,7 +321,7 @@ class MusicAssistantConfigFlow(ConfigFlow, domain=DOMAIN): aiohttp_session=session, ) LOGGER.debug("Successfully created long-lived token") - except (TimeoutError, CannotConnect): + except TimeoutError, CannotConnect: return self.async_abort(reason="cannot_connect") except (AuthenticationFailed, InvalidToken) as err: LOGGER.error("Authentication failed: %s", err) @@ -364,7 +364,7 @@ class MusicAssistantConfigFlow(ConfigFlow, domain=DOMAIN): return self.async_abort(reason="cannot_connect") except InvalidServerVersion: return self.async_abort(reason="invalid_server_version") - except (AuthenticationFailed, InvalidToken): + except AuthenticationFailed, InvalidToken: errors["base"] = "auth_failed" except MusicAssistantClientException: LOGGER.exception("Unexpected exception during manual auth") diff --git a/homeassistant/components/nam/config_flow.py b/homeassistant/components/nam/config_flow.py index b90426b66e5..a13757234bc 100644 --- a/homeassistant/components/nam/config_flow.py +++ b/homeassistant/components/nam/config_flow.py @@ -61,7 +61,7 @@ class NAMFlowHandler(ConfigFlow, domain=DOMAIN): try: nam = await async_get_nam(self.hass, self.host, {}) - except (ApiError, ClientConnectorError, TimeoutError): + except ApiError, ClientConnectorError, TimeoutError: errors["base"] = "cannot_connect" except CannotGetMacError: return self.async_abort(reason="device_unsupported") @@ -96,7 +96,7 @@ class NAMFlowHandler(ConfigFlow, domain=DOMAIN): nam = await async_get_nam(self.hass, self.host, user_input) except AuthFailedError: errors["base"] = "invalid_auth" - except (ApiError, ClientConnectorError, TimeoutError): + except ApiError, ClientConnectorError, TimeoutError: errors["base"] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception") @@ -126,7 +126,7 @@ class NAMFlowHandler(ConfigFlow, domain=DOMAIN): try: nam = await async_get_nam(self.hass, self.host, {}) - except (ApiError, ClientConnectorError, TimeoutError): + except ApiError, ClientConnectorError, TimeoutError: return self.async_abort(reason="cannot_connect") except CannotGetMacError: return self.async_abort(reason="device_unsupported") @@ -208,7 +208,7 @@ class NAMFlowHandler(ConfigFlow, domain=DOMAIN): if user_input is not None: try: nam = await async_get_nam(self.hass, user_input[CONF_HOST], {}) - except (ApiError, ClientConnectorError, TimeoutError): + except ApiError, ClientConnectorError, TimeoutError: errors["base"] = "cannot_connect" else: await self.async_set_unique_id(format_mac(nam.mac)) diff --git a/homeassistant/components/nederlandse_spoorwegen/config_flow.py b/homeassistant/components/nederlandse_spoorwegen/config_flow.py index 6f498fe637c..34872509aea 100644 --- a/homeassistant/components/nederlandse_spoorwegen/config_flow.py +++ b/homeassistant/components/nederlandse_spoorwegen/config_flow.py @@ -60,7 +60,7 @@ class NSConfigFlow(ConfigFlow, domain=DOMAIN): await self.hass.async_add_executor_job(client.get_stations) except HTTPError: errors["base"] = "invalid_auth" - except (RequestsConnectionError, Timeout): + except RequestsConnectionError, Timeout: errors["base"] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception validating API key") @@ -142,7 +142,7 @@ class NSConfigFlow(ConfigFlow, domain=DOMAIN): stations = await self.hass.async_add_executor_job(client.get_stations) except HTTPError: return self.async_abort(reason="invalid_auth") - except (RequestsConnectionError, Timeout): + except RequestsConnectionError, Timeout: return self.async_abort(reason="cannot_connect") except Exception: _LOGGER.exception("Unexpected exception validating API key") @@ -205,7 +205,7 @@ class RouteSubentryFlowHandler(ConfigSubentryFlow): client.get_stations ) } - except (RequestsConnectionError, Timeout, HTTPError, ValueError): + except RequestsConnectionError, Timeout, HTTPError, ValueError: return self.async_abort(reason="cannot_connect") options = [ diff --git a/homeassistant/components/neurio_energy/sensor.py b/homeassistant/components/neurio_energy/sensor.py index f4943b856cb..4d763263469 100644 --- a/homeassistant/components/neurio_energy/sensor.py +++ b/homeassistant/components/neurio_energy/sensor.py @@ -139,7 +139,7 @@ class NeurioData: sample = self.neurio_client.get_samples_live_last(self.sensor_id) self._active_power = sample["consumptionPower"] self._active_generation = sample.get("generationPower") - except (requests.exceptions.RequestException, ValueError, KeyError): + except requests.exceptions.RequestException, ValueError, KeyError: _LOGGER.warning("Could not update current power usage") def get_daily_usage(self) -> None: @@ -155,7 +155,7 @@ class NeurioData: history = self.neurio_client.get_samples_stats( self.sensor_id, start_time, "days", end_time ) - except (requests.exceptions.RequestException, ValueError, KeyError): + except requests.exceptions.RequestException, ValueError, KeyError: _LOGGER.warning("Could not update daily power usage") return diff --git a/homeassistant/components/nextcloud/config_flow.py b/homeassistant/components/nextcloud/config_flow.py index 6c59dd271d5..b67b4ff5882 100644 --- a/homeassistant/components/nextcloud/config_flow.py +++ b/homeassistant/components/nextcloud/config_flow.py @@ -60,7 +60,7 @@ class NextcloudConfigFlow(ConfigFlow, domain=DOMAIN): await self.hass.async_add_executor_job(self._try_connect_nc, user_input) except NextcloudMonitorAuthorizationError: errors["base"] = "invalid_auth" - except (NextcloudMonitorConnectionError, NextcloudMonitorRequestError): + except NextcloudMonitorConnectionError, NextcloudMonitorRequestError: errors["base"] = "connection_error" else: return self.async_create_entry( @@ -93,7 +93,7 @@ class NextcloudConfigFlow(ConfigFlow, domain=DOMAIN): ) except NextcloudMonitorAuthorizationError: errors["base"] = "invalid_auth" - except (NextcloudMonitorConnectionError, NextcloudMonitorRequestError): + except NextcloudMonitorConnectionError, NextcloudMonitorRequestError: errors["base"] = "connection_error" else: return self.async_update_reload_and_abort( diff --git a/homeassistant/components/nextdns/config_flow.py b/homeassistant/components/nextdns/config_flow.py index 637e698f112..9401a735935 100644 --- a/homeassistant/components/nextdns/config_flow.py +++ b/homeassistant/components/nextdns/config_flow.py @@ -49,7 +49,7 @@ async def async_validate_new_api_key( await async_init_nextdns(hass, user_input[CONF_API_KEY], profile_id) except InvalidApiKeyError: errors["base"] = "invalid_api_key" - except (ApiError, ClientConnectorError, RetryError, TimeoutError): + except ApiError, ClientConnectorError, RetryError, TimeoutError: errors["base"] = "cannot_connect" except ProfileNotAvailable: errors["base"] = "profile_not_available" @@ -82,7 +82,7 @@ class NextDnsFlowHandler(ConfigFlow, domain=DOMAIN): self.nextdns = await async_init_nextdns(self.hass, self.api_key) except InvalidApiKeyError: errors["base"] = "invalid_api_key" - except (ApiError, ClientConnectorError, RetryError, TimeoutError): + except ApiError, ClientConnectorError, RetryError, TimeoutError: errors["base"] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception") diff --git a/homeassistant/components/nintendo_parental_controls/config_flow.py b/homeassistant/components/nintendo_parental_controls/config_flow.py index 936bc1772c0..f40c5d4712a 100644 --- a/homeassistant/components/nintendo_parental_controls/config_flow.py +++ b/homeassistant/components/nintendo_parental_controls/config_flow.py @@ -41,7 +41,7 @@ class NintendoConfigFlow(ConfigFlow, domain=DOMAIN): ) try: await self.auth.async_complete_login(user_input[CONF_API_TOKEN]) - except (ValueError, InvalidSessionTokenException, HttpException): + except ValueError, InvalidSessionTokenException, HttpException: errors["base"] = "invalid_auth" else: if TYPE_CHECKING: @@ -90,7 +90,7 @@ class NintendoConfigFlow(ConfigFlow, domain=DOMAIN): if user_input is not None: try: await self.auth.async_complete_login(user_input[CONF_API_TOKEN]) - except (ValueError, InvalidSessionTokenException, HttpException): + except ValueError, InvalidSessionTokenException, HttpException: errors["base"] = "invalid_auth" else: return self.async_update_reload_and_abort( diff --git a/homeassistant/components/nissan_leaf/__init__.py b/homeassistant/components/nissan_leaf/__init__.py index 4f24cde0578..e94b6d20016 100644 --- a/homeassistant/components/nissan_leaf/__init__.py +++ b/homeassistant/components/nissan_leaf/__init__.py @@ -417,7 +417,7 @@ class LeafDataStore: except CarwingsError: _LOGGER.error("An error occurred getting battery status") return None - except (KeyError, TypeError): + except KeyError, TypeError: _LOGGER.error("An error occurred parsing response from server") return None return server_info diff --git a/homeassistant/components/nrgkick/sensor.py b/homeassistant/components/nrgkick/sensor.py index 61bca4a5fc6..090a1f19c3f 100644 --- a/homeassistant/components/nrgkick/sensor.py +++ b/homeassistant/components/nrgkick/sensor.py @@ -88,7 +88,7 @@ def _seconds_to_stable_timestamp(value: StateType) -> datetime | None: try: return _seconds_to_stable_datetime(cast(int, value)) - except (TypeError, OverflowError): + except TypeError, OverflowError: return None diff --git a/homeassistant/components/oem/climate.py b/homeassistant/components/oem/climate.py index e5ccdf6ede8..a1d82ab763c 100644 --- a/homeassistant/components/oem/climate.py +++ b/homeassistant/components/oem/climate.py @@ -57,7 +57,7 @@ def setup_platform( try: therm = Thermostat(host, port=port, username=username, password=password) - except (ValueError, AssertionError, requests.RequestException): + except ValueError, AssertionError, requests.RequestException: return add_entities((ThermostatDevice(therm, name),), True) diff --git a/homeassistant/components/ollama/config_flow.py b/homeassistant/components/ollama/config_flow.py index bf953d54016..84f56d966f4 100644 --- a/homeassistant/components/ollama/config_flow.py +++ b/homeassistant/components/ollama/config_flow.py @@ -112,7 +112,7 @@ class OllamaConfigFlow(ConfigFlow, domain=DOMAIN): client = ollama.AsyncClient(host=url, verify=get_default_context()) async with asyncio.timeout(DEFAULT_TIMEOUT): await client.list() - except (TimeoutError, httpx.ConnectError): + except TimeoutError, httpx.ConnectError: errors["base"] = "cannot_connect" except Exception: _LOGGER.exception("Unexpected exception") @@ -182,7 +182,7 @@ class OllamaSubentryFlowHandler(ConfigSubentryFlow): downloaded_models: set[str] = { model_info["model"] for model_info in response.get("models", []) } - except (TimeoutError, httpx.ConnectError, httpx.HTTPError): + except TimeoutError, httpx.ConnectError, httpx.HTTPError: _LOGGER.exception("Failed to get models from Ollama server") return self.async_abort(reason="cannot_connect") diff --git a/homeassistant/components/onvif/__init__.py b/homeassistant/components/onvif/__init__.py index 83dc238d2c4..39ffb97e09d 100644 --- a/homeassistant/components/onvif/__init__.py +++ b/homeassistant/components/onvif/__init__.py @@ -122,7 +122,7 @@ async def _async_stop_device(hass: HomeAssistant, device: ONVIFDevice) -> None: if device.capabilities.events and device.events.started: try: await device.events.async_stop() - except (TimeoutError, ONVIFError, Fault, aiohttp.ClientError, TransportError): + except TimeoutError, ONVIFError, Fault, aiohttp.ClientError, TransportError: LOGGER.warning("Error while stopping events: %s", device.name) await device.device.close() diff --git a/homeassistant/components/onvif/device.py b/homeassistant/components/onvif/device.py index 2e695a3241e..47f23da7f99 100644 --- a/homeassistant/components/onvif/device.py +++ b/homeassistant/components/onvif/device.py @@ -220,7 +220,7 @@ class ONVIFDevice: LOGGER.debug("%s: SetSystemDateAndTime: success", self.name) # Some cameras don't support setting the timezone and will throw an IndexError # if we try to set it. If we get an error, try again without the timezone. - except (IndexError, Fault): + except IndexError, Fault: if idx == timezone_max_idx: raise else: @@ -303,7 +303,7 @@ class ONVIFDevice: # Set Date and Time ourselves if Date and Time is set manually in the camera. try: await self.async_manually_set_date_and_time() - except (TimeoutError, aiohttp.ClientError, TransportError, IndexError, Fault): + except TimeoutError, aiohttp.ClientError, TransportError, IndexError, Fault: LOGGER.warning("%s: Could not sync date/time on this camera", self.name) self._async_log_time_out_of_sync(cam_date_utc, system_date) diff --git a/homeassistant/components/openalpr_cloud/image_processing.py b/homeassistant/components/openalpr_cloud/image_processing.py index f541ee0b515..3594555ebc4 100644 --- a/homeassistant/components/openalpr_cloud/image_processing.py +++ b/homeassistant/components/openalpr_cloud/image_processing.py @@ -199,7 +199,7 @@ class OpenAlprCloudEntity(ImageProcessingAlprEntity): _LOGGER.error("Error %d -> %s", request.status, data.get("error")) return - except (TimeoutError, aiohttp.ClientError): + except TimeoutError, aiohttp.ClientError: _LOGGER.error("Timeout for OpenALPR API") return diff --git a/homeassistant/components/openhome/media_player.py b/homeassistant/components/openhome/media_player.py index def1019a4f6..746468730ef 100644 --- a/homeassistant/components/openhome/media_player.py +++ b/homeassistant/components/openhome/media_player.py @@ -74,7 +74,7 @@ def catch_request_errors[_OpenhomeDeviceT: OpenhomeDevice, **_P, _R]() -> Callab """Catch TimeoutError, aiohttp.ClientError, UpnpError errors.""" try: return await func(self, *args, **kwargs) - except (TimeoutError, aiohttp.ClientError, UpnpError): + except TimeoutError, aiohttp.ClientError, UpnpError: _LOGGER.error("Error during call %s", func.__name__) return None @@ -169,7 +169,7 @@ class OpenhomeDevice(MediaPlayerEntity): self._attr_state = MediaPlayerState.PLAYING self._attr_available = True - except (TimeoutError, aiohttp.ClientError, UpnpError): + except TimeoutError, aiohttp.ClientError, UpnpError: self._attr_available = False @catch_request_errors() diff --git a/homeassistant/components/opentherm_gw/config_flow.py b/homeassistant/components/opentherm_gw/config_flow.py index a100dcb730f..688f7ac0d85 100644 --- a/homeassistant/components/opentherm_gw/config_flow.py +++ b/homeassistant/components/opentherm_gw/config_flow.py @@ -82,7 +82,7 @@ class OpenThermGwConfigFlow(ConfigFlow, domain=DOMAIN): await test_connection() except TimeoutError: return self._show_form({"base": "timeout_connect"}) - except (ConnectionError, SerialException): + except ConnectionError, SerialException: return self._show_form({"base": "cannot_connect"}) return self._create_entry(gw_id, name, device) diff --git a/homeassistant/components/ourgroceries/config_flow.py b/homeassistant/components/ourgroceries/config_flow.py index 233ec381556..893970800b4 100644 --- a/homeassistant/components/ourgroceries/config_flow.py +++ b/homeassistant/components/ourgroceries/config_flow.py @@ -39,7 +39,7 @@ class OurGroceriesConfigFlow(ConfigFlow, domain=DOMAIN): og = OurGroceries(user_input[CONF_USERNAME], user_input[CONF_PASSWORD]) try: await og.login() - except (TimeoutError, ClientError): + except TimeoutError, ClientError: errors["base"] = "cannot_connect" except InvalidLoginException: errors["base"] = "invalid_auth" diff --git a/homeassistant/components/overkiz/config_flow.py b/homeassistant/components/overkiz/config_flow.py index e5fca781433..b04e9436c4d 100644 --- a/homeassistant/components/overkiz/config_flow.py +++ b/homeassistant/components/overkiz/config_flow.py @@ -164,7 +164,7 @@ class OverkizConfigFlow(ConfigFlow, domain=DOMAIN): errors["base"] = "unsupported_hardware" else: errors["base"] = "invalid_auth" - except (TimeoutError, ClientError): + except TimeoutError, ClientError: errors["base"] = "cannot_connect" except MaintenanceException: errors["base"] = "server_in_maintenance" diff --git a/homeassistant/components/p1_monitor/coordinator.py b/homeassistant/components/p1_monitor/coordinator.py index 3be78f8efd5..e62d10e5811 100644 --- a/homeassistant/components/p1_monitor/coordinator.py +++ b/homeassistant/components/p1_monitor/coordinator.py @@ -81,7 +81,7 @@ class P1MonitorDataUpdateCoordinator(DataUpdateCoordinator[P1MonitorData]): try: data[SERVICE_WATERMETER] = await self.p1monitor.watermeter() self.has_water_meter = True - except (P1MonitorNoDataError, P1MonitorConnectionError): + except P1MonitorNoDataError, P1MonitorConnectionError: LOGGER.debug("No water meter data received from P1 Monitor") if self.has_water_meter is None: self.has_water_meter = False diff --git a/homeassistant/components/panasonic_viera/__init__.py b/homeassistant/components/panasonic_viera/__init__.py index 6dacc08077d..2d0a2b9d26b 100644 --- a/homeassistant/components/panasonic_viera/__init__.py +++ b/homeassistant/components/panasonic_viera/__init__.py @@ -196,7 +196,7 @@ class Remote: """Send a key to the TV and handle exceptions.""" try: key = getattr(Keys, key.upper()) - except (AttributeError, TypeError): + except AttributeError, TypeError: key = getattr(key, "value", key) assert self._control is not None diff --git a/homeassistant/components/permobil/config_flow.py b/homeassistant/components/permobil/config_flow.py index e0fb55a0363..11c89f7e398 100644 --- a/homeassistant/components/permobil/config_flow.py +++ b/homeassistant/components/permobil/config_flow.py @@ -140,7 +140,7 @@ class PermobilConfigFlow(ConfigFlow, domain=DOMAIN): token, ttl = await self.p_api.request_application_token() self.data[CONF_TOKEN] = token self.data[CONF_TTL] = ttl - except (MyPermobilAPIException, MyPermobilClientException): + except MyPermobilAPIException, MyPermobilClientException: # the code did not pass validation by the api client # or the backend returned an error when trying to validate the code _LOGGER.exception("Error verifying code") diff --git a/homeassistant/components/philips_js/coordinator.py b/homeassistant/components/philips_js/coordinator.py index f450e971093..9e92efa83c1 100644 --- a/homeassistant/components/philips_js/coordinator.py +++ b/homeassistant/components/philips_js/coordinator.py @@ -101,7 +101,7 @@ class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]): while self._notify_wanted: try: res = await self.api.notifyChange(130) - except (ConnectionFailure, AutenticationFailure): + except ConnectionFailure, AutenticationFailure: res = None if res: diff --git a/homeassistant/components/picnic/coordinator.py b/homeassistant/components/picnic/coordinator.py index 9b23157dbf3..a63be7614c2 100644 --- a/homeassistant/components/picnic/coordinator.py +++ b/homeassistant/components/picnic/coordinator.py @@ -120,7 +120,7 @@ class PicnicUpdateCoordinator(DataUpdateCoordinator): copy.deepcopy(next_deliveries[-1]) if next_deliveries else {} ) last_order = copy.deepcopy(deliveries[0]) if deliveries else {} - except (KeyError, TypeError): + except KeyError, TypeError: # A KeyError or TypeError indicate that the response contains unexpected data return {}, {} diff --git a/homeassistant/components/playstation_network/config_flow.py b/homeassistant/components/playstation_network/config_flow.py index e6220812219..26333423603 100644 --- a/homeassistant/components/playstation_network/config_flow.py +++ b/homeassistant/components/playstation_network/config_flow.py @@ -132,7 +132,7 @@ class PlaystationNetworkConfigFlow(ConfigFlow, domain=DOMAIN): user = await psn.get_user() except PSNAWPAuthenticationError: errors["base"] = "invalid_auth" - except (PSNAWPNotFoundError, PSNAWPInvalidTokenError): + except PSNAWPNotFoundError, PSNAWPInvalidTokenError: errors["base"] = "invalid_account" except PSNAWPError: errors["base"] = "cannot_connect" diff --git a/homeassistant/components/plex/__init__.py b/homeassistant/components/plex/__init__.py index bc117e4c7f4..c82a4c37e11 100644 --- a/homeassistant/components/plex/__init__.py +++ b/homeassistant/components/plex/__init__.py @@ -245,7 +245,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: def get_plex_account(plex_server): try: return plex_server.account - except (plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized): + except plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized: return None await hass.async_add_executor_job(get_plex_account, plex_server) diff --git a/homeassistant/components/plex/config_flow.py b/homeassistant/components/plex/config_flow.py index 23334bc07b2..67abba8a89a 100644 --- a/homeassistant/components/plex/config_flow.py +++ b/homeassistant/components/plex/config_flow.py @@ -216,13 +216,13 @@ class PlexFlowHandler(ConfigFlow, domain=DOMAIN): except NoServersFound: _LOGGER.error("No servers linked to Plex account") errors["base"] = "no_servers" - except (plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized): + except plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized: _LOGGER.error("Invalid credentials provided, config not created") errors[CONF_TOKEN] = "faulty_credentials" except requests.exceptions.SSLError as error: _LOGGER.error("SSL certificate error: [%s]", error) errors["base"] = "ssl_error" - except (plexapi.exceptions.NotFound, requests.exceptions.ConnectionError): + except plexapi.exceptions.NotFound, requests.exceptions.ConnectionError: server_identifier = ( server_config.get(CONF_URL) or plex_server.server_choice or "Unknown" ) diff --git a/homeassistant/components/plex/server.py b/homeassistant/components/plex/server.py index 7f9c2545032..462d7577a9b 100644 --- a/homeassistant/components/plex/server.py +++ b/homeassistant/components/plex/server.py @@ -114,7 +114,7 @@ class PlexServer: if not self._plex_account and self._use_plex_tv: try: self._plex_account = plexapi.myplex.MyPlexAccount(token=self._token) - except (BadRequest, Unauthorized): + except BadRequest, Unauthorized: self._use_plex_tv = False _LOGGER.error("Not authorized to access plex.tv with provided token") raise @@ -402,7 +402,7 @@ class PlexServer: identifier=machine_identifier, token=self._plex_server.createToken(), ) - except (NotFound, requests.exceptions.ConnectionError): + except NotFound, requests.exceptions.ConnectionError: _LOGGER.error( "Direct client connection failed, will try again: %s (%s)", name, diff --git a/homeassistant/components/plex/update.py b/homeassistant/components/plex/update.py index bc1c6abf2ed..6016220a32d 100644 --- a/homeassistant/components/plex/update.py +++ b/homeassistant/components/plex/update.py @@ -53,7 +53,7 @@ class PlexUpdate(UpdateEntity): if (release := self._server.plex_server.checkForUpdate()) is None: self._attr_latest_version = self.installed_version return - except (requests.exceptions.RequestException, PlexApiException): + except requests.exceptions.RequestException, PlexApiException: _LOGGER.debug("Polling update sensor failed, will try again") return self._attr_latest_version = release.version diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 685e17ea8c9..fac9f0b4cdd 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -103,7 +103,7 @@ async def verify_connection( errors[CONF_BASE] = "invalid_auth" except InvalidSetupError: errors[CONF_BASE] = "invalid_setup" - except (InvalidXMLError, ResponseError): + except InvalidXMLError, ResponseError: errors[CONF_BASE] = "response_error" except UnsupportedDeviceError: errors[CONF_BASE] = "unsupported" diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index acfb93610a2..2596e0077bb 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -517,7 +517,7 @@ class PrometheusMetrics: for key, value in state.attributes.items(): try: value = float(value) - except (ValueError, TypeError): + except ValueError, TypeError: continue self._metric( diff --git a/homeassistant/components/proxmoxve/common.py b/homeassistant/components/proxmoxve/common.py index 4173377377c..6dc59cb8dd0 100644 --- a/homeassistant/components/proxmoxve/common.py +++ b/homeassistant/components/proxmoxve/common.py @@ -82,7 +82,7 @@ def call_api_container_vm( status = proxmox.nodes(node_name).qemu(vm_id).status.current.get() elif machine_type == TYPE_CONTAINER: status = proxmox.nodes(node_name).lxc(vm_id).status.current.get() - except (ResourceException, requests.exceptions.ConnectionError): + except ResourceException, requests.exceptions.ConnectionError: return None return status diff --git a/homeassistant/components/pushbullet/sensor.py b/homeassistant/components/pushbullet/sensor.py index ea9a8f198ef..3ab55ecf072 100644 --- a/homeassistant/components/pushbullet/sensor.py +++ b/homeassistant/components/pushbullet/sensor.py @@ -123,7 +123,7 @@ class PushBulletNotificationSensor(SensorEntity): else: self._attr_native_value = value self._attr_extra_state_attributes = self.pb_provider.data - except (KeyError, TypeError): + except KeyError, TypeError: pass self.async_write_ha_state() diff --git a/homeassistant/components/pyload/config_flow.py b/homeassistant/components/pyload/config_flow.py index 8aa1fb422c6..3262069c2f5 100644 --- a/homeassistant/components/pyload/config_flow.py +++ b/homeassistant/components/pyload/config_flow.py @@ -111,7 +111,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): self._async_abort_entries_match({CONF_URL: url}) try: await validate_input(self.hass, user_input) - except (CannotConnect, ParserError): + except CannotConnect, ParserError: errors["base"] = "cannot_connect" except InvalidAuth: errors["base"] = "invalid_auth" @@ -154,7 +154,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): if user_input is not None: try: await validate_input(self.hass, {**reauth_entry.data, **user_input}) - except (CannotConnect, ParserError): + except CannotConnect, ParserError: errors["base"] = "cannot_connect" except InvalidAuth: errors["base"] = "invalid_auth" @@ -190,7 +190,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): if user_input is not None: try: await validate_input(self.hass, user_input) - except (CannotConnect, ParserError): + except CannotConnect, ParserError: errors["base"] = "cannot_connect" except InvalidAuth: errors["base"] = "invalid_auth" @@ -249,7 +249,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): try: await validate_input(self.hass, data) - except (CannotConnect, ParserError): + except CannotConnect, ParserError: _LOGGER.debug("Cannot connect", exc_info=True) errors["base"] = "cannot_connect" except InvalidAuth: