Type-check the test suite, not just the component
CI runs `ty check custom_components tests`; the identity work was only checked against `custom_components`, so eighteen diagnostics in the new tests went unnoticed until the PR run. Two shapes, both in the new files. `dev_reg.async_get` and `ent_reg.async_get` return `... | None`, so chaining an attribute off them is both a type error and, on the failure it exists to catch, an AttributeError instead of the assertion that would say what went wrong -- replaced with `_device_identifiers`/`_entity_unique_id` helpers that assert the row survived and return the field. And `_identity`'s `**kwargs` dict-merge erased the field types it was constructing; spelling the three optional fields out is clearer anyway. No behaviour change; the full suite and the thirteen-mutation sweep still pass.
This commit is contained in:
2 files changed
+61
-42
No files matched your search
+15
-3
@@ -137,9 +137,21 @@ def test_read_identity_tolerates_malformed_oic_res():
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _identity(**kwargs) -> DeviceIdentity:
|
||||
base = {"manufacturer": "Samsung", "model": "M", "name": "N", "serial": None}
|
||||
return DeviceIdentity(**{**base, **kwargs})
|
||||
def _identity(
|
||||
*,
|
||||
serial: str | None = None,
|
||||
device_id: str | None = None,
|
||||
platform_id: str | None = None,
|
||||
) -> DeviceIdentity:
|
||||
"""A DeviceIdentity carrying only the fields the key chain reads."""
|
||||
return DeviceIdentity(
|
||||
manufacturer="Samsung",
|
||||
model="M",
|
||||
name="N",
|
||||
serial=serial,
|
||||
device_id=device_id,
|
||||
platform_id=platform_id,
|
||||
)
|
||||
|
||||
|
||||
def test_read_identity_captures_the_ocf_uuids_as_named_fields():
|
||||
|
||||
Reference in new issue
Block a user