1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Code styling tweaks to core helpers (#85441)

This commit is contained in:
Franck Nijhof
2023-01-09 00:44:09 +01:00
committed by GitHub
parent cf5fca0464
commit 06a35fb7db
22 changed files with 192 additions and 100 deletions

View File

@@ -161,7 +161,9 @@ class DeviceRegistryStore(storage.Store[dict[str, list[dict[str, Any]]]]):
device.setdefault("configuration_url", None)
device.setdefault("disabled_by", None)
try:
device["entry_type"] = DeviceEntryType(device.get("entry_type")) # type: ignore[arg-type]
device["entry_type"] = DeviceEntryType(
device.get("entry_type"), # type: ignore[arg-type]
)
except ValueError:
device["entry_type"] = None
device.setdefault("name_by_user", None)
@@ -550,7 +552,10 @@ class DeviceRegistry:
config_entries=set(device["config_entries"]),
configuration_url=device["configuration_url"],
# type ignores (if tuple arg was cast): likely https://github.com/python/mypy/issues/8625
connections={tuple(conn) for conn in device["connections"]}, # type: ignore[misc]
connections={
tuple(conn) # type: ignore[misc]
for conn in device["connections"]
},
disabled_by=DeviceEntryDisabler(device["disabled_by"])
if device["disabled_by"]
else None,
@@ -559,7 +564,10 @@ class DeviceRegistry:
else None,
hw_version=device["hw_version"],
id=device["id"],
identifiers={tuple(iden) for iden in device["identifiers"]}, # type: ignore[misc]
identifiers={
tuple(iden) # type: ignore[misc]
for iden in device["identifiers"]
},
manufacturer=device["manufacturer"],
model=device["model"],
name_by_user=device["name_by_user"],
@@ -572,8 +580,14 @@ class DeviceRegistry:
deleted_devices[device["id"]] = DeletedDeviceEntry(
config_entries=set(device["config_entries"]),
# type ignores (if tuple arg was cast): likely https://github.com/python/mypy/issues/8625
connections={tuple(conn) for conn in device["connections"]}, # type: ignore[misc]
identifiers={tuple(iden) for iden in device["identifiers"]}, # type: ignore[misc]
connections={
tuple(conn) # type: ignore[misc]
for conn in device["connections"]
},
identifiers={
tuple(iden) # type: ignore[misc]
for iden in device["identifiers"]
},
id=device["id"],
orphaned_timestamp=device["orphaned_timestamp"],
)