From 873d2d4bb0bd7405561969094e0f6b865c8d7774 Mon Sep 17 00:00:00 2001 From: Nathan Spencer Date: Mon, 24 Nov 2025 05:17:26 +0000 Subject: [PATCH] Add noqa: ARG001 on unused hass --- custom_components/oasis_mini/__init__.py | 4 +++- custom_components/oasis_mini/binary_sensor.py | 2 +- custom_components/oasis_mini/button.py | 2 +- custom_components/oasis_mini/helpers.py | 4 ++-- custom_components/oasis_mini/image.py | 2 +- custom_components/oasis_mini/light.py | 2 +- custom_components/oasis_mini/media_player.py | 2 +- custom_components/oasis_mini/number.py | 7 ++++++- custom_components/oasis_mini/pyoasiscontrol/device.py | 10 +++++----- custom_components/oasis_mini/pyoasiscontrol/utils.py | 5 +++-- custom_components/oasis_mini/select.py | 8 ++++---- custom_components/oasis_mini/sensor.py | 2 +- custom_components/oasis_mini/switch.py | 8 ++++---- custom_components/oasis_mini/update.py | 2 +- 14 files changed, 34 insertions(+), 26 deletions(-) diff --git a/custom_components/oasis_mini/__init__.py b/custom_components/oasis_mini/__init__.py index d8faa41..8378047 100644 --- a/custom_components/oasis_mini/__init__.py +++ b/custom_components/oasis_mini/__init__.py @@ -249,7 +249,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: OasisDeviceConfigEntry async def async_remove_config_entry_device( - hass: HomeAssistant, config_entry: OasisDeviceConfigEntry, device_entry: DeviceEntry + hass: HomeAssistant, # noqa: ARG001 + config_entry: OasisDeviceConfigEntry, + device_entry: DeviceEntry, ) -> bool: """ Determine whether the config entry is no longer associated with the given device. diff --git a/custom_components/oasis_mini/binary_sensor.py b/custom_components/oasis_mini/binary_sensor.py index 677881c..99bb127 100644 --- a/custom_components/oasis_mini/binary_sensor.py +++ b/custom_components/oasis_mini/binary_sensor.py @@ -17,7 +17,7 @@ from .pyoasiscontrol import OasisDevice async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: diff --git a/custom_components/oasis_mini/button.py b/custom_components/oasis_mini/button.py index 11c19a8..9dd57cd 100644 --- a/custom_components/oasis_mini/button.py +++ b/custom_components/oasis_mini/button.py @@ -24,7 +24,7 @@ from .pyoasiscontrol.const import TRACKS async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: diff --git a/custom_components/oasis_mini/helpers.py b/custom_components/oasis_mini/helpers.py index 2b06f04..902d742 100644 --- a/custom_components/oasis_mini/helpers.py +++ b/custom_components/oasis_mini/helpers.py @@ -23,8 +23,8 @@ def create_client(hass: HomeAssistant, data: dict[str, Any]) -> OasisCloudClient Create an Oasis cloud client configured with the Home Assistant HTTP session and access token. Parameters: - hass: Home Assistant instance used to obtain the shared HTTP client session. - data: Configuration mapping; the function reads the `CONF_ACCESS_TOKEN` key for the cloud access token. + hass (HomeAssistant): Home Assistant instance used to obtain the shared HTTP client session. + data (dict[str, Any]): Configuration mapping; the function reads the `CONF_ACCESS_TOKEN` key for the cloud access token. Returns: An `OasisCloudClient` initialized with the Home Assistant HTTP session and the configured access token. diff --git a/custom_components/oasis_mini/image.py b/custom_components/oasis_mini/image.py index b7a200c..acb4793 100644 --- a/custom_components/oasis_mini/image.py +++ b/custom_components/oasis_mini/image.py @@ -15,7 +15,7 @@ from .pyoasiscontrol import OasisDevice async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: diff --git a/custom_components/oasis_mini/light.py b/custom_components/oasis_mini/light.py index 3d3df29..f70d332 100644 --- a/custom_components/oasis_mini/light.py +++ b/custom_components/oasis_mini/light.py @@ -30,7 +30,7 @@ from .pyoasiscontrol.const import LED_EFFECTS async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: diff --git a/custom_components/oasis_mini/media_player.py b/custom_components/oasis_mini/media_player.py index 8c3c53b..563e024 100644 --- a/custom_components/oasis_mini/media_player.py +++ b/custom_components/oasis_mini/media_player.py @@ -26,7 +26,7 @@ from .pyoasiscontrol import OasisDevice async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: diff --git a/custom_components/oasis_mini/number.py b/custom_components/oasis_mini/number.py index 66fe93d..8774e3b 100644 --- a/custom_components/oasis_mini/number.py +++ b/custom_components/oasis_mini/number.py @@ -23,7 +23,7 @@ from .pyoasiscontrol.device import ( async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: @@ -31,6 +31,11 @@ async def async_setup_entry( Set up number entities for Oasis devices from a configuration entry. Creates number entities for each discovered Oasis device and each descriptor in DESCRIPTORS, then registers those entities with the platform coordinator so they are added to Home Assistant. + + Parameters: + hass (HomeAssistant): Home Assistant core object. + entry (OasisDeviceConfigEntry): Configuration entry containing runtime data and devices to expose. + async_add_entities (AddEntitiesCallback): Callback to add created entities to Home Assistant. """ def make_entities(new_devices: list[OasisDevice]): diff --git a/custom_components/oasis_mini/pyoasiscontrol/device.py b/custom_components/oasis_mini/pyoasiscontrol/device.py index d88895b..5c0a2cd 100644 --- a/custom_components/oasis_mini/pyoasiscontrol/device.py +++ b/custom_components/oasis_mini/pyoasiscontrol/device.py @@ -77,7 +77,7 @@ class OasisDevice: model (str | None): Device model identifier. serial_number (str | None): Device serial number. name (str | None): Human-readable device name; if omitted, defaults to " ". - ssid (str | None): Last-known Wi‑Fi SSID for the device. + ssid (str | None): Last-known Wi-Fi SSID for the device. ip_address (str | None): Last-known IP address for the device. cloud (OasisCloudClient | None): Optional cloud client used to fetch track metadata and remote data. client (OasisClientProtocol | None): Optional transport client used to send commands to the device. @@ -436,11 +436,11 @@ class OasisDevice: Returns: dict[int, dict[str, str]]: A mapping from track ID to a details dictionary (contains at least a `'name'` key). If track metadata is available from the device cache or built-in TRACKS it is used; otherwise a fallback `{"name": "Unknown Title (#)"}` is provided. """ + base = dict(TRACKS) + if (current_id := self.track_id) is not None and self.track: + base[current_id] = self.track return { - track_id: {self.track_id: self.track or {}, **TRACKS}.get( - track_id, - {"name": f"Unknown Title (#{track_id})"}, - ) + track_id: base.get(track_id, {"name": f"Unknown Title (#{track_id})"}) for track_id in self.playlist } diff --git a/custom_components/oasis_mini/pyoasiscontrol/utils.py b/custom_components/oasis_mini/pyoasiscontrol/utils.py index d9e13d0..61de128 100644 --- a/custom_components/oasis_mini/pyoasiscontrol/utils.py +++ b/custom_components/oasis_mini/pyoasiscontrol/utils.py @@ -6,6 +6,7 @@ import base64 from datetime import UTC, datetime import logging import math +from typing import Any from xml.etree.ElementTree import Element, SubElement, tostring from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes @@ -27,12 +28,12 @@ def _bit_to_bool(val: str) -> bool: return val == "1" -def _parse_int(val: str) -> int: +def _parse_int(val: Any | None) -> int: """ Parse a string into an integer, falling back to 0 when conversion fails. Parameters: - val (str): String potentially containing an integer value. + val (Any | None): String potentially containing an integer value. Returns: int: The parsed integer, or 0 if `val` cannot be converted. diff --git a/custom_components/oasis_mini/select.py b/custom_components/oasis_mini/select.py index ccc8f3b..bab75ac 100644 --- a/custom_components/oasis_mini/select.py +++ b/custom_components/oasis_mini/select.py @@ -82,7 +82,7 @@ def queue_update_handler(entity: OasisDeviceSelectEntity) -> None: async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: @@ -92,9 +92,9 @@ async def async_setup_entry( Creates OasisDeviceSelectEntity instances for every device and descriptor and registers them with Home Assistant via the platform setup. Parameters: - hass: Home Assistant instance. - entry: Oasis device config entry used to locate coordinator and runtime data. - async_add_entities: Callback to add created entities to Home Assistant. + hass (HomeAssistant): Home Assistant core object. + entry (OasisDeviceConfigEntry): Configuration entry containing runtime data and devices to expose. + async_add_entities (AddEntitiesCallback): Callback to add created entities to Home Assistant. """ def make_entities(new_devices: list[OasisDevice]): diff --git a/custom_components/oasis_mini/sensor.py b/custom_components/oasis_mini/sensor.py index 7f62975..1a1ec57 100644 --- a/custom_components/oasis_mini/sensor.py +++ b/custom_components/oasis_mini/sensor.py @@ -17,7 +17,7 @@ from .pyoasiscontrol import OasisDevice async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: diff --git a/custom_components/oasis_mini/switch.py b/custom_components/oasis_mini/switch.py index eb49dcb..3bdf4b4 100644 --- a/custom_components/oasis_mini/switch.py +++ b/custom_components/oasis_mini/switch.py @@ -15,7 +15,7 @@ from .pyoasiscontrol import OasisDevice async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: @@ -25,9 +25,9 @@ async def async_setup_entry( Creates an OasisDeviceSwitchEntity for each OasisDevice associated with the given config entry (one entity per descriptor in DESCRIPTORS) and registers them with Home Assistant via the coordinator helper. Parameters: - hass: Home Assistant core instance. - entry: OasisDeviceConfigEntry containing runtime data and the devices to expose as switch entities. - async_add_entities: Callback used to register created entities with Home Assistant. + hass (HomeAssistant): Home Assistant core instance. + entry (OasisDeviceConfigEntry): Config entry containing runtime data used to create device update entities. + async_add_entities (AddEntitiesCallback): Callback to add created entities to Home Assistant. """ def make_entities(new_devices: list[OasisDevice]): diff --git a/custom_components/oasis_mini/update.py b/custom_components/oasis_mini/update.py index 17e3ffa..dc0281a 100644 --- a/custom_components/oasis_mini/update.py +++ b/custom_components/oasis_mini/update.py @@ -25,7 +25,7 @@ SCAN_INTERVAL = timedelta(hours=6) async def async_setup_entry( - hass: HomeAssistant, + hass: HomeAssistant, # noqa: ARG001 entry: OasisDeviceConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: