Replace pylint broad-except with Ruff BLE001 (#116250)

pull/116991/head^2
Sid 2024-05-07 14:00:27 +02:00 committed by GitHub
parent b35fbd8d20
commit 2cc916db6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
335 changed files with 459 additions and 459 deletions

View File

@ -82,7 +82,7 @@ class AirNowConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth"
except InvalidLocation:
errors["base"] = "invalid_location"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -56,7 +56,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except airthings.AirthingsAuthError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -102,7 +102,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
device = await self._get_device_data(discovery_info)
except AirthingsDeviceUpdateError:
return self.async_abort(reason="cannot_connect")
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
return self.async_abort(reason="unknown")
name = get_name(device)
@ -160,7 +160,7 @@ class AirthingsConfigFlow(ConfigFlow, domain=DOMAIN):
device = await self._get_device_data(discovery_info)
except AirthingsDeviceUpdateError:
return self.async_abort(reason="cannot_connect")
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
return self.async_abort(reason="unknown")
name = get_name(device)
self._discovered_devices[address] = Discovery(name, discovery_info, device)

View File

@ -32,7 +32,7 @@ class AirTouch5ConfigFlow(ConfigFlow, domain=DOMAIN):
client = Airtouch5SimpleClient(user_input[CONF_HOST])
try:
await client.test_connection()
except Exception: # pylint: disable=broad-exception-caught
except Exception: # noqa: BLE001
errors = {"base": "cannot_connect"}
else:
await self.async_set_unique_id(user_input[CONF_HOST])

View File

@ -60,7 +60,7 @@ async def async_validate_credentials(
except NodeProError as err:
LOGGER.error("Unknown Pro error while connecting to %s: %s", ip_address, err)
errors["base"] = "unknown"
except Exception as err: # pylint: disable=broad-except
except Exception as err: # noqa: BLE001
LOGGER.exception("Unknown error while connecting to %s: %s", ip_address, err)
errors["base"] = "unknown"
else:

View File

@ -128,7 +128,7 @@ class AlarmDecoderFlowHandler(ConfigFlow, domain=DOMAIN):
)
except NoDeviceError:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception during AlarmDecoder setup")
errors["base"] = "unknown"

View File

@ -268,7 +268,7 @@ class AlexaCapability:
prop_value = self.get_property(prop_name)
except UnsupportedProperty:
raise
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Unexpected error getting %s.%s property from %s",
self.name(),

View File

@ -353,7 +353,7 @@ class AlexaEntity:
try:
capabilities.append(i.serialize_discovery())
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Error serializing %s discovery for %s", i.name(), self.entity
)
@ -379,7 +379,7 @@ def async_get_entities(
try:
alexa_entity = ENTITY_ADAPTERS[state.domain](hass, config, state)
interfaces = list(alexa_entity.interfaces())
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unable to serialize %s for discovery", state.entity_id)
else:
if not interfaces:

View File

@ -126,7 +126,7 @@ async def async_api_discovery(
continue
try:
discovered_serialized_entity = alexa_entity.serialize_discovery()
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Unable to serialize %s for discovery", alexa_entity.entity_id
)

View File

@ -219,7 +219,7 @@ async def async_handle_message(
error_message=err.error_message,
payload=err.payload,
)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Uncaught exception processing Alexa %s/%s request (%s)",
directive.namespace,

View File

@ -119,7 +119,7 @@ class AndroidTVFlowHandler(ConfigFlow, domain=DOMAIN):
try:
aftv, error_message = await async_connect_androidtv(self.hass, user_input)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Unknown error connecting with Android device at %s",
user_input[CONF_HOST],

View File

@ -89,7 +89,7 @@ def adb_decorator(
await self.aftv.adb_close()
self._attr_available = False
return None
except Exception as err: # pylint: disable=broad-except
except Exception as err: # noqa: BLE001
# An unforeseen exception occurred. Close the ADB connection so that
# it doesn't happen over and over again.
if self.available:

View File

@ -38,7 +38,7 @@ class AnovaConfligFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth"
except NoDevicesFound:
errors["base"] = "no_devices_found"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
errors["base"] = "unknown"
else:
# We store device list in config flow in order to persist found devices on restart, as the Anova api get_devices does not return any devices that are offline.

View File

@ -36,7 +36,7 @@ class AOSmithConfigFlow(ConfigFlow, domain=DOMAIN):
await client.get_devices()
except AOSmithInvalidCredentialsException:
return "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return "unknown"

View File

@ -246,7 +246,7 @@ class AppleTVManager(DeviceListener):
if self._task:
self._task.cancel()
self._task = None
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("An error occurred while disconnecting")
def _start_connect_loop(self) -> None:
@ -292,7 +292,7 @@ class AppleTVManager(DeviceListener):
return
except asyncio.CancelledError:
pass
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Failed to connect")
await self.disconnect()

View File

@ -184,7 +184,7 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "no_devices_found"
except DeviceAlreadyConfigured:
errors["base"] = "already_configured"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -329,7 +329,7 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="no_devices_found")
except DeviceAlreadyConfigured:
return self.async_abort(reason="already_configured")
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
@ -472,7 +472,7 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN):
except exceptions.PairingError:
_LOGGER.exception("Authentication problem")
abort_reason = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
abort_reason = "unknown"
@ -514,7 +514,7 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN):
except exceptions.PairingError:
_LOGGER.exception("Authentication problem")
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -86,6 +86,6 @@ async def _run_client(hass: HomeAssistant, client: Client, interval: float) -> N
await asyncio.sleep(interval)
except TimeoutError:
continue
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception, aborting arcam client")
return

View File

@ -62,7 +62,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidAuthCredentials:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -126,7 +126,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidAuthCredentials:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -1295,7 +1295,7 @@ def _pipeline_debug_recording_thread_proc(
wav_writer.writeframes(message)
except Empty:
pass # occurs when pipeline has unexpected error
except Exception: # pylint: disable=broad-exception-caught
except Exception:
_LOGGER.exception("Unexpected error in debug recording thread")
finally:
if wav_writer is not None:

View File

@ -195,7 +195,7 @@ class AsusWrtFlowHandler(ConfigFlow, domain=DOMAIN):
)
error = RESULT_CONN_ERROR
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Unknown error connecting with AsusWrt router at %s using protocol %s",
host,

View File

@ -254,7 +254,7 @@ class AugustConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth"
except RequireValidation:
validation_required = True
except Exception as ex: # pylint: disable=broad-except
except Exception as ex:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unhandled"
description_placeholders = {"error": str(ex)}

View File

@ -64,7 +64,7 @@ class AuroraConfigFlow(ConfigFlow, domain=DOMAIN):
await api.get_forecast_data(longitude, latitude)
except ClientError:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -651,7 +651,7 @@ def websocket_delete_all_refresh_tokens(
continue
try:
hass.auth.async_remove_refresh_token(token)
except Exception: # pylint: disable=broad-except
except Exception:
getLogger(__name__).exception("Error during refresh token removal")
remove_failed = True

View File

@ -747,7 +747,7 @@ class AutomationEntity(BaseAutomationEntity, RestoreEntity):
err,
)
automation_trace.set_error(err)
except Exception as err: # pylint: disable=broad-except
except Exception as err:
self._logger.exception("While executing automation %s", self.entity_id)
automation_trace.set_error(err)

View File

@ -73,7 +73,7 @@ async def validate_data(data: dict[str, Any]) -> dict[str, str] | None:
await client.test_connection()
except EventHubError:
return {"base": "cannot_connect"}
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unknown error")
return {"base": "unknown"}
return None

View File

@ -92,7 +92,7 @@ async def handle_backup_start(
try:
await manager.pre_backup_actions()
except Exception as err: # pylint: disable=broad-except
except Exception as err: # noqa: BLE001
connection.send_error(msg["id"], "pre_backup_actions_failed", str(err))
return
@ -114,7 +114,7 @@ async def handle_backup_end(
try:
await manager.post_backup_actions()
except Exception as err: # pylint: disable=broad-except
except Exception as err: # noqa: BLE001
connection.send_error(msg["id"], "post_backup_actions_failed", str(err))
return

View File

@ -92,7 +92,7 @@ class BAFFlowHandler(ConfigFlow, domain=DOMAIN):
device = await async_try_connect(ip_address)
except CannotConnect:
errors[CONF_IP_ADDRESS] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Unknown exception during connection test to %s", ip_address
)

View File

@ -74,7 +74,7 @@ class BalboaSpaClientFlowHandler(ConfigFlow, domain=DOMAIN):
info = await validate_input(user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -69,7 +69,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN):
return await self.async_step_2fa()
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
@ -96,7 +96,7 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN):
)
except BlinkSetupError:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -48,7 +48,7 @@ class BlueCurrentConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "already_connected"
except InvalidApiToken:
errors["base"] = "invalid_token"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -136,7 +136,7 @@ class ActiveBluetoothDataUpdateCoordinator(
)
self.last_poll_successful = False
return
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
if self.last_poll_successful:
self.logger.exception("%s: Failure while polling", self.address)
self.last_poll_successful = False

View File

@ -129,7 +129,7 @@ class ActiveBluetoothProcessorCoordinator(
)
self.last_poll_successful = False
return
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
if self.last_poll_successful:
self.logger.exception("%s: Failure while polling", self.address)
self.last_poll_successful = False

View File

@ -107,7 +107,7 @@ class HomeAssistantBluetoothManager(BluetoothManager):
callback = match[CALLBACK]
try:
callback(service_info, BluetoothChange.ADVERTISEMENT)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Error in bluetooth callback")
for domain in matched_domains:
@ -182,7 +182,7 @@ class HomeAssistantBluetoothManager(BluetoothManager):
if ble_device_matches(callback_matcher, service_info):
try:
callback(service_info, BluetoothChange.ADVERTISEMENT)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Error in bluetooth callback")
return _async_remove_callback

View File

@ -373,7 +373,7 @@ class PassiveBluetoothProcessorCoordinator(
try:
update = self._update_method(service_info)
except Exception: # pylint: disable=broad-except
except Exception:
self.last_update_success = False
self.logger.exception("Unexpected error updating %s data", self.name)
return
@ -583,7 +583,7 @@ class PassiveBluetoothDataProcessor(Generic[_T]):
"""Handle a Bluetooth event."""
try:
new_data = self.update_method(update)
except Exception: # pylint: disable=broad-except
except Exception:
self.last_update_success = False
self.coordinator.logger.exception(
"Unexpected error updating %s data", self.coordinator.name

View File

@ -124,7 +124,7 @@ class BoschSHCConfigFlow(ConfigFlow, domain=DOMAIN):
self.info = await self._get_info(self.host)
except SHCConnectionError:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -161,7 +161,7 @@ class BoschSHCConfigFlow(ConfigFlow, domain=DOMAIN):
except SHCRegistrationError as err:
_LOGGER.warning("Registration error: %s", err.message)
errors["base"] = "pairing_failed"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -59,7 +59,7 @@ class BringConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except BringAuthException:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -43,7 +43,7 @@ async def validate_input(user_input: dict[str, Any]) -> dict[str, str] | None:
except ServerDisconnectedError:
_LOGGER.warning("Cannot connect to Brunt")
errors = {"base": "cannot_connect"}
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unknown error when trying to login to Brunt")
errors = {"base": "unknown"}
finally:

View File

@ -82,7 +82,7 @@ class CalDavConfigFlow(ConfigFlow, domain=DOMAIN):
except DAVError as err:
_LOGGER.warning("CalDAV client error: %s", err)
return "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return "unknown"
return None

View File

@ -6,7 +6,7 @@ from contextlib import suppress
import logging
from typing import TYPE_CHECKING, Literal, cast
with suppress(Exception): # pylint: disable=broad-except
with suppress(Exception):
# TurboJPEG imports numpy which may or may not work so
# we have to guard the import here. We still want
# to import it at top level so it gets loaded
@ -98,7 +98,7 @@ class TurboJPEGSingleton:
"""Try to create TurboJPEG only once."""
try:
TurboJPEGSingleton.__instance = TurboJPEG()
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Error loading libturbojpeg; Camera snapshot performance will be sub-optimal"
)

View File

@ -82,7 +82,7 @@ class CanaryConfigFlow(ConfigFlow, domain=DOMAIN):
)
except (ConnectTimeout, HTTPError):
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
else:

View File

@ -42,7 +42,7 @@ class CCM15ConfigFlow(ConfigFlow, domain=DOMAIN):
try:
if not await ccm15.async_test_connection():
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -136,7 +136,7 @@ def _handle_cloud_errors(
"""Handle exceptions that raise from the wrapped request handler."""
try:
result = await handler(view, request, *args, **kwargs)
except Exception as err: # pylint: disable=broad-except
except Exception as err: # noqa: BLE001
status, msg = _process_cloud_exception(err, request.path)
return view.json_message(
msg, status_code=status, message_code=err.__class__.__name__.lower()
@ -167,7 +167,7 @@ def _ws_handle_cloud_errors(
try:
return await handler(hass, connection, msg)
except Exception as err: # pylint: disable=broad-except
except Exception as err: # noqa: BLE001
err_status, err_msg = _process_cloud_exception(err, msg["type"])
connection.send_error(msg["id"], str(err_status), err_msg)

View File

@ -194,7 +194,7 @@ class CloudflareConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except pycfdns.AuthenticationException:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -130,7 +130,7 @@ class CoinbaseConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth_secret"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -188,7 +188,7 @@ class OptionsFlowHandler(OptionsFlow):
errors["base"] = "currency_unavailable"
except ExchangeRateUnavailable:
errors["base"] = "exchange_rate_unavailable"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -92,7 +92,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -138,7 +138,7 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -112,7 +112,7 @@ class Control4ConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth"
except CannotConnect:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -93,7 +93,7 @@ async def daikin_api_setup(
except ClientConnectionError as err:
_LOGGER.debug("ClientConnectionError to %s", host)
raise ConfigEntryNotReady from err
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
_LOGGER.error("Unexpected error creating device %s", host)
return None

View File

@ -109,7 +109,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
data_schema=self.schema,
errors={"base": "unknown"},
)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected error creating device")
return self.async_show_form(
step_id="user",

View File

@ -42,7 +42,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await hass.async_add_executor_job(api.connect)
except (ConnectionRefusedError, TimeoutError, SSLError) as ex:
raise ConfigEntryNotReady("Connection to Deluge Daemon failed") from ex
except Exception as ex: # pylint:disable=broad-except
except Exception as ex: # noqa: BLE001
if type(ex).__name__ == "BadLoginError":
raise ConfigEntryAuthFailed(
"Credentials for Deluge client are not valid"

View File

@ -94,7 +94,7 @@ class DelugeFlowHandler(ConfigFlow, domain=DOMAIN):
await self.hass.async_add_executor_job(api.connect)
except (ConnectionRefusedError, TimeoutError, SSLError):
return "cannot_connect"
except Exception as ex: # pylint:disable=broad-except
except Exception as ex: # noqa: BLE001
if type(ex).__name__ == "BadLoginError":
return "invalid_auth"
return "unknown"

View File

@ -365,7 +365,7 @@ class DeviceTrackerPlatform:
hass.config.components.add(full_name)
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
LOGGER.exception(
"Error setting up platform %s %s", self.type, self.name
)

View File

@ -63,7 +63,7 @@ class DevoloHomeNetworkConfigFlow(ConfigFlow, domain=DOMAIN):
info = await validate_input(self.hass, user_input)
except DeviceNotFound:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -40,7 +40,7 @@ class DexcomConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except AccountError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
errors["base"] = "unknown"
if "base" not in errors:

View File

@ -55,7 +55,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
info = await validate_input(self.hass, user_input)
except DIRECTVError:
return self._show_setup_form({"base": ERROR_CANNOT_CONNECT})
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason=ERROR_UNKNOWN)
@ -88,7 +88,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN):
info = await validate_input(self.hass, self.discovery_info)
except DIRECTVError:
return self.async_abort(reason=ERROR_CANNOT_CONNECT)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason=ERROR_UNKNOWN)

View File

@ -89,7 +89,7 @@ async def _async_try_connect(token: str) -> tuple[str | None, nextcord.AppInfo |
return "invalid_auth", None
except (ClientConnectorError, nextcord.HTTPException, nextcord.NotFound):
return "cannot_connect", None
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return "unknown", None
await discord_bot.close()

View File

@ -91,7 +91,7 @@ class DiscovergyConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except discovergyError.InvalidLogin:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected error occurred while getting meters")
errors["base"] = "unknown"
else:

View File

@ -121,7 +121,7 @@ class DLinkFlowHandler(ConfigFlow, domain=DOMAIN):
user_input[CONF_USERNAME],
user_input[CONF_USE_LEGACY_PROTOCOL],
)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return "unknown"
if not smartplug.authenticated and smartplug.use_legacy_protocol:

View File

@ -148,7 +148,7 @@ class DoorBirdConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
return info, errors

View File

@ -175,7 +175,7 @@ class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_code"
except dkey_errors.WrongActivationCode:
errors["base"] = "wrong_code"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
else:

View File

@ -42,7 +42,7 @@ class Dremel3DPrinterConfigFlow(ConfigFlow, domain=DOMAIN):
api = await self.hass.async_add_executor_job(Dremel3DPrinter, host)
except (ConnectTimeout, HTTPError, JSONDecodeError):
errors = {"base": "cannot_connect"}
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
LOGGER.exception("An unknown error has occurred")
errors = {"base": "unknown"}

View File

@ -51,7 +51,7 @@ class DuoTecnoConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidPassword:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -46,7 +46,7 @@ class EcoForestConfigFlow(ConfigFlow, domain=DOMAIN):
device = await api.get()
except EcoforestAuthenticationRequired:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "cannot_connect"
else:

View File

@ -93,7 +93,7 @@ async def _validate_input(
errors["base"] = "cannot_connect"
except InvalidAuthenticationError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception during login")
errors["base"] = "unknown"
@ -121,7 +121,7 @@ async def _validate_input(
errors[cannot_connect_field] = "cannot_connect"
except InvalidAuthenticationError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception during mqtt connection verification")
errors["base"] = "unknown"

View File

@ -68,7 +68,7 @@ class EfergyFlowHandler(ConfigFlow, domain=DOMAIN):
return None, "cannot_connect"
except exceptions.InvalidAuth:
return None, "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
LOGGER.exception("Unexpected exception")
return None, "unknown"
return api.info["hid"], None

View File

@ -248,7 +248,7 @@ class Elkm1ConfigFlow(ConfigFlow, domain=DOMAIN):
return {"base": "cannot_connect"}, None
except InvalidAuth:
return {CONF_PASSWORD: "invalid_auth"}, None
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return {"base": "unknown"}, None

View File

@ -370,7 +370,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
)
except ElmaxBadPinError:
errors["base"] = "invalid_pin"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Error occurred")
errors["base"] = "unknown"

View File

@ -46,7 +46,7 @@ class EmonitorConfigFlow(ConfigFlow, domain=DOMAIN):
info = await fetch_mac_and_title(self.hass, user_input[CONF_HOST])
except aiohttp.ClientError:
errors[CONF_HOST] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -77,7 +77,7 @@ class EmonitorConfigFlow(ConfigFlow, domain=DOMAIN):
self.discovered_info = await fetch_mac_and_title(
self.hass, self.discovered_ip
)
except Exception as ex: # pylint: disable=broad-except
except Exception as ex: # noqa: BLE001
_LOGGER.debug(
"Unable to fetch status, falling back to manual entry", exc_info=ex
)

View File

@ -95,7 +95,7 @@ class Enigma2ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
errors = {"base": "invalid_auth"}
except ClientError:
errors = {"base": "cannot_connect"}
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
errors = {"base": "unknown"}
else:
await self.async_set_unique_id(about["info"]["ifaces"][0]["mac"])

View File

@ -169,7 +169,7 @@ class EnphaseConfigFlow(ConfigFlow, domain=DOMAIN):
except EnvoyError as e:
errors["base"] = "cannot_connect"
description_placeholders = {"reason": str(e)}
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -61,7 +61,7 @@ class EnvironmentCanadaConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "bad_station_id"
else:
errors["base"] = "error_response"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -82,7 +82,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
try:
await validate_input(self.hass, user_input)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -60,7 +60,7 @@ def get_game_url(raw_game_data: dict[str, Any], language: str) -> str:
url_slug: str | None = None
try:
url_slug = raw_game_data["offerMappings"][0]["pageSlug"]
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
with contextlib.suppress(Exception):
url_slug = raw_game_data["catalogNs"]["mappings"][0]["pageSlug"]

View File

@ -374,7 +374,7 @@ class RuntimeEntryData:
if subscription := self.state_subscriptions.get(subscription_key):
try:
subscription()
except Exception: # pylint: disable=broad-except
except Exception:
# If we allow this exception to raise it will
# make it all the way to data_received in aioesphomeapi
# which will cause the connection to be closed.

View File

@ -67,7 +67,7 @@ class EvilGeniusLabsConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "timeout"
except CannotConnect:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -189,7 +189,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
except PyEzvizError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
@ -242,7 +242,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
except PyEzvizError:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
@ -297,7 +297,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
except (PyEzvizError, AuthTestResultFailed):
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")
@ -358,7 +358,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
except (PyEzvizError, AuthTestResultFailed):
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")

View File

@ -43,7 +43,7 @@ class FAADelaysConfigFlow(ConfigFlow, domain=DOMAIN):
_LOGGER.error("Error connecting to FAA API")
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -59,7 +59,7 @@ class FiveMConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidGameNameError:
errors["base"] = "invalid_game_name"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -46,7 +46,7 @@ class FlexitBacnetConfigFlow(ConfigFlow, domain=DOMAIN):
await device.update()
except (asyncio.exceptions.TimeoutError, ConnectionError, DecodingError):
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -65,7 +65,7 @@ class FlickConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidAuth:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -44,7 +44,7 @@ class FliprConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth"
except (Timeout, ConnectionError):
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
errors["base"] = "unknown"
_LOGGER.exception("Unexpected exception")

View File

@ -48,7 +48,7 @@ def get_scanner(hass: HomeAssistant, config: ConfigType) -> FortiOSDeviceScanner
except ConnectionError as ex:
_LOGGER.error("ConnectionError to FortiOS API: %s", ex)
return None
except Exception as ex: # pylint: disable=broad-except
except Exception as ex: # noqa: BLE001
_LOGGER.error("Failed to login to FortiOS API: %s", ex)
return None

View File

@ -110,7 +110,7 @@ class FoscamConfigFlow(ConfigFlow, domain=DOMAIN):
except AbortFlow:
raise
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -89,7 +89,7 @@ class FreeboxFlowHandler(ConfigFlow, domain=DOMAIN):
)
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception(
"Unknown error connecting with Freebox router at %s",
self._data[CONF_HOST],

View File

@ -441,7 +441,7 @@ class FritzBoxTools(
hosts_info = await self.hass.async_add_executor_job(
self.fritz_hosts.get_hosts_info
)
except Exception as ex: # pylint: disable=[broad-except]
except Exception as ex: # noqa: BLE001
if not self.hass.is_stopping:
raise HomeAssistantError(
translation_domain=DOMAIN,

View File

@ -91,7 +91,7 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
return ERROR_AUTH_INVALID
except FritzConnectionException:
return ERROR_CANNOT_CONNECT
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return ERROR_UNKNOWN

View File

@ -97,7 +97,7 @@ class FroniusConfigFlow(ConfigFlow, domain=DOMAIN):
unique_id, info = await validate_host(self.hass, user_input[CONF_HOST])
except CannotConnect:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -74,7 +74,7 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
self._webfsapi_url = await AFSAPI.get_webfsapi_endpoint(device_url)
except FSConnectionError:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
@ -108,7 +108,7 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
self._webfsapi_url = await AFSAPI.get_webfsapi_endpoint(device_url)
except FSConnectionError:
return self.async_abort(reason="cannot_connect")
except Exception as exception: # pylint: disable=broad-except
except Exception as exception: # noqa: BLE001
_LOGGER.debug(exception)
return self.async_abort(reason="unknown")
@ -206,7 +206,7 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
except InvalidPinException:
errors["base"] = "invalid_auth"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -64,7 +64,7 @@ class FullyKioskConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
description_placeholders["error_detail"] = str(error.args)
return None
except Exception as error: # pylint: disable=broad-except
except Exception as error: # noqa: BLE001
LOGGER.exception("Unexpected exception: %s", error)
errors["base"] = "unknown"
description_placeholders["error_detail"] = str(error.args)

View File

@ -50,7 +50,7 @@ class FytaConfigFlow(ConfigFlow, domain=DOMAIN):
return {"base": "invalid_auth"}
except FytaPasswordError:
return {"base": "invalid_auth", CONF_PASSWORD: "password_error"}
except Exception as e: # pylint: disable=broad-except
except Exception as e: # noqa: BLE001
_LOGGER.error(e)
return {"base": "unknown"}
finally:

View File

@ -36,7 +36,7 @@ class GaragesAmsterdamConfigFlow(ConfigFlow, domain=DOMAIN):
except ClientResponseError:
_LOGGER.error("Unexpected response from server")
return self.async_abort(reason="cannot_connect")
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return self.async_abort(reason="unknown")

View File

@ -111,7 +111,7 @@ class GoalZeroFlowHandler(ConfigFlow, domain=DOMAIN):
return None, "cannot_connect"
except exceptions.InvalidHost:
return None, "invalid_host"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
return None, "unknown"
return str(api.sysdata["macAddress"]), None

View File

@ -111,7 +111,7 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
else:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
errors["base"] = "cannot_connect"
if self._ip_address and self._device_type:

View File

@ -90,7 +90,7 @@ async def _process(hass, data, message):
result = await handler(hass, data, inputs[0].get("payload"))
except SmartHomeError as err:
return {"requestId": data.request_id, "payload": {"errorCode": err.code}}
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected error")
return {
"requestId": data.request_id,
@ -115,7 +115,7 @@ async def async_devices_sync_response(hass, config, agent_user_id):
try:
devices.append(entity.sync_serialize(agent_user_id, instance_uuid))
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Error serializing %s", entity.entity_id)
return devices
@ -179,7 +179,7 @@ async def async_devices_query_response(hass, config, payload_devices):
entity = GoogleEntity(hass, config, state)
try:
devices[devid] = entity.query_serialize()
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected error serializing query for %s", state)
devices[devid] = {"online": False}

View File

@ -295,7 +295,7 @@ class GoogleCloudTTSProvider(Provider):
except TimeoutError as ex:
_LOGGER.error("Timeout for Google Cloud TTS call: %s", ex)
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Error occurred during Google Cloud TTS call")
return None, None

View File

@ -94,7 +94,7 @@ class GoogleGenerativeAIConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "invalid_auth"
else:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:

View File

@ -66,7 +66,7 @@ class OAuth2FlowHandler(
reason="access_not_configured",
description_placeholders={"message": error},
)
except Exception: # pylint: disable=broad-except
except Exception:
self.logger.exception("Unknown error occurred")
return self.async_abort(reason="unknown")
user_id = user_resource_info["id"]

View File

@ -177,7 +177,7 @@ class GraphiteFeeder(threading.Thread):
self._report_attributes(
event.data["entity_id"], event.data["new_state"]
)
except Exception: # pylint: disable=broad-except
except Exception:
# Catch this so we can avoid the thread dying and
# make it visible.
_LOGGER.exception("Failed to process STATE_CHANGED event")

View File

@ -64,7 +64,7 @@ class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
info = await validate_input(self.hass, user_input)
except InvalidAuth:
errors = {"base": "invalid_credentials"}
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors = {"base": "unknown"}
else:

View File

@ -76,7 +76,7 @@ class HarmonyConfigFlow(ConfigFlow, domain=DOMAIN):
validated = await validate_input(user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception:
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"

View File

@ -54,7 +54,7 @@ class HKOConfigFlow(ConfigFlow, domain=DOMAIN):
except HKOError:
errors["base"] = "cannot_connect"
except Exception: # pylint: disable=broad-except
except Exception: # noqa: BLE001
errors["base"] = "unknown"
else:
await self.async_set_unique_id(

Some files were not shown because too many files have changed in this diff Show More