Enable Ruff RSE (#113695)

This commit is contained in:
Sid 2024-03-18 00:40:38 +01:00 committed by GitHub
parent 685553d17d
commit 82a60fe8ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
155 changed files with 325 additions and 324 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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."""

View File

@ -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.

View File

@ -413,7 +413,7 @@ class APIDomainServicesView(HomeAssistantView):
)
)
except (vol.Invalid, ServiceNotFound) as ex:
raise HTTPBadRequest() from ex
raise HTTPBadRequest from ex
finally:
cancel_listen()

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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.

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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."""

View File

@ -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):

View File

@ -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(

View File

@ -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."""

View File

@ -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()

View File

@ -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."""

View File

@ -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:

View File

@ -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."""

View File

@ -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."""

View File

@ -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."""

View File

@ -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)

View File

@ -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"

View File

@ -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

View File

@ -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(

View File

@ -81,7 +81,7 @@ def setup_platform(
api = EpsonPrinterAPI(host)
if not api.available:
raise PlatformNotReady()
raise PlatformNotReady
sensors = [
EpsonPrinterCartridge(api, description)

View File

@ -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(

View File

@ -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."""

View File

@ -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.

View File

@ -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))

View File

@ -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."""

View File

@ -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

View File

@ -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

View File

@ -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."""

View File

@ -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."""

View File

@ -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,

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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])

View File

@ -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]

View File

@ -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."""

View File

@ -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

View File

@ -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",

View File

@ -588,7 +588,7 @@ class HomeAccessory(Accessory): # type: ignore[misc]
Overridden by accessory types.
"""
raise NotImplementedError()
raise NotImplementedError
@ha_callback
def async_call_service(

View File

@ -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)

View File

@ -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:

View File

@ -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."""

View File

@ -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

View File

@ -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)

View File

@ -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."""

View File

@ -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}"

View File

@ -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):

View File

@ -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:

View File

@ -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()

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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."""

View File

@ -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."""

View File

@ -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

View File

@ -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

View File

@ -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."""

View File

@ -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):

View File

@ -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":

View File

@ -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."""

View File

@ -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}"}

View File

@ -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)

View File

@ -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(

View File

@ -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}

View File

@ -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()

View File

@ -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)

View File

@ -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

View File

@ -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.

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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."""

View File

@ -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

View File

@ -377,7 +377,7 @@ class RflinkDevice(Entity):
def _handle_event(self, event):
"""Platform specific event handler."""
raise NotImplementedError()
raise NotImplementedError
@property
def name(self):

View File

@ -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

View File

@ -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."""

View File

@ -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):

View File

@ -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):

View File

@ -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."""

View File

@ -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(

View File

@ -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

View File

@ -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:

View File

@ -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)

View File

@ -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)

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