diff --git a/matter_server/client/client.py b/matter_server/client/client.py index dd7796cc..abba334f 100644 --- a/matter_server/client/client.py +++ b/matter_server/client/client.py @@ -254,7 +254,7 @@ async def get_matter_fabrics(self, node_id: int) -> list[MatterFabricData]: fabric_id=f.fabricID, vendor_id=f.vendorID, fabric_index=f.fabricIndex, - fabric_label=f.label if f.label else None, + fabric_label=f.label or None, vendor_name=vendors_map.get(str(f.vendorID)), ) for f in fabrics diff --git a/matter_server/client/models/node.py b/matter_server/client/models/node.py index f8bf274c..6d2c7a4a 100644 --- a/matter_server/client/models/node.py +++ b/matter_server/client/models/node.py @@ -358,7 +358,7 @@ def update(self, node_data: MatterNodeData) -> None: def update_attribute(self, attribute_path: str, new_value: Any) -> None: """Handle Attribute value update.""" - endpoint_id = int(attribute_path.split("/")[0]) + endpoint_id = int(attribute_path.split("/", maxsplit=1)[0]) if endpoint_id not in self.endpoints: # race condition when a bridge is in the process of adding a new endpoint return diff --git a/matter_server/common/models.py b/matter_server/common/models.py index fb897502..d8376558 100644 --- a/matter_server/common/models.py +++ b/matter_server/common/models.py @@ -5,7 +5,7 @@ from collections.abc import Callable from dataclasses import dataclass, field from datetime import datetime # noqa: TC003 -from enum import Enum +from enum import Enum, StrEnum from typing import Any # Enums and constants @@ -25,7 +25,7 @@ class EventType(Enum): ENDPOINT_REMOVED = "endpoint_removed" -class APICommand(str, Enum): +class APICommand(StrEnum): """Enum with all known API commands.""" START_LISTENING = "start_listening" diff --git a/matter_server/server/ota/provider.py b/matter_server/server/ota/provider.py index 606ffda8..7702440e 100644 --- a/matter_server/server/ota/provider.py +++ b/matter_server/server/ota/provider.py @@ -320,7 +320,7 @@ async def fetch_update(self, update_desc: dict) -> None: if parsed_url.scheme in ["http", "https"]: file_path = await self._download_update(url, checksum_alg) - elif parsed_url.scheme in ["file"]: + elif parsed_url.scheme == "file": file_path = self._ota_provider_base_dir / Path(parsed_url.path[1:]) if not await asyncio.to_thread(file_path.exists): LOGGER.warning("Local update file not found: %s", file_path) diff --git a/matter_server/server/server.py b/matter_server/server/server.py index c381e68b..0e5315f2 100644 --- a/matter_server/server/server.py +++ b/matter_server/server/server.py @@ -297,7 +297,7 @@ def scope_ipv6_lla(self, ip_addr: str) -> str: if ip_addr_parsed.scope_id is not None: # This type of IPv6 manipulation is not supported by the ipaddress lib - ip_addr = ip_addr.split("%")[0] + ip_addr = ip_addr.split("%", maxsplit=1)[0] # Rely on host OS routing table if self.primary_interface is None: diff --git a/pyproject.toml b/pyproject.toml index 8b0800da..fb426d9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ test = [ "pytest-asyncio==1.3.0", "pytest-aiohttp==1.1.0", "pytest-cov==7.0.0", - "ruff==0.14.14", + "ruff==0.15.1", "tomli==2.4.0", ] diff --git a/scripts/generate_devices.py b/scripts/generate_devices.py index 8fb4d321..5d0ab1d9 100644 --- a/scripts/generate_devices.py +++ b/scripts/generate_devices.py @@ -32,7 +32,7 @@ def gen_cls_name(name: str): if char in ("-", "/"): next_upper = True continue - elif char in ("."): + elif char == ".": continue elif next_upper: char = char.upper()