Fix pre-existing ty diagnostics in a second batch of test files

Same isinstance/cast narrowing and Optional-field assert pattern as the
prior commits, covering the airconditioner, fridge, washer, operational,
subdevices, sensor_hysteresis, laundry, select_options, identity and
entities test files.
This commit is contained in:
Marc Billow committed 2026-08-03 00:11:05 +00:00
1 parent 07061c734d
commit 36a642135b
17 files changed
+322 -100

No files matched your search

+10 -4
View File
@@ -3,8 +3,10 @@
from __future__ import annotations
from datetime import UTC, datetime, timedelta
from typing import cast
from custom_components.localthings.const import CONF_FINISH_TIME_HYSTERESIS_MINUTES
from custom_components.localthings.coordinator import LocalThingsCoordinator
from custom_components.localthings.registry.capabilities.operational import OPERATIONAL_STATE
from custom_components.localthings.registry.discovery import BoundEntity
from custom_components.localthings.sensor import LocalThingsSensor
@@ -32,12 +34,14 @@ class _FakeCoordinator:
def _sensor(threshold_minutes=3):
coordinator = _FakeCoordinator(threshold_minutes)
href = OPERATIONAL_STATE.href
assert href is not None
bound = BoundEntity(
href=OPERATIONAL_STATE.href,
href=href,
capability=OPERATIONAL_STATE,
desc=_FINISH_TIME_DESC,
)
sensor = LocalThingsSensor(coordinator, bound)
sensor = LocalThingsSensor(cast(LocalThingsCoordinator, coordinator), bound)
return sensor, coordinator
@@ -92,12 +96,14 @@ def test_non_hysteresis_sensor_is_unaffected():
"""A SensorDesc without hysteresis=True reads straight through, unchanged."""
machine_state_desc = next(e for e in OPERATIONAL_STATE.entities if e.key == "machine_state")
coordinator = _FakeCoordinator(threshold_minutes=3)
href = OPERATIONAL_STATE.href
assert href is not None
bound = BoundEntity(
href=OPERATIONAL_STATE.href,
href=href,
capability=OPERATIONAL_STATE,
desc=machine_state_desc,
)
sensor = LocalThingsSensor(coordinator, bound)
sensor = LocalThingsSensor(cast(LocalThingsCoordinator, coordinator), bound)
coordinator.data = {"machine_state": "active"}
assert sensor.native_value == "active"