diff --git a/homeassistant/components/adguard/entity.py b/homeassistant/components/adguard/entity.py index 74f69442f81..8cb71a861e8 100644 --- a/homeassistant/components/adguard/entity.py +++ b/homeassistant/components/adguard/entity.py @@ -44,7 +44,7 @@ class AdGuardHomeEntity(Entity): async def _adguard_update(self) -> None: """Update AdGuard Home entity.""" - raise NotImplementedError() + raise NotImplementedError @property def device_info(self) -> DeviceInfo: diff --git a/homeassistant/components/air_quality/__init__.py b/homeassistant/components/air_quality/__init__.py index a25874f0c2f..f23f87019b9 100644 --- a/homeassistant/components/air_quality/__init__.py +++ b/homeassistant/components/air_quality/__init__.py @@ -83,7 +83,7 @@ class AirQualityEntity(Entity): @property def particulate_matter_2_5(self) -> StateType: """Return the particulate matter 2.5 level.""" - raise NotImplementedError() + raise NotImplementedError @property def particulate_matter_10(self) -> StateType: diff --git a/homeassistant/components/airtouch5/__init__.py b/homeassistant/components/airtouch5/__init__.py index 8518d8a442e..b8b9a3f765a 100644 --- a/homeassistant/components/airtouch5/__init__.py +++ b/homeassistant/components/airtouch5/__init__.py @@ -27,7 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: await client.connect_and_stay_connected() except TimeoutError as t: - raise ConfigEntryNotReady() from t + raise ConfigEntryNotReady from t # Store an API object for your platforms to access hass.data[DOMAIN][entry.entry_id] = client diff --git a/homeassistant/components/airvisual_pro/__init__.py b/homeassistant/components/airvisual_pro/__init__.py index 74c90b9ed02..88f05d28145 100644 --- a/homeassistant/components/airvisual_pro/__init__.py +++ b/homeassistant/components/airvisual_pro/__init__.py @@ -54,7 +54,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: await node.async_connect() except NodeProError as err: - raise ConfigEntryNotReady() from err + raise ConfigEntryNotReady from err reload_task: asyncio.Task | None = None diff --git a/homeassistant/components/airzone/entity.py b/homeassistant/components/airzone/entity.py index 7d2c883f484..b360db61897 100644 --- a/homeassistant/components/airzone/entity.py +++ b/homeassistant/components/airzone/entity.py @@ -44,7 +44,7 @@ class AirzoneEntity(CoordinatorEntity[AirzoneUpdateCoordinator]): def get_airzone_value(self, key: str) -> Any: """Return Airzone entity value by key.""" - raise NotImplementedError() + raise NotImplementedError class AirzoneSystemEntity(AirzoneEntity): diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index 37a2fa6a315..63c095ea6ce 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -173,7 +173,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_disarm(self, code: str | None = None) -> None: """Send disarm command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_disarm(self, code: str | None = None) -> None: """Send disarm command.""" @@ -181,7 +181,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_arm_home(self, code: str | None = None) -> None: """Send arm home command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_arm_home(self, code: str | None = None) -> None: """Send arm home command.""" @@ -189,7 +189,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_arm_away(self, code: str | None = None) -> None: """Send arm away command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_arm_away(self, code: str | None = None) -> None: """Send arm away command.""" @@ -197,7 +197,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_arm_night(self, code: str | None = None) -> None: """Send arm night command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_arm_night(self, code: str | None = None) -> None: """Send arm night command.""" @@ -205,7 +205,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_arm_vacation(self, code: str | None = None) -> None: """Send arm vacation command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_arm_vacation(self, code: str | None = None) -> None: """Send arm vacation command.""" @@ -213,7 +213,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_trigger(self, code: str | None = None) -> None: """Send alarm trigger command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_trigger(self, code: str | None = None) -> None: """Send alarm trigger command.""" @@ -221,7 +221,7 @@ class AlarmControlPanelEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_A def alarm_arm_custom_bypass(self, code: str | None = None) -> None: """Send arm custom bypass command.""" - raise NotImplementedError() + raise NotImplementedError async def async_alarm_arm_custom_bypass(self, code: str | None = None) -> None: """Send arm custom bypass command.""" diff --git a/homeassistant/components/alexa/resources.py b/homeassistant/components/alexa/resources.py index b75e5597b6f..4bc63f6ccae 100644 --- a/homeassistant/components/alexa/resources.py +++ b/homeassistant/components/alexa/resources.py @@ -224,7 +224,7 @@ class AlexaCapabilityResource: Return ModeResources, PresetResources friendlyNames serialized. """ - raise NotImplementedError() + raise NotImplementedError def serialize_labels(self, resources: list[str]) -> dict[str, list[dict[str, Any]]]: """Return serialized labels for an API response. diff --git a/homeassistant/components/api/__init__.py b/homeassistant/components/api/__init__.py index 25d404cbd15..82aaefe1288 100644 --- a/homeassistant/components/api/__init__.py +++ b/homeassistant/components/api/__init__.py @@ -413,7 +413,7 @@ class APIDomainServicesView(HomeAssistantView): ) ) except (vol.Invalid, ServiceNotFound) as ex: - raise HTTPBadRequest() from ex + raise HTTPBadRequest from ex finally: cancel_listen() diff --git a/homeassistant/components/apple_tv/config_flow.py b/homeassistant/components/apple_tv/config_flow.py index dea4763a04d..19cbb24d8a2 100644 --- a/homeassistant/components/apple_tv/config_flow.py +++ b/homeassistant/components/apple_tv/config_flow.py @@ -341,7 +341,7 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN): self.hass, self.scan_filter, self.hass.loop ) if not self.atv: - raise DeviceNotFound() + raise DeviceNotFound # Protocols supported by the device are prospects for pairing self.protocols_to_pair = deque( @@ -384,7 +384,7 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN): self.hass.config_entries.async_reload(entry.entry_id) ) if not allow_exist: - raise DeviceAlreadyConfigured() + raise DeviceAlreadyConfigured async def async_step_confirm( self, user_input: dict[str, str] | None = None diff --git a/homeassistant/components/aprilaire/__init__.py b/homeassistant/components/aprilaire/__init__.py index b5aeea2a55c..4fa5cdac68d 100644 --- a/homeassistant/components/aprilaire/__init__.py +++ b/homeassistant/components/aprilaire/__init__.py @@ -51,7 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: coordinator.stop_listen() - raise ConfigEntryNotReady() + raise ConfigEntryNotReady await coordinator.wait_for_ready(ready_callback) diff --git a/homeassistant/components/aussie_broadband/__init__.py b/homeassistant/components/aussie_broadband/__init__.py index 72fa824bb5b..1fc7e47ebde 100644 --- a/homeassistant/components/aussie_broadband/__init__.py +++ b/homeassistant/components/aussie_broadband/__init__.py @@ -39,9 +39,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await client.login() services = await client.get_services(drop_types=ignore_types) except AuthenticationException as exc: - raise ConfigEntryAuthFailed() from exc + raise ConfigEntryAuthFailed from exc except ClientError as exc: - raise ConfigEntryNotReady() from exc + raise ConfigEntryNotReady from exc # Create an appropriate refresh function def update_data_factory(service_id): diff --git a/homeassistant/components/auth/indieauth.py b/homeassistant/components/auth/indieauth.py index 2c90d33b1d8..0bbfcc01fc7 100644 --- a/homeassistant/components/auth/indieauth.py +++ b/homeassistant/components/auth/indieauth.py @@ -158,7 +158,7 @@ def _parse_client_id(client_id: str) -> ParseResult: # Client identifier URLs # MUST have either an https or http scheme if parts.scheme not in ("http", "https"): - raise ValueError() + raise ValueError # MUST contain a path component # Handled by url canonicalization. diff --git a/homeassistant/components/bluesound/media_player.py b/homeassistant/components/bluesound/media_player.py index 357f971f574..9377557d025 100644 --- a/homeassistant/components/bluesound/media_player.py +++ b/homeassistant/components/bluesound/media_player.py @@ -366,7 +366,7 @@ class BluesoundPlayer(MediaPlayerEntity): data = None elif response.status == 595: _LOGGER.info("Status 595 returned, treating as timeout") - raise BluesoundPlayer._TimeoutException() + raise BluesoundPlayer._TimeoutException else: _LOGGER.error("Error %s on %s", response.status, url) return None @@ -432,7 +432,7 @@ class BluesoundPlayer(MediaPlayerEntity): self.async_write_ha_state() elif response.status == 595: _LOGGER.info("Status 595 returned, treating as timeout") - raise BluesoundPlayer._TimeoutException() + raise BluesoundPlayer._TimeoutException else: _LOGGER.error( "Error %s on %s. Trying one more time", response.status, url diff --git a/homeassistant/components/brother/config_flow.py b/homeassistant/components/brother/config_flow.py index 346141cd197..ca2f1ae5a39 100644 --- a/homeassistant/components/brother/config_flow.py +++ b/homeassistant/components/brother/config_flow.py @@ -43,7 +43,7 @@ class BrotherConfigFlow(ConfigFlow, domain=DOMAIN): if user_input is not None: try: if not is_host_valid(user_input[CONF_HOST]): - raise InvalidHost() + raise InvalidHost snmp_engine = get_snmp_engine(self.hass) diff --git a/homeassistant/components/brunt/__init__.py b/homeassistant/components/brunt/__init__.py index ec3ecd0ce6c..bec281d1902 100644 --- a/homeassistant/components/brunt/__init__.py +++ b/homeassistant/components/brunt/__init__.py @@ -51,7 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise UpdateFailed(f"Error communicating with API: {err}") from err except ClientResponseError as err: if err.status == 403: - raise ConfigEntryAuthFailed() from err + raise ConfigEntryAuthFailed from err if err.status == 401: _LOGGER.warning("Device not found, will reload Brunt integration") await hass.config_entries.async_reload(entry.entry_id) diff --git a/homeassistant/components/button/__init__.py b/homeassistant/components/button/__init__.py index 0385e6b7f98..6826f681d4d 100644 --- a/homeassistant/components/button/__init__.py +++ b/homeassistant/components/button/__init__.py @@ -148,7 +148,7 @@ class ButtonEntity(RestoreEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_ def press(self) -> None: """Press the button.""" - raise NotImplementedError() + raise NotImplementedError async def async_press(self) -> None: """Press the button.""" diff --git a/homeassistant/components/calendar/__init__.py b/homeassistant/components/calendar/__init__.py index cb0256e8346..47ea10b71b6 100644 --- a/homeassistant/components/calendar/__init__.py +++ b/homeassistant/components/calendar/__init__.py @@ -503,7 +503,7 @@ class CalendarEntity(Entity): @property def event(self) -> CalendarEvent | None: """Return the next upcoming event.""" - raise NotImplementedError() + raise NotImplementedError @final @property @@ -599,11 +599,11 @@ class CalendarEntity(Entity): end_date: datetime.datetime, ) -> list[CalendarEvent]: """Return calendar events within a datetime range.""" - raise NotImplementedError() + raise NotImplementedError async def async_create_event(self, **kwargs: Any) -> None: """Add a new event to calendar.""" - raise NotImplementedError() + raise NotImplementedError async def async_delete_event( self, @@ -612,7 +612,7 @@ class CalendarEntity(Entity): recurrence_range: str | None = None, ) -> None: """Delete an event on the calendar.""" - raise NotImplementedError() + raise NotImplementedError async def async_update_event( self, @@ -622,7 +622,7 @@ class CalendarEntity(Entity): recurrence_range: str | None = None, ) -> None: """Delete an event on the calendar.""" - raise NotImplementedError() + raise NotImplementedError class CalendarEventView(http.HomeAssistantView): diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index c91c8c403ca..9671288e7ee 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -651,7 +651,7 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): self, width: int | None = None, height: int | None = None ) -> bytes | None: """Return bytes of camera image.""" - raise NotImplementedError() + raise NotImplementedError async def async_camera_image( self, width: int | None = None, height: int | None = None @@ -696,7 +696,7 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_off(self) -> None: """Turn off camera.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_off(self) -> None: """Turn off camera.""" @@ -704,7 +704,7 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_on(self) -> None: """Turn off camera.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_on(self) -> None: """Turn off camera.""" @@ -712,7 +712,7 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def enable_motion_detection(self) -> None: """Enable motion detection in the camera.""" - raise NotImplementedError() + raise NotImplementedError async def async_enable_motion_detection(self) -> None: """Call the job and enable motion detection.""" @@ -720,7 +720,7 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def disable_motion_detection(self) -> None: """Disable motion detection in camera.""" - raise NotImplementedError() + raise NotImplementedError async def async_disable_motion_detection(self) -> None: """Call the job and disable motion detection.""" @@ -797,7 +797,7 @@ class CameraView(HomeAssistantView): async def get(self, request: web.Request, entity_id: str) -> web.StreamResponse: """Start a GET request.""" if (camera := self.component.get_entity(entity_id)) is None: - raise web.HTTPNotFound() + raise web.HTTPNotFound authenticated = ( request[KEY_AUTHENTICATED] @@ -808,19 +808,19 @@ class CameraView(HomeAssistantView): # Attempt with invalid bearer token, raise unauthorized # so ban middleware can handle it. if hdrs.AUTHORIZATION in request.headers: - raise web.HTTPUnauthorized() + raise web.HTTPUnauthorized # Invalid sigAuth or camera access token - raise web.HTTPForbidden() + raise web.HTTPForbidden if not camera.is_on: _LOGGER.debug("Camera is off") - raise web.HTTPServiceUnavailable() + raise web.HTTPServiceUnavailable return await self.handle(request, camera) async def handle(self, request: web.Request, camera: Camera) -> web.StreamResponse: """Handle the camera request.""" - raise NotImplementedError() + raise NotImplementedError class CameraImageView(CameraView): @@ -841,7 +841,7 @@ class CameraImageView(CameraView): int(height) if height else None, ) except (HomeAssistantError, ValueError) as ex: - raise web.HTTPInternalServerError() from ex + raise web.HTTPInternalServerError from ex return web.Response(body=image.content, content_type=image.content_type) @@ -861,7 +861,7 @@ class CameraMjpegStream(CameraView): stream = None _LOGGER.debug("Error while writing MJPEG stream to transport") if stream is None: - raise web.HTTPBadGateway() + raise web.HTTPBadGateway return stream try: @@ -871,7 +871,7 @@ class CameraMjpegStream(CameraView): raise ValueError(f"Stream interval must be > {MIN_STREAM_INTERVAL}") return await camera.handle_async_still_stream(request, interval) except ValueError as err: - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err @websocket_api.websocket_command( diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index 2382c535413..d96dd163f41 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -657,7 +657,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" @@ -667,7 +667,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_humidity(self, humidity: int) -> None: """Set new target humidity.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_humidity(self, humidity: int) -> None: """Set new target humidity.""" @@ -681,7 +681,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" @@ -689,7 +689,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" @@ -703,7 +703,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_swing_mode(self, swing_mode: str) -> None: """Set new target swing operation.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_swing_mode(self, swing_mode: str) -> None: """Set new target swing operation.""" @@ -717,7 +717,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" @@ -725,7 +725,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_aux_heat_on(self) -> None: """Turn auxiliary heater on.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_aux_heat_on(self) -> None: """Turn auxiliary heater on.""" @@ -733,7 +733,7 @@ class ClimateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_aux_heat_off(self) -> None: """Turn auxiliary heater off.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_aux_heat_off(self) -> None: """Turn auxiliary heater off.""" diff --git a/homeassistant/components/coolmaster/__init__.py b/homeassistant/components/coolmaster/__init__.py index 513d8b3c5a9..1f3f5a66380 100644 --- a/homeassistant/components/coolmaster/__init__.py +++ b/homeassistant/components/coolmaster/__init__.py @@ -37,7 +37,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if not info: raise ConfigEntryNotReady except OSError as error: - raise ConfigEntryNotReady() from error + raise ConfigEntryNotReady from error coordinator = CoolmasterDataUpdateCoordinator(hass, coolmaster) hass.data.setdefault(DOMAIN, {}) await coordinator.async_config_entry_first_refresh() diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index aed0680bad3..1eac6844703 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -381,7 +381,7 @@ class CoverEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def open_cover(self, **kwargs: Any) -> None: """Open the cover.""" - raise NotImplementedError() + raise NotImplementedError async def async_open_cover(self, **kwargs: Any) -> None: """Open the cover.""" @@ -389,7 +389,7 @@ class CoverEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def close_cover(self, **kwargs: Any) -> None: """Close cover.""" - raise NotImplementedError() + raise NotImplementedError async def async_close_cover(self, **kwargs: Any) -> None: """Close cover.""" diff --git a/homeassistant/components/cups/sensor.py b/homeassistant/components/cups/sensor.py index 36f108a1c14..647deee79a6 100644 --- a/homeassistant/components/cups/sensor.py +++ b/homeassistant/components/cups/sensor.py @@ -74,7 +74,7 @@ def setup_platform( data.update() if data.available is False: _LOGGER.error("Unable to connect to CUPS server: %s:%s", host, port) - raise PlatformNotReady() + raise PlatformNotReady assert data.printers is not None dev: list[SensorEntity] = [] @@ -97,7 +97,7 @@ def setup_platform( data.update() if data.available is False: _LOGGER.error("Unable to connect to IPP printer: %s:%s", host, port) - raise PlatformNotReady() + raise PlatformNotReady dev = [] for printer in printers: diff --git a/homeassistant/components/date/__init__.py b/homeassistant/components/date/__init__.py index 5f569500c19..3cb6ad3a77d 100644 --- a/homeassistant/components/date/__init__.py +++ b/homeassistant/components/date/__init__.py @@ -110,7 +110,7 @@ class DateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_value(self, value: date) -> None: """Change the date.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_value(self, value: date) -> None: """Change the date.""" diff --git a/homeassistant/components/datetime/__init__.py b/homeassistant/components/datetime/__init__.py index 15829e14de5..420cf27b5aa 100644 --- a/homeassistant/components/datetime/__init__.py +++ b/homeassistant/components/datetime/__init__.py @@ -126,7 +126,7 @@ class DateTimeEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_value(self, value: datetime) -> None: """Change the date/time.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_value(self, value: datetime) -> None: """Change the date/time.""" diff --git a/homeassistant/components/device_tracker/legacy.py b/homeassistant/components/device_tracker/legacy.py index 081d5e2ca67..9ca9567b896 100644 --- a/homeassistant/components/device_tracker/legacy.py +++ b/homeassistant/components/device_tracker/legacy.py @@ -940,7 +940,7 @@ class DeviceScanner: def scan_devices(self) -> list[str]: """Scan for devices.""" - raise NotImplementedError() + raise NotImplementedError async def async_scan_devices(self) -> list[str]: """Scan for devices.""" @@ -951,7 +951,7 @@ class DeviceScanner: def get_device_name(self, device: str) -> str | None: """Get the name of a device.""" - raise NotImplementedError() + raise NotImplementedError async def async_get_device_name(self, device: str) -> str | None: """Get the name of a device.""" @@ -962,7 +962,7 @@ class DeviceScanner: def get_extra_attributes(self, device: str) -> dict: """Get the extra attributes of a device.""" - raise NotImplementedError() + raise NotImplementedError async def async_get_extra_attributes(self, device: str) -> dict: """Get the extra attributes of a device.""" diff --git a/homeassistant/components/directv/media_player.py b/homeassistant/components/directv/media_player.py index 736e30b9f96..6c4a40598de 100644 --- a/homeassistant/components/directv/media_player.py +++ b/homeassistant/components/directv/media_player.py @@ -278,7 +278,7 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity): async def async_turn_on(self) -> None: """Turn on the receiver.""" if self._is_client: - raise NotImplementedError() + raise NotImplementedError _LOGGER.debug("Turn on %s", self.name) await self.dtv.remote("poweron", self._address) @@ -286,7 +286,7 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity): async def async_turn_off(self) -> None: """Turn off the receiver.""" if self._is_client: - raise NotImplementedError() + raise NotImplementedError _LOGGER.debug("Turn off %s", self.name) await self.dtv.remote("poweroff", self._address) diff --git a/homeassistant/components/dunehd/config_flow.py b/homeassistant/components/dunehd/config_flow.py index 43e919ee42c..8a0f3eec4a0 100644 --- a/homeassistant/components/dunehd/config_flow.py +++ b/homeassistant/components/dunehd/config_flow.py @@ -25,7 +25,7 @@ class DuneHDConfigFlow(ConfigFlow, domain=DOMAIN): player = DuneHDPlayer(host) state = await self.hass.async_add_executor_job(player.update_state) if not state: - raise CannotConnect() + raise CannotConnect async def async_step_user( self, user_input: dict[str, Any] | None = None @@ -39,7 +39,7 @@ class DuneHDConfigFlow(ConfigFlow, domain=DOMAIN): try: if self.host_already_configured(host): - raise AlreadyConfigured() + raise AlreadyConfigured await self.init_device(host) except CannotConnect: errors[CONF_HOST] = "cannot_connect" diff --git a/homeassistant/components/elmax/__init__.py b/homeassistant/components/elmax/__init__.py index ce8ce68d953..518bf1e932b 100644 --- a/homeassistant/components/elmax/__init__.py +++ b/homeassistant/components/elmax/__init__.py @@ -95,7 +95,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: client, panel = await _load_elmax_panel_client(entry) except ElmaxBadLoginError as err: - raise ConfigEntryAuthFailed() from err + raise ConfigEntryAuthFailed from err # Create the API client object and attempt a login, so that we immediately know # if there is something wrong with user credentials diff --git a/homeassistant/components/elmax/config_flow.py b/homeassistant/components/elmax/config_flow.py index d7c6e74ed14..666f4e75fcd 100644 --- a/homeassistant/components/elmax/config_flow.py +++ b/homeassistant/components/elmax/config_flow.py @@ -424,7 +424,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN): if p.hash == self._entry.data[CONF_ELMAX_PANEL_ID] ] if len(panels) < 1: - raise NoOnlinePanelsError() + raise NoOnlinePanelsError # Verify the pin is still valid. await client.get_panel_status( diff --git a/homeassistant/components/epsonworkforce/sensor.py b/homeassistant/components/epsonworkforce/sensor.py index f8b11fc31f4..dea611a3c3a 100644 --- a/homeassistant/components/epsonworkforce/sensor.py +++ b/homeassistant/components/epsonworkforce/sensor.py @@ -81,7 +81,7 @@ def setup_platform( api = EpsonPrinterAPI(host) if not api.available: - raise PlatformNotReady() + raise PlatformNotReady sensors = [ EpsonPrinterCartridge(api, description) diff --git a/homeassistant/components/event/__init__.py b/homeassistant/components/event/__init__.py index fc9add8c62e..2ad0e6d950b 100644 --- a/homeassistant/components/event/__init__.py +++ b/homeassistant/components/event/__init__.py @@ -147,7 +147,7 @@ class EventEntity(RestoreEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_) and self.entity_description.event_types is not None ): return self.entity_description.event_types - raise AttributeError() + raise AttributeError @final def _trigger_event( diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index aeb3a6c89df..185b9631198 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -238,7 +238,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_percentage(self, percentage: int) -> None: """Set the speed of the fan, as a percentage.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_percentage(self, percentage: int) -> None: """Set the speed of the fan, as a percentage.""" @@ -277,7 +277,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" - raise NotImplementedError() + raise NotImplementedError @final async def async_handle_set_preset_mode_service(self, preset_mode: str) -> None: @@ -307,7 +307,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_direction(self, direction: str) -> None: """Set the direction of the fan.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_direction(self, direction: str) -> None: """Set the direction of the fan.""" @@ -320,7 +320,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): **kwargs: Any, ) -> None: """Turn on the fan.""" - raise NotImplementedError() + raise NotImplementedError @final async def async_handle_turn_on_service( @@ -352,7 +352,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def oscillate(self, oscillating: bool) -> None: """Oscillate the fan.""" - raise NotImplementedError() + raise NotImplementedError async def async_oscillate(self, oscillating: bool) -> None: """Oscillate the fan.""" diff --git a/homeassistant/components/ffmpeg/__init__.py b/homeassistant/components/ffmpeg/__init__.py index ec19df5fb6f..2045b6bb06b 100644 --- a/homeassistant/components/ffmpeg/__init__.py +++ b/homeassistant/components/ffmpeg/__init__.py @@ -229,7 +229,7 @@ class FFmpegBase(Entity, Generic[_HAFFmpegT]): This method is a coroutine. """ - raise NotImplementedError() + raise NotImplementedError async def _async_stop_ffmpeg(self, entity_ids: list[str] | None) -> None: """Stop a FFmpeg process. diff --git a/homeassistant/components/file_upload/__init__.py b/homeassistant/components/file_upload/__init__.py index 94c3c39ce92..bb8c34fb28a 100644 --- a/homeassistant/components/file_upload/__init__.py +++ b/homeassistant/components/file_upload/__init__.py @@ -203,13 +203,13 @@ class FileUploadView(HomeAssistantView): hass = request.app[KEY_HASS] if DOMAIN not in hass.data: - raise web.HTTPNotFound() + raise web.HTTPNotFound file_id = data["file_id"] file_upload_data: FileUploadData = hass.data[DOMAIN] if file_upload_data.files.pop(file_id, None) is None: - raise web.HTTPNotFound() + raise web.HTTPNotFound await hass.async_add_executor_job( lambda: shutil.rmtree(file_upload_data.file_dir(file_id)) diff --git a/homeassistant/components/filter/sensor.py b/homeassistant/components/filter/sensor.py index 4289444c6f4..5ae300f6ec4 100644 --- a/homeassistant/components/filter/sensor.py +++ b/homeassistant/components/filter/sensor.py @@ -469,7 +469,7 @@ class Filter: def _filter_state(self, new_state: FilterState) -> FilterState: """Implement filter.""" - raise NotImplementedError() + raise NotImplementedError def filter_state(self, new_state: _State) -> _State: """Implement a common interface for filters.""" diff --git a/homeassistant/components/flick_electric/config_flow.py b/homeassistant/components/flick_electric/config_flow.py index efe8a5725f7..41b58431977 100644 --- a/homeassistant/components/flick_electric/config_flow.py +++ b/homeassistant/components/flick_electric/config_flow.py @@ -49,9 +49,9 @@ class FlickConfigFlow(ConfigFlow, domain=DOMAIN): async with asyncio.timeout(60): token = await auth.async_get_access_token() except TimeoutError as err: - raise CannotConnect() from err + raise CannotConnect from err except AuthException as err: - raise InvalidAuth() from err + raise InvalidAuth from err return token is not None diff --git a/homeassistant/components/freedompro/coordinator.py b/homeassistant/components/freedompro/coordinator.py index c5f8ea990dc..ad76a9aaa65 100644 --- a/homeassistant/components/freedompro/coordinator.py +++ b/homeassistant/components/freedompro/coordinator.py @@ -36,7 +36,7 @@ class FreedomproDataUpdateCoordinator(DataUpdateCoordinator[list[dict[str, Any]] if result["state"]: self._devices = result["devices"] else: - raise UpdateFailed() + raise UpdateFailed result = await get_states( aiohttp_client.async_get_clientsession(self._hass), self._api_key diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index 39b3c8fbc20..8e773e74c75 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -342,21 +342,21 @@ class FritzBoxTools( def unique_id(self) -> str: """Return unique id.""" if not self._unique_id: - raise ClassSetupMissing() + raise ClassSetupMissing return self._unique_id @property def model(self) -> str: """Return device model.""" if not self._model: - raise ClassSetupMissing() + raise ClassSetupMissing return self._model @property def current_firmware(self) -> str: """Return current SW version.""" if not self._current_firmware: - raise ClassSetupMissing() + raise ClassSetupMissing return self._current_firmware @property @@ -378,7 +378,7 @@ class FritzBoxTools( def mac(self) -> str: """Return device Mac address.""" if not self._unique_id: - raise ClassSetupMissing() + raise ClassSetupMissing return dr.format_mac(self._unique_id) @property @@ -966,7 +966,7 @@ class FritzDeviceBase(update_coordinator.CoordinatorEntity[AvmWrapper]): async def async_process_update(self) -> None: """Update device.""" - raise NotImplementedError() + raise NotImplementedError async def async_on_demand_update(self) -> None: """Update state.""" diff --git a/homeassistant/components/fritz/switch.py b/homeassistant/components/fritz/switch.py index 26926c09223..913d0165247 100644 --- a/homeassistant/components/fritz/switch.py +++ b/homeassistant/components/fritz/switch.py @@ -289,7 +289,7 @@ class FritzBoxBaseCoordinatorSwitch(CoordinatorEntity[AvmWrapper], SwitchEntity) @property def data(self) -> dict[str, Any]: """Return entity data from coordinator data.""" - raise NotImplementedError() + raise NotImplementedError @property def available(self) -> bool: @@ -298,7 +298,7 @@ class FritzBoxBaseCoordinatorSwitch(CoordinatorEntity[AvmWrapper], SwitchEntity) async def _async_handle_turn_on_off(self, turn_on: bool) -> None: """Handle switch state change request.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_on(self, **kwargs: Any) -> None: """Turn on switch.""" diff --git a/homeassistant/components/generic/config_flow.py b/homeassistant/components/generic/config_flow.py index 0964e7f2b29..621b4dd299b 100644 --- a/homeassistant/components/generic/config_flow.py +++ b/homeassistant/components/generic/config_flow.py @@ -480,12 +480,12 @@ class CameraImagePreview(HomeAssistantView): flow = self.hass.config_entries.options.async_get(flow_id) except UnknownFlow as exc: _LOGGER.warning("Unknown flow while getting image preview") - raise web.HTTPNotFound() from exc + raise web.HTTPNotFound from exc user_input = flow["context"]["preview_cam"] camera = GenericCamera(self.hass, user_input, flow_id, "preview") if not camera.is_on: _LOGGER.debug("Camera is off") - raise web.HTTPServiceUnavailable() + raise web.HTTPServiceUnavailable image = await _async_get_image( camera, CAMERA_IMAGE_TIMEOUT, diff --git a/homeassistant/components/google_travel_time/helpers.py b/homeassistant/components/google_travel_time/helpers.py index d36adb21c18..baceffecc73 100644 --- a/homeassistant/components/google_travel_time/helpers.py +++ b/homeassistant/components/google_travel_time/helpers.py @@ -30,13 +30,13 @@ def validate_config_entry( _LOGGER.error("Request denied: %s", api_error.message) raise InvalidApiKeyException from api_error _LOGGER.error("Unknown error: %s", api_error.message) - raise UnknownException() from api_error + raise UnknownException from api_error except TransportError as transport_error: _LOGGER.error("Unknown error: %s", transport_error) - raise UnknownException() from transport_error + raise UnknownException from transport_error except Timeout as timeout_error: _LOGGER.error("Timeout error") - raise TimeoutError() from timeout_error + raise TimeoutError from timeout_error class InvalidApiKeyException(Exception): diff --git a/homeassistant/components/habitica/config_flow.py b/homeassistant/components/habitica/config_flow.py index 18bdb4b45ce..9ee2aef40ba 100644 --- a/homeassistant/components/habitica/config_flow.py +++ b/homeassistant/components/habitica/config_flow.py @@ -46,7 +46,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str, CONF_API_USER: data[CONF_API_USER], } except ClientResponseError as ex: - raise InvalidAuth() from ex + raise InvalidAuth from ex class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN): diff --git a/homeassistant/components/hassio/auth.py b/homeassistant/components/hassio/auth.py index 52016b20659..6ca89ee24be 100644 --- a/homeassistant/components/hassio/auth.py +++ b/homeassistant/components/hassio/auth.py @@ -48,12 +48,12 @@ class HassIOBaseAuth(HomeAssistantView): hassio_ip ): _LOGGER.error("Invalid auth request from %s", request.remote) - raise HTTPUnauthorized() + raise HTTPUnauthorized # Check caller token if request[KEY_HASS_USER].id != self.user.id: _LOGGER.error("Invalid auth request from %s", request[KEY_HASS_USER].name) - raise HTTPUnauthorized() + raise HTTPUnauthorized class HassIOAuth(HassIOBaseAuth): @@ -82,7 +82,7 @@ class HassIOAuth(HassIOBaseAuth): data[ATTR_USERNAME], data[ATTR_PASSWORD] ) except auth_ha.InvalidAuth: - raise HTTPNotFound() from None + raise HTTPNotFound from None return web.Response(status=HTTPStatus.OK) @@ -112,6 +112,6 @@ class HassIOPasswordReset(HassIOBaseAuth): data[ATTR_USERNAME], data[ATTR_PASSWORD] ) except auth_ha.InvalidUser as err: - raise HTTPNotFound() from err + raise HTTPNotFound from err return web.Response(status=HTTPStatus.OK) diff --git a/homeassistant/components/hassio/discovery.py b/homeassistant/components/hassio/discovery.py index 173583c9891..66be8267d53 100644 --- a/homeassistant/components/hassio/discovery.py +++ b/homeassistant/components/hassio/discovery.py @@ -78,7 +78,7 @@ class HassIODiscovery(HomeAssistantView): data = await self.hassio.get_discovery_message(uuid) except HassioAPIError as err: _LOGGER.error("Can't read discovery data: %s", err) - raise HTTPServiceUnavailable() from None + raise HTTPServiceUnavailable from None await self.async_process_new(data) return web.Response() diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index db0a5ac0528..ff34aa06cf3 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -571,7 +571,7 @@ class HassIO: # such as ../../../../etc/passwd if url != str(joined_url): _LOGGER.error("Invalid request %s", command) - raise HassioAPIError() + raise HassioAPIError try: response = await self.websession.request( @@ -598,7 +598,7 @@ class HassIO: method, response.status, ) - raise HassioAPIError() + raise HassioAPIError if return_text: return await response.text(encoding="utf-8") @@ -611,4 +611,4 @@ class HassIO: except aiohttp.ClientError as err: _LOGGER.error("Client error on %s request %s", command, err) - raise HassioAPIError() + raise HassioAPIError diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index edbcf93d7e5..0b92ada6c70 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -196,7 +196,7 @@ class HassIOView(HomeAssistantView): except TimeoutError: _LOGGER.error("Client timeout error on API request %s", path) - raise HTTPBadGateway() + raise HTTPBadGateway get = _handle post = _handle diff --git a/homeassistant/components/hassio/ingress.py b/homeassistant/components/hassio/ingress.py index d325fb10f35..6d6faa6fe75 100644 --- a/homeassistant/components/hassio/ingress.py +++ b/homeassistant/components/hassio/ingress.py @@ -77,10 +77,10 @@ class HassIOIngress(HomeAssistantView): try: target_url = URL(url) except ValueError as err: - raise HTTPBadRequest() from err + raise HTTPBadRequest from err if not target_url.path.startswith(base_path): - raise HTTPBadRequest() + raise HTTPBadRequest return target_url @@ -99,7 +99,7 @@ class HassIOIngress(HomeAssistantView): except aiohttp.ClientError as err: _LOGGER.debug("Ingress error with %s / %s: %s", token, path, err) - raise HTTPBadGateway() from None + raise HTTPBadGateway from None get = _handle post = _handle @@ -247,7 +247,7 @@ def _init_header(request: web.Request, token: str) -> CIMultiDict | dict[str, st assert request.transport if (peername := request.transport.get_extra_info("peername")) is None: _LOGGER.error("Can't set forward_for header, missing peername") - raise HTTPBadRequest() + raise HTTPBadRequest headers[hdrs.X_FORWARDED_FOR] = _forwarded_for_header(forward_for, peername[0]) diff --git a/homeassistant/components/hassio/websocket_api.py b/homeassistant/components/hassio/websocket_api.py index 6313ebd5eaf..03ca424035c 100644 --- a/homeassistant/components/hassio/websocket_api.py +++ b/homeassistant/components/hassio/websocket_api.py @@ -112,7 +112,7 @@ async def websocket_supervisor_api( if not connection.user.is_admin and not WS_NO_ADMIN_ENDPOINTS.match( msg[ATTR_ENDPOINT] ): - raise Unauthorized() + raise Unauthorized supervisor: HassIO = hass.data[DOMAIN] command = msg[ATTR_ENDPOINT] diff --git a/homeassistant/components/hdmi_cec/media_player.py b/homeassistant/components/hdmi_cec/media_player.py index 4cd95a6c382..e86a1f5be70 100644 --- a/homeassistant/components/hdmi_cec/media_player.py +++ b/homeassistant/components/hdmi_cec/media_player.py @@ -95,7 +95,7 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity): def clear_playlist(self) -> None: """Clear players playlist.""" - raise NotImplementedError() + raise NotImplementedError def turn_off(self) -> None: """Turn device off.""" @@ -111,7 +111,7 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity): self, media_type: MediaType | str, media_id: str, **kwargs: Any ) -> None: """Not supported.""" - raise NotImplementedError() + raise NotImplementedError def media_next_track(self) -> None: """Skip to next track.""" @@ -119,11 +119,11 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity): def media_seek(self, position: float) -> None: """Not supported.""" - raise NotImplementedError() + raise NotImplementedError def set_volume_level(self, volume: float) -> None: """Set volume level, range 0..1.""" - raise NotImplementedError() + raise NotImplementedError def media_pause(self) -> None: """Pause playback.""" @@ -132,7 +132,7 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity): def select_source(self, source: str) -> None: """Not supported.""" - raise NotImplementedError() + raise NotImplementedError def media_play(self) -> None: """Start playback.""" diff --git a/homeassistant/components/hive/__init__.py b/homeassistant/components/hive/__init__.py index 834054dd91c..fb2733223eb 100644 --- a/homeassistant/components/hive/__init__.py +++ b/homeassistant/components/hive/__init__.py @@ -90,7 +90,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: devices = await hive.session.startSession(hive_config) except HTTPException as error: _LOGGER.error("Could not connect to the internet: %s", error) - raise ConfigEntryNotReady() from error + raise ConfigEntryNotReady from error except HiveReauthRequired as err: raise ConfigEntryAuthFailed from err diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 8fc96cff954..a5c08a3bbd4 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -1163,7 +1163,7 @@ class HomeKitPairingQRView(HomeAssistantView): async def get(self, request: web.Request) -> web.Response: """Retrieve the pairing QRCode image.""" if not request.query_string: - raise Unauthorized() + raise Unauthorized entry_id, secret = request.query_string.split("-") hass = request.app[KEY_HASS] domain_data: dict[str, HomeKitEntryData] = hass.data[DOMAIN] @@ -1173,7 +1173,7 @@ class HomeKitPairingQRView(HomeAssistantView): or not entry_data.pairing_qr_secret or secret != entry_data.pairing_qr_secret ): - raise Unauthorized() + raise Unauthorized return web.Response( body=entry_data.pairing_qr, content_type="image/svg+xml", diff --git a/homeassistant/components/homekit/accessories.py b/homeassistant/components/homekit/accessories.py index 7c8eb973911..f39bf32744a 100644 --- a/homeassistant/components/homekit/accessories.py +++ b/homeassistant/components/homekit/accessories.py @@ -588,7 +588,7 @@ class HomeAccessory(Accessory): # type: ignore[misc] Overridden by accessory types. """ - raise NotImplementedError() + raise NotImplementedError @ha_callback def async_call_service( diff --git a/homeassistant/components/http/ban.py b/homeassistant/components/http/ban.py index 5a0f40cdeab..eec951fb907 100644 --- a/homeassistant/components/http/ban.py +++ b/homeassistant/components/http/ban.py @@ -82,7 +82,7 @@ async def ban_middleware( # Verify if IP is not banned ip_address_ = ip_address(request.remote) # type: ignore[arg-type] if ip_address_ in ip_bans_lookup: - raise HTTPForbidden() + raise HTTPForbidden try: return await handler(request) diff --git a/homeassistant/components/http/static.py b/homeassistant/components/http/static.py index bdc7b08ee4a..fd6cd742ce4 100644 --- a/homeassistant/components/http/static.py +++ b/homeassistant/components/http/static.py @@ -52,14 +52,14 @@ class CachingStaticResource(StaticResource): filepath = await hass.async_add_executor_job(_get_file_path, *key) except (ValueError, FileNotFoundError) as error: # relatively safe - raise HTTPNotFound() from error + raise HTTPNotFound from error except HTTPForbidden: # forbidden raise except Exception as error: # perm error or other kind! request.app.logger.exception(error) - raise HTTPNotFound() from error + raise HTTPNotFound from error content_type: str | None = None if filepath is not None: diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index 97f78aba21c..bf3ce16fa92 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -248,7 +248,7 @@ class HumidifierEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_AT def set_humidity(self, humidity: int) -> None: """Set new target humidity.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_humidity(self, humidity: int) -> None: """Set new target humidity.""" @@ -256,7 +256,7 @@ class HumidifierEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_AT def set_mode(self, mode: str) -> None: """Set new mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_mode(self, mode: str) -> None: """Set new mode.""" diff --git a/homeassistant/components/icloud/config_flow.py b/homeassistant/components/icloud/config_flow.py index caec770743b..36fe880ec79 100644 --- a/homeassistant/components/icloud/config_flow.py +++ b/homeassistant/components/icloud/config_flow.py @@ -141,7 +141,7 @@ class IcloudFlowHandler(ConfigFlow, domain=DOMAIN): getattr, self.api, "devices" ) if not devices: - raise PyiCloudNoDevicesException() + raise PyiCloudNoDevicesException except (PyiCloudServiceNotActivatedException, PyiCloudNoDevicesException): _LOGGER.error("No device found in the iCloud account: %s", self._username) self.api = None diff --git a/homeassistant/components/image/__init__.py b/homeassistant/components/image/__init__.py index 35869f31792..47767a004cb 100644 --- a/homeassistant/components/image/__init__.py +++ b/homeassistant/components/image/__init__.py @@ -190,7 +190,7 @@ class ImageEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def image(self) -> bytes | None: """Return bytes of image.""" - raise NotImplementedError() + raise NotImplementedError async def _fetch_url(self, url: str) -> httpx.Response | None: """Fetch a URL.""" @@ -278,7 +278,7 @@ class ImageView(HomeAssistantView): async def get(self, request: web.Request, entity_id: str) -> web.StreamResponse: """Start a GET request.""" if (image_entity := self.component.get_entity(entity_id)) is None: - raise web.HTTPNotFound() + raise web.HTTPNotFound authenticated = ( request[KEY_AUTHENTICATED] @@ -289,9 +289,9 @@ class ImageView(HomeAssistantView): # Attempt with invalid bearer token, raise unauthorized # so ban middleware can handle it. if hdrs.AUTHORIZATION in request.headers: - raise web.HTTPUnauthorized() + raise web.HTTPUnauthorized # Invalid sigAuth or image entity access token - raise web.HTTPForbidden() + raise web.HTTPForbidden return await self.handle(request, image_entity) @@ -302,7 +302,7 @@ class ImageView(HomeAssistantView): try: image = await _async_get_image(image_entity, IMAGE_TIMEOUT) except (HomeAssistantError, ValueError) as ex: - raise web.HTTPInternalServerError() from ex + raise web.HTTPInternalServerError from ex return web.Response(body=image.content, content_type=image.content_type) diff --git a/homeassistant/components/image_processing/__init__.py b/homeassistant/components/image_processing/__init__.py index ed366c0bdfc..2c1d0f9304c 100644 --- a/homeassistant/components/image_processing/__init__.py +++ b/homeassistant/components/image_processing/__init__.py @@ -165,7 +165,7 @@ class ImageProcessingEntity(Entity): def process_image(self, image: bytes) -> None: """Process image.""" - raise NotImplementedError() + raise NotImplementedError async def async_process_image(self, image: bytes) -> None: """Process image.""" diff --git a/homeassistant/components/image_upload/__init__.py b/homeassistant/components/image_upload/__init__.py index 4bde9730674..19763e65fa5 100644 --- a/homeassistant/components/image_upload/__init__.py +++ b/homeassistant/components/image_upload/__init__.py @@ -199,7 +199,7 @@ class ImageServeView(HomeAssistantView): image_info = self.image_collection.data.get(image_id) if image_info is None: - raise web.HTTPNotFound() + raise web.HTTPNotFound hass = request.app[KEY_HASS] target_file = self.image_folder / image_id / f"{width}x{height}" diff --git a/homeassistant/components/imap/coordinator.py b/homeassistant/components/imap/coordinator.py index 2881f9f515e..78b52e06db3 100644 --- a/homeassistant/components/imap/coordinator.py +++ b/homeassistant/components/imap/coordinator.py @@ -406,7 +406,7 @@ class ImapPollingDataUpdateCoordinator(ImapDataUpdateCoordinator): ) as ex: await self._cleanup() self.async_set_update_error(ex) - raise UpdateFailed() from ex + raise UpdateFailed from ex except InvalidFolder as ex: _LOGGER.warning("Selected mailbox folder is invalid") await self._cleanup() @@ -423,7 +423,7 @@ class ImapPollingDataUpdateCoordinator(ImapDataUpdateCoordinator): ) self.config_entry.async_start_reauth(self.hass) self.async_set_update_error(ex) - raise ConfigEntryAuthFailed() from ex + raise ConfigEntryAuthFailed from ex class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator): diff --git a/homeassistant/components/influxdb/sensor.py b/homeassistant/components/influxdb/sensor.py index b9ce68e198c..03b6acb204c 100644 --- a/homeassistant/components/influxdb/sensor.py +++ b/homeassistant/components/influxdb/sensor.py @@ -166,7 +166,7 @@ def setup_platform( influx = get_influx_connection(config, test_read=True) except ConnectionError as exc: _LOGGER.error(exc) - raise PlatformNotReady() from exc + raise PlatformNotReady from exc entities = [] if CONF_QUERIES_FLUX in config: diff --git a/homeassistant/components/iqvia/__init__.py b/homeassistant/components/iqvia/__init__.py index 27d7d46f677..eef7f929cab 100644 --- a/homeassistant/components/iqvia/__init__.py +++ b/homeassistant/components/iqvia/__init__.py @@ -92,7 +92,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # The IQVIA API can be selectively flaky, meaning that any number of the setup # API calls could fail. We only retry integration setup if *all* of the initial # API calls fail: - raise ConfigEntryNotReady() + raise ConfigEntryNotReady # Once we've successfully authenticated, we re-enable client request retries: client.enable_request_retries() diff --git a/homeassistant/components/justnimbus/__init__.py b/homeassistant/components/justnimbus/__init__.py index e4be25b8959..101a2086962 100644 --- a/homeassistant/components/justnimbus/__init__.py +++ b/homeassistant/components/justnimbus/__init__.py @@ -15,7 +15,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if "zip_code" in entry.data: coordinator = JustNimbusCoordinator(hass=hass, entry=entry) else: - raise ConfigEntryAuthFailed() + raise ConfigEntryAuthFailed await coordinator.async_config_entry_first_refresh() hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator diff --git a/homeassistant/components/kef/media_player.py b/homeassistant/components/kef/media_player.py index 03f3468dc15..d7d33dabd44 100644 --- a/homeassistant/components/kef/media_player.py +++ b/homeassistant/components/kef/media_player.py @@ -270,7 +270,7 @@ class KefMediaPlayer(MediaPlayerEntity): async def async_turn_on(self) -> None: """Turn the media player on.""" if not self._supports_on: - raise NotImplementedError() + raise NotImplementedError await self._speaker.turn_on() async def async_volume_up(self) -> None: diff --git a/homeassistant/components/kodi/config_flow.py b/homeassistant/components/kodi/config_flow.py index 30cac5dbdd4..1d9d1ca4f7c 100644 --- a/homeassistant/components/kodi/config_flow.py +++ b/homeassistant/components/kodi/config_flow.py @@ -78,7 +78,7 @@ async def validate_ws(hass: HomeAssistant, data): await kwc.connect() if not kwc.connected: _LOGGER.warning("Cannot connect to %s:%s over WebSocket", host, ws_port) - raise WSCannotConnect() + raise WSCannotConnect kodi = Kodi(kwc) await kodi.ping() except CannotConnectError as error: diff --git a/homeassistant/components/lawn_mower/__init__.py b/homeassistant/components/lawn_mower/__init__.py index 5be457ab88f..f28bd1308b0 100644 --- a/homeassistant/components/lawn_mower/__init__.py +++ b/homeassistant/components/lawn_mower/__init__.py @@ -108,7 +108,7 @@ class LawnMowerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def start_mowing(self) -> None: """Start or resume mowing.""" - raise NotImplementedError() + raise NotImplementedError async def async_start_mowing(self) -> None: """Start or resume mowing.""" @@ -116,7 +116,7 @@ class LawnMowerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def dock(self) -> None: """Dock the mower.""" - raise NotImplementedError() + raise NotImplementedError async def async_dock(self) -> None: """Dock the mower.""" @@ -124,7 +124,7 @@ class LawnMowerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def pause(self) -> None: """Pause the lawn mower.""" - raise NotImplementedError() + raise NotImplementedError async def async_pause(self) -> None: """Pause the lawn mower.""" diff --git a/homeassistant/components/litejet/light.py b/homeassistant/components/litejet/light.py index b387c6f8890..f2b9af9adb4 100644 --- a/homeassistant/components/litejet/light.py +++ b/homeassistant/components/litejet/light.py @@ -97,7 +97,7 @@ class LiteJetLight(LightEntity): try: await self._lj.activate_load(self._index) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc return # If either attribute is specified then Home Assistant must @@ -109,7 +109,7 @@ class LiteJetLight(LightEntity): try: await self._lj.activate_load_at(self._index, brightness, int(transition)) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the light.""" @@ -117,7 +117,7 @@ class LiteJetLight(LightEntity): try: await self._lj.activate_load_at(self._index, 0, kwargs[ATTR_TRANSITION]) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc return # If transition attribute is not specified then the simple @@ -126,7 +126,7 @@ class LiteJetLight(LightEntity): try: await self._lj.deactivate_load(self._index) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc async def async_update(self) -> None: """Retrieve the light's brightness from the LiteJet system.""" diff --git a/homeassistant/components/litejet/scene.py b/homeassistant/components/litejet/scene.py index ab1e0687710..712e223aa3e 100644 --- a/homeassistant/components/litejet/scene.py +++ b/homeassistant/components/litejet/scene.py @@ -77,4 +77,4 @@ class LiteJetScene(Scene): try: await self._lj.activate_scene(self._index) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc diff --git a/homeassistant/components/litejet/switch.py b/homeassistant/components/litejet/switch.py index cf294be8054..28f751f3ec1 100644 --- a/homeassistant/components/litejet/switch.py +++ b/homeassistant/components/litejet/switch.py @@ -92,11 +92,11 @@ class LiteJetSwitch(SwitchEntity): try: await self._lj.press_switch(self._index) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc async def async_turn_off(self, **kwargs: Any) -> None: """Release the switch.""" try: await self._lj.release_switch(self._index) except LiteJetError as exc: - raise HomeAssistantError() from exc + raise HomeAssistantError from exc diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index da342410308..e8b7a013523 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -219,7 +219,7 @@ class LockEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def lock(self, **kwargs: Any) -> None: """Lock the lock.""" - raise NotImplementedError() + raise NotImplementedError async def async_lock(self, **kwargs: Any) -> None: """Lock the lock.""" @@ -232,7 +232,7 @@ class LockEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def unlock(self, **kwargs: Any) -> None: """Unlock the lock.""" - raise NotImplementedError() + raise NotImplementedError async def async_unlock(self, **kwargs: Any) -> None: """Unlock the lock.""" @@ -245,7 +245,7 @@ class LockEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def open(self, **kwargs: Any) -> None: """Open the door latch.""" - raise NotImplementedError() + raise NotImplementedError async def async_open(self, **kwargs: Any) -> None: """Open the door latch.""" diff --git a/homeassistant/components/mailbox/__init__.py b/homeassistant/components/mailbox/__init__.py index 4d585413519..b000f1eadcb 100644 --- a/homeassistant/components/mailbox/__init__.py +++ b/homeassistant/components/mailbox/__init__.py @@ -180,7 +180,7 @@ class Mailbox: @property def media_type(self) -> str: """Return the supported media type.""" - raise NotImplementedError() + raise NotImplementedError @property def can_delete(self) -> bool: @@ -194,15 +194,15 @@ class Mailbox: async def async_get_media(self, msgid: str) -> bytes: """Return the media blob for the msgid.""" - raise NotImplementedError() + raise NotImplementedError async def async_get_messages(self) -> list[dict[str, Any]]: """Return a list of the current messages.""" - raise NotImplementedError() + raise NotImplementedError async def async_delete(self, msgid: str) -> bool: """Delete the specified messages.""" - raise NotImplementedError() + raise NotImplementedError class StreamError(Exception): diff --git a/homeassistant/components/media_extractor/__init__.py b/homeassistant/components/media_extractor/__init__.py index f6b153b2ef8..888265e8d3c 100644 --- a/homeassistant/components/media_extractor/__init__.py +++ b/homeassistant/components/media_extractor/__init__.py @@ -127,7 +127,7 @@ class MediaExtractor: all_media = ydl.extract_info(self.get_media_url(), process=False) except DownloadError as err: # This exception will be logged by youtube-dl itself - raise MEDownloadException() from err + raise MEDownloadException from err if "entries" in all_media: _LOGGER.warning("Playlists are not supported, looking for the first video") @@ -136,7 +136,7 @@ class MediaExtractor: selected_media = entries[0] else: _LOGGER.error("Playlist is empty") - raise MEDownloadException() + raise MEDownloadException else: selected_media = all_media @@ -147,7 +147,7 @@ class MediaExtractor: requested_stream = ydl.process_ie_result(selected_media, download=False) except (ExtractorError, DownloadError) as err: _LOGGER.error("Could not extract stream for the query: %s", query) - raise MEQueryException() from err + raise MEQueryException from err if "formats" in requested_stream: if requested_stream["extractor"] == "youtube": diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index cc768232287..6535aea3e52 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -783,7 +783,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_on(self) -> None: """Turn the media player on.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_on(self) -> None: """Turn the media player on.""" @@ -791,7 +791,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_off(self) -> None: """Turn the media player off.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_off(self) -> None: """Turn the media player off.""" @@ -799,7 +799,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def mute_volume(self, mute: bool) -> None: """Mute the volume.""" - raise NotImplementedError() + raise NotImplementedError async def async_mute_volume(self, mute: bool) -> None: """Mute the volume.""" @@ -807,7 +807,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_volume_level(self, volume: float) -> None: """Set volume level, range 0..1.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_volume_level(self, volume: float) -> None: """Set volume level, range 0..1.""" @@ -815,7 +815,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def media_play(self) -> None: """Send play command.""" - raise NotImplementedError() + raise NotImplementedError async def async_media_play(self) -> None: """Send play command.""" @@ -823,7 +823,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def media_pause(self) -> None: """Send pause command.""" - raise NotImplementedError() + raise NotImplementedError async def async_media_pause(self) -> None: """Send pause command.""" @@ -831,7 +831,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def media_stop(self) -> None: """Send stop command.""" - raise NotImplementedError() + raise NotImplementedError async def async_media_stop(self) -> None: """Send stop command.""" @@ -839,7 +839,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def media_previous_track(self) -> None: """Send previous track command.""" - raise NotImplementedError() + raise NotImplementedError async def async_media_previous_track(self) -> None: """Send previous track command.""" @@ -847,7 +847,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def media_next_track(self) -> None: """Send next track command.""" - raise NotImplementedError() + raise NotImplementedError async def async_media_next_track(self) -> None: """Send next track command.""" @@ -855,7 +855,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def media_seek(self, position: float) -> None: """Send seek command.""" - raise NotImplementedError() + raise NotImplementedError async def async_media_seek(self, position: float) -> None: """Send seek command.""" @@ -865,7 +865,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): self, media_type: MediaType | str, media_id: str, **kwargs: Any ) -> None: """Play a piece of media.""" - raise NotImplementedError() + raise NotImplementedError async def async_play_media( self, media_type: MediaType | str, media_id: str, **kwargs: Any @@ -877,7 +877,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def select_source(self, source: str) -> None: """Select input source.""" - raise NotImplementedError() + raise NotImplementedError async def async_select_source(self, source: str) -> None: """Select input source.""" @@ -885,7 +885,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def select_sound_mode(self, sound_mode: str) -> None: """Select sound mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_select_sound_mode(self, sound_mode: str) -> None: """Select sound mode.""" @@ -893,7 +893,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def clear_playlist(self) -> None: """Clear players playlist.""" - raise NotImplementedError() + raise NotImplementedError async def async_clear_playlist(self) -> None: """Clear players playlist.""" @@ -901,7 +901,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_shuffle(self, shuffle: bool) -> None: """Enable/disable shuffle mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_shuffle(self, shuffle: bool) -> None: """Enable/disable shuffle mode.""" @@ -909,7 +909,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_repeat(self, repeat: RepeatMode) -> None: """Set repeat mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_repeat(self, repeat: RepeatMode) -> None: """Set repeat mode.""" @@ -1135,11 +1135,11 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): The BrowseMedia instance will be used by the "media_player/browse_media" websocket command. """ - raise NotImplementedError() + raise NotImplementedError def join_players(self, group_members: list[str]) -> None: """Join `group_members` as a player group with the current player.""" - raise NotImplementedError() + raise NotImplementedError async def async_join_players(self, group_members: list[str]) -> None: """Join `group_members` as a player group with the current player.""" @@ -1147,7 +1147,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def unjoin_player(self) -> None: """Remove this player from any group.""" - raise NotImplementedError() + raise NotImplementedError async def async_unjoin_player(self) -> None: """Remove this player from any group.""" diff --git a/homeassistant/components/media_source/local_source.py b/homeassistant/components/media_source/local_source.py index 8d739d8d027..8a67ae4a5b4 100644 --- a/homeassistant/components/media_source/local_source.py +++ b/homeassistant/components/media_source/local_source.py @@ -219,21 +219,21 @@ class LocalMediaView(http.HomeAssistantView): try: raise_if_invalid_path(location) except ValueError as err: - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err if source_dir_id not in self.hass.config.media_dirs: - raise web.HTTPNotFound() + raise web.HTTPNotFound media_path = self.source.async_full_path(source_dir_id, location) # Check that the file exists if not media_path.is_file(): - raise web.HTTPNotFound() + raise web.HTTPNotFound # Check that it's a media file mime_type, _ = mimetypes.guess_type(str(media_path)) if not mime_type or mime_type.split("/")[0] not in MEDIA_MIME_TYPES: - raise web.HTTPNotFound() + raise web.HTTPNotFound return web.FileResponse(media_path) @@ -265,19 +265,19 @@ class UploadMediaView(http.HomeAssistantView): data = self.schema(dict(await request.post())) except vol.Invalid as err: LOGGER.error("Received invalid upload data: %s", err) - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err try: item = MediaSourceItem.from_uri(self.hass, data["media_content_id"], None) except ValueError as err: LOGGER.error("Received invalid upload data: %s", err) - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err try: source_dir_id, location = self.source.async_parse_identifier(item) except Unresolvable as err: LOGGER.error("Invalid local source ID") - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err uploaded_file: FileField = data["file"] @@ -289,7 +289,7 @@ class UploadMediaView(http.HomeAssistantView): raise_if_invalid_filename(uploaded_file.filename) except ValueError as err: LOGGER.error("Invalid filename") - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err try: await self.hass.async_add_executor_job( @@ -299,7 +299,7 @@ class UploadMediaView(http.HomeAssistantView): ) except ValueError as err: LOGGER.error("Moving upload failed: %s", err) - raise web.HTTPBadRequest() from err + raise web.HTTPBadRequest from err return self.json( {"media_content_id": f"{data['media_content_id']}/{uploaded_file.filename}"} diff --git a/homeassistant/components/met/coordinator.py b/homeassistant/components/met/coordinator.py index e5a4dbf754c..ef73e1b52ab 100644 --- a/homeassistant/components/met/coordinator.py +++ b/homeassistant/components/met/coordinator.py @@ -78,7 +78,7 @@ class MetWeatherData: """Fetch data from API - (current weather and forecast).""" resp = await self._weather_data.fetching_data() if not resp: - raise CannotConnect() + raise CannotConnect self.current_weather_data = self._weather_data.get_current_weather() time_zone = dt_util.DEFAULT_TIME_ZONE self.daily_forecast = self._weather_data.get_forecast(time_zone, False, 0) diff --git a/homeassistant/components/metoffice/__init__.py b/homeassistant/components/metoffice/__init__.py index cdc6c2c7500..18fc121d5d3 100644 --- a/homeassistant/components/metoffice/__init__.py +++ b/homeassistant/components/metoffice/__init__.py @@ -94,7 +94,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: fetch_site, connection, latitude, longitude ) if site is None: - raise ConfigEntryNotReady() + raise ConfigEntryNotReady async def async_update_3hourly() -> MetOfficeData: return await hass.async_add_executor_job( diff --git a/homeassistant/components/metoffice/config_flow.py b/homeassistant/components/metoffice/config_flow.py index 196d24ff68a..8b3c10cd460 100644 --- a/homeassistant/components/metoffice/config_flow.py +++ b/homeassistant/components/metoffice/config_flow.py @@ -36,7 +36,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str, ) if site is None: - raise CannotConnect() + raise CannotConnect return {"site_name": site.name} diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index 3cef5ae645a..3e16c21261b 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -296,7 +296,7 @@ async def webhook_call_service( config_entry.data[ATTR_DEVICE_NAME], ex, ) - raise HTTPBadRequest() from ex + raise HTTPBadRequest from ex return empty_okay_response() diff --git a/homeassistant/components/mystrom/__init__.py b/homeassistant/components/mystrom/__init__.py index 3c6a5805ddb..09cd7b42da0 100644 --- a/homeassistant/components/mystrom/__init__.py +++ b/homeassistant/components/mystrom/__init__.py @@ -30,7 +30,7 @@ async def _async_get_device_state( await device.get_state() except MyStromConnectionError as err: _LOGGER.error("No route to myStrom plug: %s", ip_address) - raise ConfigEntryNotReady() from err + raise ConfigEntryNotReady from err def _get_mystrom_bulb(host: str, mac: str) -> MyStromBulb: @@ -48,7 +48,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: info = await pymystrom.get_device_info(host) except MyStromConnectionError as err: _LOGGER.error("No route to myStrom plug: %s", host) - raise ConfigEntryNotReady() from err + raise ConfigEntryNotReady from err info.setdefault("type", 101) diff --git a/homeassistant/components/nederlandse_spoorwegen/sensor.py b/homeassistant/components/nederlandse_spoorwegen/sensor.py index d99e4c62646..55727289181 100644 --- a/homeassistant/components/nederlandse_spoorwegen/sensor.py +++ b/homeassistant/components/nederlandse_spoorwegen/sensor.py @@ -64,7 +64,7 @@ def setup_platform( requests.exceptions.HTTPError, ) as error: _LOGGER.error("Could not connect to the internet: %s", error) - raise PlatformNotReady() from error + raise PlatformNotReady from error except RequestParametersError as error: _LOGGER.error("Could not fetch stations, please check configuration: %s", error) return diff --git a/homeassistant/components/notify/legacy.py b/homeassistant/components/notify/legacy.py index 664e3a6d10d..6b29df504d9 100644 --- a/homeassistant/components/notify/legacy.py +++ b/homeassistant/components/notify/legacy.py @@ -232,7 +232,7 @@ class BaseNotificationService: kwargs can contain ATTR_TITLE to specify a title. """ - raise NotImplementedError() + raise NotImplementedError async def async_send_message(self, message: str, **kwargs: Any) -> None: """Send a message. diff --git a/homeassistant/components/number/__init__.py b/homeassistant/components/number/__init__.py index 5d21109f3fe..8c55bbc2cba 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -394,7 +394,7 @@ class NumberEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_native_value(self, value: float) -> None: """Set new value.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_native_value(self, value: float) -> None: """Set new value.""" @@ -403,7 +403,7 @@ class NumberEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): @final def set_value(self, value: float) -> None: """Set new value.""" - raise NotImplementedError() + raise NotImplementedError @final async def async_set_value(self, value: float) -> None: diff --git a/homeassistant/components/onboarding/views.py b/homeassistant/components/onboarding/views.py index bb4d84d1b50..1ecfc10d974 100644 --- a/homeassistant/components/onboarding/views.py +++ b/homeassistant/components/onboarding/views.py @@ -84,7 +84,7 @@ class InstallationTypeOnboardingView(HomeAssistantView): async def get(self, request: web.Request) -> web.Response: """Return the onboarding status.""" if self._data["done"]: - raise HTTPUnauthorized() + raise HTTPUnauthorized hass = request.app[KEY_HASS] info = await async_get_system_info(hass) diff --git a/homeassistant/components/onewire/__init__.py b/homeassistant/components/onewire/__init__.py index 95082c9d9e2..72119915246 100644 --- a/homeassistant/components/onewire/__init__.py +++ b/homeassistant/components/onewire/__init__.py @@ -26,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: CannotConnect, # Failed to connect to the server protocol.OwnetError, # Connected to server, but failed to list the devices ) as exc: - raise ConfigEntryNotReady() from exc + raise ConfigEntryNotReady from exc hass.data[DOMAIN][entry.entry_id] = onewire_hub diff --git a/homeassistant/components/onvif/__init__.py b/homeassistant/components/onvif/__init__.py index 5c97abee77a..02e7e28ea18 100644 --- a/homeassistant/components/onvif/__init__.py +++ b/homeassistant/components/onvif/__init__.py @@ -87,7 +87,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise ConfigEntryNotReady(f"Setup was unexpectedly canceled: {err}") from err if not device.available: - raise ConfigEntryNotReady() + raise ConfigEntryNotReady hass.data[DOMAIN][entry.unique_id] = device diff --git a/homeassistant/components/osoenergy/__init__.py b/homeassistant/components/osoenergy/__init__.py index 269fd6614b7..48ea01e8bb8 100644 --- a/homeassistant/components/osoenergy/__init__.py +++ b/homeassistant/components/osoenergy/__init__.py @@ -45,7 +45,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: devices: Any = await osoenergy.session.start_session(osoenergy_config) except HTTPException as error: - raise ConfigEntryNotReady() from error + raise ConfigEntryNotReady from error except OSOEnergyReauthRequired as err: raise ConfigEntryAuthFailed from err diff --git a/homeassistant/components/proxy/camera.py b/homeassistant/components/proxy/camera.py index c50dc819f9a..3a93c7a2d36 100644 --- a/homeassistant/components/proxy/camera.py +++ b/homeassistant/components/proxy/camera.py @@ -78,16 +78,16 @@ async def async_setup_platform( def _precheck_image(image, opts): """Perform some pre-checks on the given image.""" if not opts: - raise ValueError() + raise ValueError try: img = Image.open(io.BytesIO(image)) except OSError as err: _LOGGER.warning("Failed to open image") - raise ValueError() from err + raise ValueError from err imgfmt = str(img.format) if imgfmt not in ("PNG", "JPEG"): _LOGGER.warning("Image is of unsupported type: %s", imgfmt) - raise ValueError() + raise ValueError if img.mode != "RGB": img = img.convert("RGB") return img @@ -292,7 +292,7 @@ class ProxyCamera(Camera): if not image: return None except HomeAssistantError as err: - raise asyncio.CancelledError() from err + raise asyncio.CancelledError from err if self._mode == MODE_RESIZE: job = _resize_image diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index fffbc913fe8..2b88c51e936 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -235,7 +235,7 @@ class RemoteEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_) def send_command(self, command: Iterable[str], **kwargs: Any) -> None: """Send commands to a device.""" - raise NotImplementedError() + raise NotImplementedError async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None: """Send commands to a device.""" @@ -245,7 +245,7 @@ class RemoteEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_) def learn_command(self, **kwargs: Any) -> None: """Learn a command from a device.""" - raise NotImplementedError() + raise NotImplementedError async def async_learn_command(self, **kwargs: Any) -> None: """Learn a command from a device.""" @@ -253,7 +253,7 @@ class RemoteEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_) def delete_command(self, **kwargs: Any) -> None: """Delete commands from the database.""" - raise NotImplementedError() + raise NotImplementedError async def async_delete_command(self, **kwargs: Any) -> None: """Delete commands from the database.""" diff --git a/homeassistant/components/renault/__init__.py b/homeassistant/components/renault/__init__.py index f2a02be7b49..62425d9c20e 100644 --- a/homeassistant/components/renault/__init__.py +++ b/homeassistant/components/renault/__init__.py @@ -21,16 +21,16 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b config_entry.data[CONF_USERNAME], config_entry.data[CONF_PASSWORD] ) except (aiohttp.ClientConnectionError, GigyaException) as exc: - raise ConfigEntryNotReady() from exc + raise ConfigEntryNotReady from exc if not login_success: - raise ConfigEntryAuthFailed() + raise ConfigEntryAuthFailed hass.data.setdefault(DOMAIN, {}) try: await renault_hub.async_initialise(config_entry) except aiohttp.ClientError as exc: - raise ConfigEntryNotReady() from exc + raise ConfigEntryNotReady from exc hass.data[DOMAIN][config_entry.entry_id] = renault_hub diff --git a/homeassistant/components/rflink/__init__.py b/homeassistant/components/rflink/__init__.py index ee2e1cb9fff..74b7d4aa4c0 100644 --- a/homeassistant/components/rflink/__init__.py +++ b/homeassistant/components/rflink/__init__.py @@ -377,7 +377,7 @@ class RflinkDevice(Entity): def _handle_event(self, event): """Platform specific event handler.""" - raise NotImplementedError() + raise NotImplementedError @property def name(self): diff --git a/homeassistant/components/risco/__init__.py b/homeassistant/components/risco/__init__.py index 02e51bcc4ea..309cad7610e 100644 --- a/homeassistant/components/risco/__init__.py +++ b/homeassistant/components/risco/__init__.py @@ -89,7 +89,7 @@ async def _async_setup_local_entry(hass: HomeAssistant, entry: ConfigEntry) -> b try: await risco.connect() except CannotConnectError as error: - raise ConfigEntryNotReady() from error + raise ConfigEntryNotReady from error except UnauthorizedError: _LOGGER.exception("Failed to login to Risco cloud") return False diff --git a/homeassistant/components/scene/__init__.py b/homeassistant/components/scene/__init__.py index ee1937b65c9..1baf25735fa 100644 --- a/homeassistant/components/scene/__init__.py +++ b/homeassistant/components/scene/__init__.py @@ -125,7 +125,7 @@ class Scene(RestoreEntity): def activate(self, **kwargs: Any) -> None: """Activate scene. Try to get entities into requested state.""" - raise NotImplementedError() + raise NotImplementedError async def async_activate(self, **kwargs: Any) -> None: """Activate scene. Try to get entities into requested state.""" diff --git a/homeassistant/components/screenlogic/entity.py b/homeassistant/components/screenlogic/entity.py index df7fe6fc265..0f7530b7289 100644 --- a/homeassistant/components/screenlogic/entity.py +++ b/homeassistant/components/screenlogic/entity.py @@ -159,7 +159,7 @@ class ScreenLogicSwitchingEntity(ScreenLogicEntity): await self._async_set_state(ON_OFF.OFF) async def _async_set_state(self, state: ON_OFF) -> None: - raise NotImplementedError() + raise NotImplementedError class ScreenLogicCircuitEntity(ScreenLogicSwitchingEntity, ScreenLogicPushEntity): diff --git a/homeassistant/components/screenlogic/number.py b/homeassistant/components/screenlogic/number.py index 71d4e045da6..76640339040 100644 --- a/homeassistant/components/screenlogic/number.py +++ b/homeassistant/components/screenlogic/number.py @@ -112,7 +112,7 @@ class ScreenLogicNumber(ScreenLogicEntity, NumberEntity): async def async_set_native_value(self, value: float) -> None: """Update the current value.""" - raise NotImplementedError() + raise NotImplementedError class ScreenLogicSCGNumber(ScreenLogicNumber): diff --git a/homeassistant/components/select/__init__.py b/homeassistant/components/select/__init__.py index 00963f4d069..1594b9e2195 100644 --- a/homeassistant/components/select/__init__.py +++ b/homeassistant/components/select/__init__.py @@ -164,7 +164,7 @@ class SelectEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): and self.entity_description.options is not None ): return self.entity_description.options - raise AttributeError() + raise AttributeError @cached_property def current_option(self) -> str | None: @@ -197,7 +197,7 @@ class SelectEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def select_option(self, option: str) -> None: """Change the selected option.""" - raise NotImplementedError() + raise NotImplementedError async def async_select_option(self, option: str) -> None: """Change the selected option.""" diff --git a/homeassistant/components/sfr_box/__init__.py b/homeassistant/components/sfr_box/__init__.py index 7e8ea102576..dade1af0e52 100644 --- a/homeassistant/components/sfr_box/__init__.py +++ b/homeassistant/components/sfr_box/__init__.py @@ -29,9 +29,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: try: await box.authenticate(username=username, password=password) except SFRBoxAuthenticationError as err: - raise ConfigEntryAuthFailed() from err + raise ConfigEntryAuthFailed from err except SFRBoxError as err: - raise ConfigEntryNotReady() from err + raise ConfigEntryNotReady from err platforms = PLATFORMS_WITH_AUTH data = DomainData( diff --git a/homeassistant/components/sfr_box/coordinator.py b/homeassistant/components/sfr_box/coordinator.py index 29ab1d7a2c6..08698edd74a 100644 --- a/homeassistant/components/sfr_box/coordinator.py +++ b/homeassistant/components/sfr_box/coordinator.py @@ -37,4 +37,4 @@ class SFRDataUpdateCoordinator(DataUpdateCoordinator[_T]): try: return await self._method(self.box) except SFRBoxError as err: - raise UpdateFailed() from err + raise UpdateFailed from err diff --git a/homeassistant/components/sharkiq/vacuum.py b/homeassistant/components/sharkiq/vacuum.py index f24a21b7f8e..658d446b9cb 100644 --- a/homeassistant/components/sharkiq/vacuum.py +++ b/homeassistant/components/sharkiq/vacuum.py @@ -99,7 +99,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum def clean_spot(self, **kwargs: Any) -> None: """Clean a spot. Not yet implemented.""" - raise NotImplementedError() + raise NotImplementedError def send_command( self, @@ -108,7 +108,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum **kwargs: Any, ) -> None: """Send a command to the vacuum. Not yet implemented.""" - raise NotImplementedError() + raise NotImplementedError @property def is_online(self) -> bool: diff --git a/homeassistant/components/sisyphus/light.py b/homeassistant/components/sisyphus/light.py index aad18461b6e..eff0fb378a3 100644 --- a/homeassistant/components/sisyphus/light.py +++ b/homeassistant/components/sisyphus/light.py @@ -33,7 +33,7 @@ async def async_setup_platform( table_holder = hass.data[DATA_SISYPHUS][host] table = await table_holder.get_table() except aiohttp.ClientError as err: - raise PlatformNotReady() from err + raise PlatformNotReady from err add_entities([SisyphusLight(table_holder.name, table)], update_before_add=True) diff --git a/homeassistant/components/sisyphus/media_player.py b/homeassistant/components/sisyphus/media_player.py index 8fb1aa50223..3884a83928a 100644 --- a/homeassistant/components/sisyphus/media_player.py +++ b/homeassistant/components/sisyphus/media_player.py @@ -35,7 +35,7 @@ async def async_setup_platform( table_holder = hass.data[DATA_SISYPHUS][host] table = await table_holder.get_table() except aiohttp.ClientError as err: - raise PlatformNotReady() from err + raise PlatformNotReady from err add_entities([SisyphusPlayer(table_holder.name, host, table)], True) diff --git a/homeassistant/components/sonos/household_coordinator.py b/homeassistant/components/sonos/household_coordinator.py index 9fc2703e48d..8fcecdf4d5e 100644 --- a/homeassistant/components/sonos/household_coordinator.py +++ b/homeassistant/components/sonos/household_coordinator.py @@ -75,8 +75,8 @@ class SonosHouseholdCoordinator: self, soco: SoCo, update_id: int | None = None ) -> None: """Update the cache and update entities.""" - raise NotImplementedError() + raise NotImplementedError def update_cache(self, soco: SoCo, update_id: int | None = None) -> bool: """Update the cache of the household-level feature and return if cache has changed.""" - raise NotImplementedError() + raise NotImplementedError diff --git a/homeassistant/components/stream/core.py b/homeassistant/components/stream/core.py index 4ff5f79ebd8..68c08a4f072 100644 --- a/homeassistant/components/stream/core.py +++ b/homeassistant/components/stream/core.py @@ -389,7 +389,7 @@ class StreamView(HomeAssistantView): ) if not stream: - raise web.HTTPNotFound() + raise web.HTTPNotFound # Start worker if not already started await stream.start() @@ -400,7 +400,7 @@ class StreamView(HomeAssistantView): self, request: web.Request, stream: Stream, sequence: str, part_num: str ) -> web.StreamResponse: """Handle the stream request.""" - raise NotImplementedError() + raise NotImplementedError TRANSFORM_IMAGE_FUNCTION = ( diff --git a/homeassistant/components/stt/__init__.py b/homeassistant/components/stt/__init__.py index 811913e1494..c3d39d4337e 100644 --- a/homeassistant/components/stt/__init__.py +++ b/homeassistant/components/stt/__init__.py @@ -257,7 +257,7 @@ class SpeechToTextView(HomeAssistantView): not (provider_entity := async_get_speech_to_text_entity(hass, provider)) and provider not in self.providers ): - raise HTTPNotFound() + raise HTTPNotFound # Get metadata try: @@ -270,7 +270,7 @@ class SpeechToTextView(HomeAssistantView): # Check format if not stt_provider.check_metadata(metadata): - raise HTTPUnsupportedMediaType() + raise HTTPUnsupportedMediaType # Process audio stream result = await stt_provider.async_process_audio_stream( @@ -279,7 +279,7 @@ class SpeechToTextView(HomeAssistantView): else: # Check format if not provider_entity.check_metadata(metadata): - raise HTTPUnsupportedMediaType() + raise HTTPUnsupportedMediaType # Process audio stream result = await provider_entity.internal_async_process_audio_stream( @@ -296,7 +296,7 @@ class SpeechToTextView(HomeAssistantView): not (provider_entity := async_get_speech_to_text_entity(hass, provider)) and provider not in self.providers ): - raise HTTPNotFound() + raise HTTPNotFound if not provider_entity: stt_provider = self._get_provider(hass, provider) diff --git a/homeassistant/components/synology_dsm/media_source.py b/homeassistant/components/synology_dsm/media_source.py index 6f53116a39c..9a393813c3e 100644 --- a/homeassistant/components/synology_dsm/media_source.py +++ b/homeassistant/components/synology_dsm/media_source.py @@ -212,18 +212,18 @@ class SynologyDsmMediaView(http.HomeAssistantView): ) -> web.Response: """Start a GET request.""" if not self.hass.data.get(DOMAIN): - raise web.HTTPNotFound() + raise web.HTTPNotFound # location: {cache_key}/{filename} cache_key, file_name = location.split("/") image_id = cache_key.split("_")[0] mime_type, _ = mimetypes.guess_type(file_name) if not isinstance(mime_type, str): - raise web.HTTPNotFound() + raise web.HTTPNotFound diskstation: SynologyDSMData = self.hass.data[DOMAIN][source_dir_id] item = SynoPhotosItem(image_id, "", "", "", cache_key, "") try: image = await diskstation.api.photos.download_item(item) except SynologyDSMException as exc: - raise web.HTTPNotFound() from exc + raise web.HTTPNotFound from exc return web.Response(body=image, content_type=mime_type) diff --git a/homeassistant/components/text/__init__.py b/homeassistant/components/text/__init__.py index c69cf8fcbdd..cf29910cc34 100644 --- a/homeassistant/components/text/__init__.py +++ b/homeassistant/components/text/__init__.py @@ -237,7 +237,7 @@ class TextEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_value(self, value: str) -> None: """Change the value.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_value(self, value: str) -> None: """Change the value.""" diff --git a/homeassistant/components/tibber/sensor.py b/homeassistant/components/tibber/sensor.py index a57c5d3e8dd..da2fd881a54 100644 --- a/homeassistant/components/tibber/sensor.py +++ b/homeassistant/components/tibber/sensor.py @@ -286,10 +286,10 @@ async def async_setup_entry( await home.update_info() except TimeoutError as err: _LOGGER.error("Timeout connecting to Tibber home: %s ", err) - raise PlatformNotReady() from err + raise PlatformNotReady from err except aiohttp.ClientError as err: _LOGGER.error("Error connecting to Tibber home: %s ", err) - raise PlatformNotReady() from err + raise PlatformNotReady from err if home.has_active_subscription: entities.append(TibberSensorElPrice(home)) diff --git a/homeassistant/components/time/__init__.py b/homeassistant/components/time/__init__.py index 867aada2e8f..2e87aaac28d 100644 --- a/homeassistant/components/time/__init__.py +++ b/homeassistant/components/time/__init__.py @@ -110,7 +110,7 @@ class TimeEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_value(self, value: time) -> None: """Change the time.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_value(self, value: time) -> None: """Change the time.""" diff --git a/homeassistant/components/todo/__init__.py b/homeassistant/components/todo/__init__.py index afcb8e28f74..0b8dd756289 100644 --- a/homeassistant/components/todo/__init__.py +++ b/homeassistant/components/todo/__init__.py @@ -261,15 +261,15 @@ class TodoListEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): async def async_create_todo_item(self, item: TodoItem) -> None: """Add an item to the To-do list.""" - raise NotImplementedError() + raise NotImplementedError async def async_update_todo_item(self, item: TodoItem) -> None: """Update an item in the To-do list.""" - raise NotImplementedError() + raise NotImplementedError async def async_delete_todo_items(self, uids: list[str]) -> None: """Delete an item in the To-do list.""" - raise NotImplementedError() + raise NotImplementedError async def async_move_todo_item( self, uid: str, previous_uid: str | None = None @@ -280,7 +280,7 @@ class TodoListEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): in the list after the specified by `previous_uid` or `None` for the first position in the To-do list. """ - raise NotImplementedError() + raise NotImplementedError @final @callback diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index ca1ed0d6027..f445309fffe 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -457,7 +457,7 @@ class TextToSpeechEntity(RestoreEntity): self, message: str, language: str, options: dict[str, Any] ) -> TtsAudioType: """Load tts audio file from the engine.""" - raise NotImplementedError() + raise NotImplementedError async def async_get_tts_audio( self, message: str, language: str, options: dict[str, Any] diff --git a/homeassistant/components/tts/legacy.py b/homeassistant/components/tts/legacy.py index 9d70139ff74..0214dcd13e9 100644 --- a/homeassistant/components/tts/legacy.py +++ b/homeassistant/components/tts/legacy.py @@ -231,7 +231,7 @@ class Provider: self, message: str, language: str, options: dict[str, Any] ) -> TtsAudioType: """Load tts audio file from provider.""" - raise NotImplementedError() + raise NotImplementedError async def async_get_tts_audio( self, message: str, language: str, options: dict[str, Any] diff --git a/homeassistant/components/unifi/entity.py b/homeassistant/components/unifi/entity.py index 649c9fc0c13..e162b32ba42 100644 --- a/homeassistant/components/unifi/entity.py +++ b/homeassistant/components/unifi/entity.py @@ -270,4 +270,4 @@ class UnifiEntity(Entity, Generic[HandlerT, ApiItemT]): Perform additional action updating platform entity child class state. """ - raise NotImplementedError() + raise NotImplementedError diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index 54b5d337605..90036e5d47c 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -658,7 +658,7 @@ class UniversalMediaPlayer(MediaPlayerEntity): component: EntityComponent[MediaPlayerEntity] = self.hass.data[DOMAIN] if entity_id and (entity := component.get_entity(entity_id)): return await entity.async_browse_media(media_content_type, media_content_id) - raise NotImplementedError() + raise NotImplementedError async def async_update(self) -> None: """Update state in HA.""" diff --git a/homeassistant/components/update/__init__.py b/homeassistant/components/update/__init__.py index d52216974aa..f274da6f412 100644 --- a/homeassistant/components/update/__init__.py +++ b/homeassistant/components/update/__init__.py @@ -374,7 +374,7 @@ class UpdateEntity( The backup parameter indicates a backup should be taken before installing the update. """ - raise NotImplementedError() + raise NotImplementedError async def async_release_notes(self) -> str | None: """Return full release notes. @@ -390,7 +390,7 @@ class UpdateEntity( This is suitable for a long changelog that does not fit in the release_summary property. The returned string can contain markdown. """ - raise NotImplementedError() + raise NotImplementedError @property @final diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py index 61a31add655..bdf690ed63f 100644 --- a/homeassistant/components/vacuum/__init__.py +++ b/homeassistant/components/vacuum/__init__.py @@ -293,7 +293,7 @@ class StateVacuumEntity( def stop(self, **kwargs: Any) -> None: """Stop the vacuum cleaner.""" - raise NotImplementedError() + raise NotImplementedError async def async_stop(self, **kwargs: Any) -> None: """Stop the vacuum cleaner. @@ -304,7 +304,7 @@ class StateVacuumEntity( def return_to_base(self, **kwargs: Any) -> None: """Set the vacuum cleaner to return to the dock.""" - raise NotImplementedError() + raise NotImplementedError async def async_return_to_base(self, **kwargs: Any) -> None: """Set the vacuum cleaner to return to the dock. @@ -315,7 +315,7 @@ class StateVacuumEntity( def clean_spot(self, **kwargs: Any) -> None: """Perform a spot clean-up.""" - raise NotImplementedError() + raise NotImplementedError async def async_clean_spot(self, **kwargs: Any) -> None: """Perform a spot clean-up. @@ -326,7 +326,7 @@ class StateVacuumEntity( def locate(self, **kwargs: Any) -> None: """Locate the vacuum cleaner.""" - raise NotImplementedError() + raise NotImplementedError async def async_locate(self, **kwargs: Any) -> None: """Locate the vacuum cleaner. @@ -337,7 +337,7 @@ class StateVacuumEntity( def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None: """Set fan speed.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None: """Set fan speed. @@ -355,7 +355,7 @@ class StateVacuumEntity( **kwargs: Any, ) -> None: """Send a command to a vacuum cleaner.""" - raise NotImplementedError() + raise NotImplementedError async def async_send_command( self, @@ -373,7 +373,7 @@ class StateVacuumEntity( def start(self) -> None: """Start or resume the cleaning task.""" - raise NotImplementedError() + raise NotImplementedError async def async_start(self) -> None: """Start or resume the cleaning task. @@ -384,7 +384,7 @@ class StateVacuumEntity( def pause(self) -> None: """Pause the cleaning task.""" - raise NotImplementedError() + raise NotImplementedError async def async_pause(self) -> None: """Pause the cleaning task. diff --git a/homeassistant/components/valve/__init__.py b/homeassistant/components/valve/__init__.py index f2d2fcf4760..0363ef55832 100644 --- a/homeassistant/components/valve/__init__.py +++ b/homeassistant/components/valve/__init__.py @@ -215,7 +215,7 @@ class ValveEntity(Entity): def open_valve(self) -> None: """Open the valve.""" - raise NotImplementedError() + raise NotImplementedError async def async_open_valve(self) -> None: """Open the valve.""" @@ -230,7 +230,7 @@ class ValveEntity(Entity): def close_valve(self) -> None: """Close valve.""" - raise NotImplementedError() + raise NotImplementedError async def async_close_valve(self) -> None: """Close valve.""" @@ -257,7 +257,7 @@ class ValveEntity(Entity): def set_valve_position(self, position: int) -> None: """Move the valve to a specific position.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_valve_position(self, position: int) -> None: """Move the valve to a specific position.""" @@ -265,7 +265,7 @@ class ValveEntity(Entity): def stop_valve(self) -> None: """Stop the valve.""" - raise NotImplementedError() + raise NotImplementedError async def async_stop_valve(self) -> None: """Stop the valve.""" diff --git a/homeassistant/components/vlc_telnet/__init__.py b/homeassistant/components/vlc_telnet/__init__.py index 659a5d29d1f..67c45c5dbdf 100644 --- a/homeassistant/components/vlc_telnet/__init__.py +++ b/homeassistant/components/vlc_telnet/__init__.py @@ -36,7 +36,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await vlc.login() except AuthError as err: await disconnect_vlc(vlc) - raise ConfigEntryAuthFailed() from err + raise ConfigEntryAuthFailed from err domain_data = hass.data.setdefault(DOMAIN, {}) domain_data[entry.entry_id] = {DATA_VLC: vlc, DATA_AVAILABLE: available} diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index 5bd414ee53e..370bb5c293c 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -331,7 +331,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" @@ -341,7 +341,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_on(self, **kwargs: Any) -> None: """Turn the water heater on.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_on(self, **kwargs: Any) -> None: """Turn the water heater on.""" @@ -349,7 +349,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_off(self, **kwargs: Any) -> None: """Turn the water heater off.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_off(self, **kwargs: Any) -> None: """Turn the water heater off.""" @@ -357,7 +357,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def set_operation_mode(self, operation_mode: str) -> None: """Set new target operation mode.""" - raise NotImplementedError() + raise NotImplementedError async def async_set_operation_mode(self, operation_mode: str) -> None: """Set new target operation mode.""" @@ -395,7 +395,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_away_mode_on(self) -> None: """Turn away mode on.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_away_mode_on(self) -> None: """Turn away mode on.""" @@ -403,7 +403,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def turn_away_mode_off(self) -> None: """Turn away mode off.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_away_mode_off(self) -> None: """Turn away mode off.""" diff --git a/homeassistant/components/websocket_api/decorators.py b/homeassistant/components/websocket_api/decorators.py index 4de83530642..51643752a0f 100644 --- a/homeassistant/components/websocket_api/decorators.py +++ b/homeassistant/components/websocket_api/decorators.py @@ -63,7 +63,7 @@ def require_admin(func: const.WebSocketCommandHandler) -> const.WebSocketCommand user = connection.user if user is None or not user.is_admin: - raise Unauthorized() + raise Unauthorized func(hass, connection, msg) diff --git a/homeassistant/components/xiaomi_aqara/__init__.py b/homeassistant/components/xiaomi_aqara/__init__.py index f39daa9b594..ee7948a237e 100644 --- a/homeassistant/components/xiaomi_aqara/__init__.py +++ b/homeassistant/components/xiaomi_aqara/__init__.py @@ -388,7 +388,7 @@ class XiaomiDevice(Entity): def parse_data(self, data, raw_data): """Parse data sent by gateway.""" - raise NotImplementedError() + raise NotImplementedError def _add_gateway_to_schema(hass, schema): diff --git a/homeassistant/components/xiaomi_miio/__init__.py b/homeassistant/components/xiaomi_miio/__init__.py index f21698f33c3..5384bd93a7e 100644 --- a/homeassistant/components/xiaomi_miio/__init__.py +++ b/homeassistant/components/xiaomi_miio/__init__.py @@ -410,9 +410,9 @@ async def async_setup_gateway_entry(hass: HomeAssistant, entry: ConfigEntry) -> try: await gateway.async_connect_gateway(host, token) except AuthException as error: - raise ConfigEntryAuthFailed() from error + raise ConfigEntryAuthFailed from error except SetupException as error: - raise ConfigEntryNotReady() from error + raise ConfigEntryNotReady from error gateway_info = gateway.gateway_info device_registry = dr.async_get(hass) diff --git a/homeassistant/components/yamaha_musiccast/__init__.py b/homeassistant/components/yamaha_musiccast/__init__.py index 9c7e6d07b82..667b411e6c4 100644 --- a/homeassistant/components/yamaha_musiccast/__init__.py +++ b/homeassistant/components/yamaha_musiccast/__init__.py @@ -120,7 +120,7 @@ class MusicCastDataUpdateCoordinator(DataUpdateCoordinator[MusicCastData]): # p try: await self.musiccast.fetch() except MusicCastConnectionException as exception: - raise UpdateFailed() from exception + raise UpdateFailed from exception return self.musiccast.data diff --git a/homeassistant/components/zha/repairs/wrong_silabs_firmware.py b/homeassistant/components/zha/repairs/wrong_silabs_firmware.py index 3326f5685df..5b1f85e1a29 100644 --- a/homeassistant/components/zha/repairs/wrong_silabs_firmware.py +++ b/homeassistant/components/zha/repairs/wrong_silabs_firmware.py @@ -101,7 +101,7 @@ async def warn_on_wrong_silabs_firmware(hass: HomeAssistant, device: str) -> boo if app_type == ApplicationType.EZSP: # If connecting fails but we somehow probe EZSP (e.g. stuck in bootloader), # reconnect, it should work - raise AlreadyRunningEZSP() + raise AlreadyRunningEZSP hardware_type = _detect_radio_hardware(hass, device) ir.async_create_issue( diff --git a/homeassistant/components/zwave_me/__init__.py b/homeassistant/components/zwave_me/__init__.py index dae065b5829..66f02246792 100644 --- a/homeassistant/components/zwave_me/__init__.py +++ b/homeassistant/components/zwave_me/__init__.py @@ -28,7 +28,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: registry = dr.async_get(hass) controller.remove_stale_devices(registry) return True - raise ConfigEntryNotReady() + raise ConfigEntryNotReady async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/exceptions.py b/homeassistant/exceptions.py index b9e1ca2e2bd..63b95b570e7 100644 --- a/homeassistant/exceptions.py +++ b/homeassistant/exceptions.py @@ -139,7 +139,7 @@ class ConditionError(HomeAssistantError): def output(self, indent: int) -> Generator[str, None, None]: """Yield an indented representation.""" - raise NotImplementedError() + raise NotImplementedError def __str__(self) -> str: """Return string representation.""" diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 17784d12aa2..15437b00183 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -191,11 +191,11 @@ async def async_aiohttp_proxy_web( except TimeoutError as err: # Timeout trying to start the web request - raise HTTPGatewayTimeout() from err + raise HTTPGatewayTimeout from err except aiohttp.ClientError as err: # Something went wrong with the connection - raise HTTPBadGateway() from err + raise HTTPBadGateway from err try: return await async_aiohttp_proxy_stream( diff --git a/homeassistant/helpers/device_registry.py b/homeassistant/helpers/device_registry.py index 13aeab9ebf2..ba4c393a2d9 100644 --- a/homeassistant/helpers/device_registry.py +++ b/homeassistant/helpers/device_registry.py @@ -755,7 +755,7 @@ class DeviceRegistry(BaseRegistry): config_entries = old.config_entries if merge_identifiers is not UNDEFINED and new_identifiers is not UNDEFINED: - raise HomeAssistantError() + raise HomeAssistantError if isinstance(disabled_by, str) and not isinstance( disabled_by, DeviceEntryDisabler diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 5f31c049d13..a2adee96500 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -1648,7 +1648,7 @@ class ToggleEntity( def turn_on(self, **kwargs: Any) -> None: """Turn the entity on.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_on(self, **kwargs: Any) -> None: """Turn the entity on.""" @@ -1656,7 +1656,7 @@ class ToggleEntity( def turn_off(self, **kwargs: Any) -> None: """Turn the entity off.""" - raise NotImplementedError() + raise NotImplementedError async def async_turn_off(self, **kwargs: Any) -> None: """Turn the entity off.""" diff --git a/homeassistant/helpers/http.py b/homeassistant/helpers/http.py index 018558a8761..a464056fc07 100644 --- a/homeassistant/helpers/http.py +++ b/homeassistant/helpers/http.py @@ -58,7 +58,7 @@ def request_handler_factory( authenticated = request.get(KEY_AUTHENTICATED, False) if view.requires_auth and not authenticated: - raise HTTPUnauthorized() + raise HTTPUnauthorized if _LOGGER.isEnabledFor(logging.DEBUG): _LOGGER.debug( @@ -74,11 +74,11 @@ def request_handler_factory( else: result = handler(request, **request.match_info) except vol.Invalid as err: - raise HTTPBadRequest() from err + raise HTTPBadRequest from err except exceptions.ServiceNotFound as err: - raise HTTPInternalServerError() from err + raise HTTPInternalServerError from err except exceptions.Unauthorized as err: - raise HTTPUnauthorized() from err + raise HTTPUnauthorized from err if isinstance(result, web.StreamResponse): # The method handler returned a ready-made Response, how nice of it diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index 71f9fd90b92..63214cb135b 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -375,7 +375,7 @@ class IntentHandler: async def async_handle(self, intent_obj: Intent) -> IntentResponse: """Handle the intent.""" - raise NotImplementedError() + raise NotImplementedError def __repr__(self) -> str: """Represent a string of an intent handler.""" @@ -439,7 +439,7 @@ class DynamicServiceIntentHandler(IntentHandler): self, intent_obj: Intent, state: State ) -> tuple[str, str]: """Get the domain and service name to call.""" - raise NotImplementedError() + raise NotImplementedError async def async_handle(self, intent_obj: Intent) -> IntentResponse: """Handle the hass intent.""" diff --git a/homeassistant/util/language.py b/homeassistant/util/language.py index 38fa22730a6..8644f8014b6 100644 --- a/homeassistant/util/language.py +++ b/homeassistant/util/language.py @@ -139,7 +139,7 @@ class Dialect: region_idx = pref_regions.index(dialect.region) else: # Can't happen, but mypy is not smart enough - raise ValueError() + raise ValueError # More preferred regions are at the front. # Add 1 to boost above a weak match where no regions are set. diff --git a/pyproject.toml b/pyproject.toml index 4703c6178e4..218127ccff0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -609,6 +609,7 @@ select = [ "PGH004", # Use specific rule codes when using noqa "PIE", # flake8-pie "PL", # pylint + "RSE", # flake8-raise "RUF005", # Consider iterable unpacking instead of concatenation "RUF006", # Store a reference to the return value of asyncio.create_task # "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up diff --git a/tests/components/anova/conftest.py b/tests/components/anova/conftest.py index 88b5ae1fd41..3e904bb1415 100644 --- a/tests/components/anova/conftest.py +++ b/tests/components/anova/conftest.py @@ -51,7 +51,7 @@ async def anova_api_no_devices( api_mock.jwt = "my_test_jwt" async def get_devices_side_effect(): - raise NoDevicesFound() + raise NoDevicesFound api_mock.authenticate.side_effect = authenticate_side_effect api_mock.get_devices.side_effect = get_devices_side_effect @@ -73,7 +73,7 @@ async def anova_api_wrong_login( api_mock = AsyncMock() async def authenticate_side_effect(): - raise InvalidLogin() + raise InvalidLogin api_mock.authenticate.side_effect = authenticate_side_effect diff --git a/tests/components/assist_pipeline/test_websocket.py b/tests/components/assist_pipeline/test_websocket.py index 91f07fc08c0..612bf760bd0 100644 --- a/tests/components/assist_pipeline/test_websocket.py +++ b/tests/components/assist_pipeline/test_websocket.py @@ -2392,7 +2392,7 @@ async def test_device_capture_queue_full( def put_nowait(self, item): if item is not None: - raise asyncio.QueueFull() + raise asyncio.QueueFull super().put_nowait(item) diff --git a/tests/components/conversation/test_init.py b/tests/components/conversation/test_init.py index 3b9e8e39a82..1e445431c24 100644 --- a/tests/components/conversation/test_init.py +++ b/tests/components/conversation/test_init.py @@ -601,7 +601,7 @@ async def test_http_api_handle_failure( # Raise an error during intent handling def async_handle_error(*args, **kwargs): - raise intent.IntentHandleError() + raise intent.IntentHandleError with patch("homeassistant.helpers.intent.async_handle", new=async_handle_error): resp = await client.post( @@ -629,7 +629,7 @@ async def test_http_api_unexpected_failure( # Raise an "unexpected" error during intent handling def async_handle_error(*args, **kwargs): - raise intent.IntentUnexpectedError() + raise intent.IntentUnexpectedError with patch("homeassistant.helpers.intent.async_handle", new=async_handle_error): resp = await client.post( diff --git a/tests/components/coolmaster/conftest.py b/tests/components/coolmaster/conftest.py index e2c4b050514..7ddf1fd5942 100644 --- a/tests/components/coolmaster/conftest.py +++ b/tests/components/coolmaster/conftest.py @@ -72,7 +72,7 @@ class CoolMasterNetUnitMock: async def set_swing(self, value: str | None) -> CoolMasterNetUnitMock: """Set the swing mode.""" if value == "": - raise ValueError() + raise ValueError self._attributes["swing"] = value return CoolMasterNetUnitMock(self.unit_id, self._attributes) diff --git a/tests/components/lifx/test_config_flow.py b/tests/components/lifx/test_config_flow.py index 8381a07cb7f..78e852e2cab 100644 --- a/tests/components/lifx/test_config_flow.py +++ b/tests/components/lifx/test_config_flow.py @@ -285,7 +285,7 @@ async def test_manual_dns_error(hass: HomeAssistant) -> None: async def async_setup(self): """Mock setup.""" - raise socket.gaierror() + raise socket.gaierror def async_stop(self): """Mock teardown.""" diff --git a/tests/components/lifx/test_init.py b/tests/components/lifx/test_init.py index c79e4bb3856..01003e6e7f1 100644 --- a/tests/components/lifx/test_init.py +++ b/tests/components/lifx/test_init.py @@ -139,7 +139,7 @@ async def test_dns_error_at_startup(hass: HomeAssistant) -> None: async def async_setup(self): """Mock setup.""" - raise socket.gaierror() + raise socket.gaierror def async_stop(self): """Mock teardown.""" diff --git a/tests/components/netatmo/test_camera.py b/tests/components/netatmo/test_camera.py index 12641438a3a..771bd62de1c 100644 --- a/tests/components/netatmo/test_camera.py +++ b/tests/components/netatmo/test_camera.py @@ -541,7 +541,7 @@ async def test_camera_image_raises_exception( endpoint = kwargs["endpoint"].split("/")[-1] if "snapshot_720.jpg" in endpoint: - raise pyatmo.ApiError() + raise pyatmo.ApiError return await fake_post_request(*args, **kwargs) diff --git a/tests/components/network/test_init.py b/tests/components/network/test_init.py index 2e0d2eb585b..7aea83a84e2 100644 --- a/tests/components/network/test_init.py +++ b/tests/components/network/test_init.py @@ -40,7 +40,7 @@ def _mock_cond_socket(sockname): """Return addr if it matches the mock sockname.""" if self._addr == sockname: return [sockname] - raise AttributeError() + raise AttributeError return CondMockSock() diff --git a/tests/components/nibe_heatpump/__init__.py b/tests/components/nibe_heatpump/__init__.py index 3c3db391ba8..d7c1fa5ebad 100644 --- a/tests/components/nibe_heatpump/__init__.py +++ b/tests/components/nibe_heatpump/__init__.py @@ -41,7 +41,7 @@ class MockConnection(Connection): async def read_coil(self, coil: Coil, timeout: float = 0) -> CoilData: """Read of coils.""" if (data := self.coils.get(coil.address, None)) is None: - raise ReadException() + raise ReadException return CoilData(coil, data) async def write_coil(self, coil_data: CoilData, timeout: float = 10.0) -> None: diff --git a/tests/components/nibe_heatpump/conftest.py b/tests/components/nibe_heatpump/conftest.py index 2d88e1b0fd2..010a79980c4 100644 --- a/tests/components/nibe_heatpump/conftest.py +++ b/tests/components/nibe_heatpump/conftest.py @@ -68,7 +68,7 @@ async def fixture_coils(mock_connection: MockConnection): def get_coil_by_address(self, address): coils_data = get_coil_by_address_original(self, address) if coils_data.address not in mock_connection.coils: - raise CoilNotFoundException() + raise CoilNotFoundException return coils_data with patch.object(HeatPump, "get_coils", new=get_coils), patch.object( diff --git a/tests/components/nsw_fuel_station/test_sensor.py b/tests/components/nsw_fuel_station/test_sensor.py index 3e3a5aa9001..898d5757870 100644 --- a/tests/components/nsw_fuel_station/test_sensor.py +++ b/tests/components/nsw_fuel_station/test_sensor.py @@ -90,7 +90,7 @@ async def test_setup(get_fuel_prices, hass: HomeAssistant) -> None: def raise_fuel_check_error(): """Raise fuel check error for testing error cases.""" - raise FuelCheckError() + raise FuelCheckError @patch( diff --git a/tests/components/nx584/test_binary_sensor.py b/tests/components/nx584/test_binary_sensor.py index 5b8adada1a2..5c57feb471b 100644 --- a/tests/components/nx584/test_binary_sensor.py +++ b/tests/components/nx584/test_binary_sensor.py @@ -249,8 +249,8 @@ def test_nx584_watcher_run_retries_failures(mock_sleep) -> None: """Fake runner.""" if empty_me: empty_me.pop() - raise requests.exceptions.ConnectionError() - raise StopMe() + raise requests.exceptions.ConnectionError + raise StopMe watcher = nx584.NX584Watcher(None, {}) with mock.patch.object(watcher, "_run") as mock_inner: diff --git a/tests/components/owntracks/test_device_tracker.py b/tests/components/owntracks/test_device_tracker.py index 4462722bb53..a36d03e973c 100644 --- a/tests/components/owntracks/test_device_tracker.py +++ b/tests/components/owntracks/test_device_tracker.py @@ -1383,7 +1383,7 @@ def mock_cipher(): (mkey, plaintext) = pickle.loads(base64.b64decode(ciphertext)) if key != mkey: - raise ValueError() + raise ValueError return plaintext return len(TEST_SECRET_KEY), mock_decrypt diff --git a/tests/components/recorder/test_util.py b/tests/components/recorder/test_util.py index 5f8225e8fe6..c199d980f69 100644 --- a/tests/components/recorder/test_util.py +++ b/tests/components/recorder/test_util.py @@ -60,7 +60,7 @@ def test_recorder_bad_execute(hass_recorder: Callable[..., HomeAssistant]) -> No def to_native(validate_entity_id=True): """Raise exception.""" - raise SQLAlchemyError() + raise SQLAlchemyError mck1 = MagicMock() mck1.to_native = to_native diff --git a/tests/components/sonos/test_init.py b/tests/components/sonos/test_init.py index 17e04e64749..964984e777a 100644 --- a/tests/components/sonos/test_init.py +++ b/tests/components/sonos/test_init.py @@ -158,7 +158,7 @@ async def test_async_poll_manual_hosts_warnings( class _MockSoCoOsError(MockSoCo): @property def visible_zones(self): - raise OSError() + raise OSError class _MockSoCoVisibleZones(MockSoCo): diff --git a/tests/components/stream/test_ll_hls.py b/tests/components/stream/test_ll_hls.py index 39d66f0141d..4cf3909dd0d 100644 --- a/tests/components/stream/test_ll_hls.py +++ b/tests/components/stream/test_ll_hls.py @@ -397,7 +397,7 @@ async def test_ll_hls_playlist_bad_msn_part( """Test some playlist requests with invalid _HLS_msn/_HLS_part.""" async def _handler_bad_request(request): - raise web.HTTPBadRequest() + raise web.HTTPBadRequest await async_setup_component( hass, diff --git a/tests/components/twinkly/__init__.py b/tests/components/twinkly/__init__.py index c77dd0ac963..f322004962a 100644 --- a/tests/components/twinkly/__init__.py +++ b/tests/components/twinkly/__init__.py @@ -42,38 +42,38 @@ class ClientMock: async def get_details(self): """Get the mocked device info.""" if self.is_offline: - raise ClientConnectionError() + raise ClientConnectionError return self.device_info async def is_on(self) -> bool: """Get the mocked on/off state.""" if self.is_offline: - raise ClientConnectionError() + raise ClientConnectionError return self.state async def turn_on(self) -> None: """Set the mocked on state.""" if self.is_offline: - raise ClientConnectionError() + raise ClientConnectionError self.state = True self.mode = self.default_mode async def turn_off(self) -> None: """Set the mocked off state.""" if self.is_offline: - raise ClientConnectionError() + raise ClientConnectionError self.state = False async def get_brightness(self) -> int: """Get the mocked brightness.""" if self.is_offline: - raise ClientConnectionError() + raise ClientConnectionError return self.brightness async def set_brightness(self, brightness: int) -> None: """Set the mocked brightness.""" if self.is_offline: - raise ClientConnectionError() + raise ClientConnectionError self.brightness = {"mode": "enabled", "value": brightness} def change_name(self, new_name: str) -> None: diff --git a/tests/components/twitch/__init__.py b/tests/components/twitch/__init__.py index bb4530eacf8..d37c386f0a3 100644 --- a/tests/components/twitch/__init__.py +++ b/tests/components/twitch/__init__.py @@ -198,7 +198,7 @@ class TwitchUnauthorizedMock(TwitchMock): def __await__(self): """Add async capabilities to the mock.""" - raise TwitchAuthorizationException() + raise TwitchAuthorizationException class TwitchMissingScopeMock(TwitchMock): @@ -208,7 +208,7 @@ class TwitchMissingScopeMock(TwitchMock): self, token: str, scope: list[AuthScope], validate: bool = True ) -> None: """Set user authentication.""" - raise MissingScopeException() + raise MissingScopeException class TwitchInvalidTokenMock(TwitchMock): @@ -218,7 +218,7 @@ class TwitchInvalidTokenMock(TwitchMock): self, token: str, scope: list[AuthScope], validate: bool = True ) -> None: """Set user authentication.""" - raise InvalidTokenException() + raise InvalidTokenException class TwitchInvalidUserMock(TwitchMock): @@ -243,4 +243,4 @@ class TwitchAPIExceptionMock(TwitchMock): self, broadcaster_id: str, user_id: str ) -> UserSubscriptionMock: """Check if the user is subscribed.""" - raise TwitchAPIException() + raise TwitchAPIException diff --git a/tests/components/uvc/test_camera.py b/tests/components/uvc/test_camera.py index ccc8b75021f..cbbd27b81df 100644 --- a/tests/components/uvc/test_camera.py +++ b/tests/components/uvc/test_camera.py @@ -472,7 +472,7 @@ async def test_login_tries_both_addrs_and_caches( """Mock get snapshots.""" try: snapshots.pop(0) - raise camera.CameraAuthError() + raise camera.CameraAuthError except IndexError: pass return "test_image" diff --git a/tests/components/websocket_api/test_http.py b/tests/components/websocket_api/test_http.py index 465c4aea749..6c2646f369e 100644 --- a/tests/components/websocket_api/test_http.py +++ b/tests/components/websocket_api/test_http.py @@ -86,7 +86,7 @@ async def test_cleanup_on_cancellation( @callback def _raise(): - raise ValueError() + raise ValueError connection.subscriptions[msg_id] = _raise connection.send_result(msg_id) @@ -104,7 +104,7 @@ async def test_cleanup_on_cancellation( def cancel_in_handler( hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any] ) -> None: - raise asyncio.CancelledError() + raise asyncio.CancelledError async_register_command(hass, cancel_in_handler) diff --git a/tests/components/ws66i/test_media_player.py b/tests/components/ws66i/test_media_player.py index 08ab646ce28..eec6bf191f7 100644 --- a/tests/components/ws66i/test_media_player.py +++ b/tests/components/ws66i/test_media_player.py @@ -86,7 +86,7 @@ class MockWs66i: def open(self): """Open socket. Do nothing.""" if self.fail_open is True: - raise ConnectionError() + raise ConnectionError def close(self): """Close socket. Do nothing.""" diff --git a/tests/helpers/test_config_entry_oauth2_flow.py b/tests/helpers/test_config_entry_oauth2_flow.py index f91cb3d2f35..6ad8af5d698 100644 --- a/tests/helpers/test_config_entry_oauth2_flow.py +++ b/tests/helpers/test_config_entry_oauth2_flow.py @@ -90,7 +90,7 @@ class MockOAuth2Implementation(config_entry_oauth2_flow.AbstractOAuth2Implementa async def _async_refresh_token(self, token: dict) -> dict: """Refresh a token.""" - raise NotImplementedError() + raise NotImplementedError def test_inherit_enforces_domain_set() -> None: diff --git a/tests/test_util/aiohttp.py b/tests/test_util/aiohttp.py index df232e51aee..742b111143f 100644 --- a/tests/test_util/aiohttp.py +++ b/tests/test_util/aiohttp.py @@ -335,7 +335,7 @@ class MockLongPollSideEffect: async def __call__(self, method, url, data): """Fetch the next response from the queue or wait until the queue has items.""" if self.stopping: - raise ClientError() + raise ClientError await self.semaphore.acquire() kwargs = self.response_list.pop(0) return AiohttpClientMockResponse(method=method, url=url, **kwargs) diff --git a/tests/util/test_timeout.py b/tests/util/test_timeout.py index 99430cc0361..02a06632ff6 100644 --- a/tests/util/test_timeout.py +++ b/tests/util/test_timeout.py @@ -315,7 +315,7 @@ async def test_simple_zone_timeout_freeze_without_timeout_exeption() -> None: async with timeout.async_timeout(0.1): with suppress(RuntimeError): async with timeout.async_freeze("test"): - raise RuntimeError() + raise RuntimeError await asyncio.sleep(0.4) @@ -328,6 +328,6 @@ async def test_simple_zone_timeout_zone_with_timeout_exeption() -> None: async with timeout.async_timeout(0.1): with suppress(RuntimeError): async with timeout.async_timeout(0.3, "test"): - raise RuntimeError() + raise RuntimeError await asyncio.sleep(0.3)