From bd1c476edf650b011c2cb6a7a8ee9c01f7c13007 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 17 Jan 2023 19:09:12 +0100 Subject: [PATCH] Code styling tweaks to the Matter integration (#86096) --- homeassistant/components/matter/adapter.py | 5 ++++- homeassistant/components/matter/entity.py | 2 +- homeassistant/components/matter/helpers.py | 11 ++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/matter/adapter.py b/homeassistant/components/matter/adapter.py index b07b489e029..16e7d456212 100644 --- a/homeassistant/components/matter/adapter.py +++ b/homeassistant/components/matter/adapter.py @@ -104,7 +104,10 @@ class MatterAdapter: name = "Hub device" elif not name and device_type_instances: # fallback name based on device type - name = f"{device_type_instances[0].device_type.__doc__[:-1]} {node_device.node().node_id}" + name = ( + f"{device_type_instances[0].device_type.__doc__[:-1]}" + f" {node_device.node().node_id}" + ) dr.async_get(self.hass).async_get_or_create( name=name, diff --git a/homeassistant/components/matter/entity.py b/homeassistant/components/matter/entity.py index fd839dcca5e..f239cec0342 100644 --- a/homeassistant/components/matter/entity.py +++ b/homeassistant/components/matter/entity.py @@ -113,7 +113,7 @@ class MatterEntity(Entity): @callback def get_matter_attribute(self, attribute: type) -> MatterAttribute | None: - """Lookup MatterAttribute instance on device instance by providing the attribute class.""" + """Lookup MatterAttribute on device by providing the attribute class.""" return next( ( x diff --git a/homeassistant/components/matter/helpers.py b/homeassistant/components/matter/helpers.py index 8dd20538a39..5abf81ee608 100644 --- a/homeassistant/components/matter/helpers.py +++ b/homeassistant/components/matter/helpers.py @@ -29,8 +29,8 @@ class MatterEntryData: def get_matter(hass: HomeAssistant) -> MatterAdapter: """Return MatterAdapter instance.""" # NOTE: This assumes only one Matter connection/fabric can exist. - # Shall we support connecting to multiple servers in the client or by config entries? - # In case of the config entry we need to fix this. + # Shall we support connecting to multiple servers in the client or by + # config entries? In case of the config entry we need to fix this. matter_entry_data: MatterEntryData = next(iter(hass.data[DOMAIN].values())) return matter_entry_data.adapter @@ -42,8 +42,8 @@ def get_operational_instance_id( """Return `Operational Instance Name` for given MatterNode.""" fabric_id_hex = f"{server_info.compressed_fabric_id:016X}" node_id_hex = f"{node.node_id:016X}" - # operational instance id matches the mdns advertisement for the node - # this is the recommended ID to recognize a unique matter node (within a fabric) + # Operational instance id matches the mDNS advertisement for the node + # this is the recommended ID to recognize a unique matter node (within a fabric). return f"{fabric_id_hex}-{node_id_hex}" @@ -55,5 +55,6 @@ def get_device_id( operational_instance_id = get_operational_instance_id( server_info, node_device.node() ) - # append nodedevice(type) to differentiate between a root node and bridge within HA devices. + # Append nodedevice(type) to differentiate between a root node + # and bridge within Home Assistant devices. return f"{operational_instance_id}-{node_device.__class__.__name__}"