Fix ty type-check failures in new test files

resolve()/for_device_by_model() return DeviceRegistry | None; four new
test files used reg.capabilities/reg.pattern_capabilities without
narrowing away None first. Add the same 'assert reg is not None' idiom
test_dehumidifier_tp1x_dhm01001_capabilities.py already uses.

Verified against a clean venv running the exact CI commands (ruff format
--check, ruff check, ty check, pytest) rather than trusting a stale local
venv that had picked up a mismatched python3.11/3.13 site-packages split.
This commit is contained in:
Marc Billow
2026-08-07 15:52:46 +00:00
parent e2dcc75ed5
commit 8551974719
4 changed files with 8 additions and 0 deletions
@@ -44,6 +44,7 @@ def _resources():
def _bound():
resources = _resources()
reg = resolve(resources, device_types=_DEVICE_TYPES)
assert reg is not None
return discover(resources, reg.capabilities, reg.pattern_capabilities), resources
@@ -68,6 +69,7 @@ def test_board_token_resolves_to_airconditioner_registry():
def test_no_unbound_hrefs():
resources = _resources()
reg = resolve(resources, device_types=_DEVICE_TYPES)
assert reg is not None
unbound = []
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
assert unbound == []
@@ -19,6 +19,7 @@ from tests.conftest import _load_device
def _bound():
resources = _load_device("gas_cooktop_tp2x_ks")
reg = resolve(resources)
assert reg is not None
return discover(resources, reg.capabilities, reg.pattern_capabilities), resources
@@ -31,6 +32,7 @@ def test_resolves_to_gas_cooktop_registry():
def test_no_unbound_hrefs():
_, resources = _bound()
reg = resolve(resources)
assert reg is not None
unbound = []
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
assert unbound == []
@@ -20,6 +20,7 @@ _DEVICE_TYPES = ("oic.wk.d", "oic.d.oven")
def _bound():
resources = _load_device("oven_tp2x_ks_walloven")
reg = resolve(resources, device_types=_DEVICE_TYPES)
assert reg is not None
return discover(resources, reg.capabilities, reg.pattern_capabilities), resources
@@ -31,6 +32,7 @@ def test_oic_device_type_resolves_to_oven_registry():
def test_no_unbound_hrefs():
resources = _load_device("oven_tp2x_ks_walloven")
reg = resolve(resources, device_types=_DEVICE_TYPES)
assert reg is not None
unbound = []
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
assert unbound == []
@@ -15,6 +15,7 @@ from tests.conftest import _load_device
def _bound():
resources = _load_device("refrigerator_tp1x_ref_21k_airfilter")
reg = resolve(resources)
assert reg is not None
return discover(resources, reg.capabilities, reg.pattern_capabilities), resources
@@ -22,6 +23,7 @@ def test_no_unbound_hrefs():
_, resources = _bound()
unbound = []
reg = resolve(resources)
assert reg is not None
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
assert unbound == []