From 7bea7a3dbba917665dbc18ed783108da97f2b983 Mon Sep 17 00:00:00 2001 From: Alexander Brinkman Date: Wed, 3 Jun 2026 15:52:41 +0200 Subject: [PATCH 1/3] Fix for Python 3.11 --- usb_device.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usb_device.py b/usb_device.py index 691f85c..8f76e2d 100644 --- a/usb_device.py +++ b/usb_device.py @@ -9,6 +9,7 @@ import logging import re +from typing import Optional import usb.core import usb.util @@ -361,7 +362,7 @@ def list_devices(self) -> list[USBDevice]: devices = usb.core.find(find_all=True) return [USBDevice(device) for device in devices] - def find_by_bus_id(self, bus_id: str) -> "USBDevice" | None: + def find_by_bus_id(self, bus_id: str) -> Optional["USBDevice"]: """Find a device by its bus ID. Args: @@ -397,8 +398,8 @@ def find_by_identity( self, vendor_id: int, product_id: int, - serial_number: str | None = None, - ) -> "USBDevice" | None: + serial_number: Optional[str] = None, + ) -> Optional["USBDevice"]: """Find a device by VID, PID, and optionally serial number. Args: @@ -428,7 +429,7 @@ def find_by_identity( return None - def find_by_binding(self, binding: dict[str, str]) -> "USBDevice" | None: + def find_by_binding(self, binding: dict[str, str]) -> Optional["USBDevice"]: """Find a device that matches a binding configuration. The binding dictionary should contain 'vendor_id', 'product_id', From 7ab870b0e10190c56a44ff1a7aabc43b63ff00af Mon Sep 17 00:00:00 2001 From: Alexander Brinkman Date: Wed, 3 Jun 2026 16:00:28 +0200 Subject: [PATCH 2/3] Ack UP045 --- usb_device.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usb_device.py b/usb_device.py index 8f76e2d..f0b9f00 100644 --- a/usb_device.py +++ b/usb_device.py @@ -15,6 +15,7 @@ import usb.util + class USBDevice: """Wrapper class for USB device access via pyusb. @@ -362,7 +363,7 @@ def list_devices(self) -> list[USBDevice]: devices = usb.core.find(find_all=True) return [USBDevice(device) for device in devices] - def find_by_bus_id(self, bus_id: str) -> Optional["USBDevice"]: + def find_by_bus_id(self, bus_id: str) -> Optional["USBDevice"]: # noqa: UP045 """Find a device by its bus ID. Args: @@ -399,7 +400,7 @@ def find_by_identity( vendor_id: int, product_id: int, serial_number: Optional[str] = None, - ) -> Optional["USBDevice"]: + ) -> Optional["USBDevice"]: # noqa: UP045 """Find a device by VID, PID, and optionally serial number. Args: @@ -429,7 +430,7 @@ def find_by_identity( return None - def find_by_binding(self, binding: dict[str, str]) -> Optional["USBDevice"]: + def find_by_binding(self, binding: dict[str, str]) -> Optional["USBDevice"]: # noqa: UP045 """Find a device that matches a binding configuration. The binding dictionary should contain 'vendor_id', 'product_id', From 9db437de7705276eada1df83146cc7efd6117fc0 Mon Sep 17 00:00:00 2001 From: Alexander Brinkman Date: Wed, 3 Jun 2026 16:04:14 +0200 Subject: [PATCH 3/3] ruff updates --- usb_device.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usb_device.py b/usb_device.py index f0b9f00..78baf4e 100644 --- a/usb_device.py +++ b/usb_device.py @@ -7,6 +7,8 @@ - USBDeviceManager: Manager class for device enumeration and lookup """ +# ruff: disable[I001,UP045] + import logging import re from typing import Optional @@ -15,7 +17,6 @@ import usb.util - class USBDevice: """Wrapper class for USB device access via pyusb. @@ -363,7 +364,7 @@ def list_devices(self) -> list[USBDevice]: devices = usb.core.find(find_all=True) return [USBDevice(device) for device in devices] - def find_by_bus_id(self, bus_id: str) -> Optional["USBDevice"]: # noqa: UP045 + def find_by_bus_id(self, bus_id: str) -> Optional["USBDevice"]: """Find a device by its bus ID. Args: @@ -400,7 +401,7 @@ def find_by_identity( vendor_id: int, product_id: int, serial_number: Optional[str] = None, - ) -> Optional["USBDevice"]: # noqa: UP045 + ) -> Optional["USBDevice"]: """Find a device by VID, PID, and optionally serial number. Args: @@ -430,7 +431,7 @@ def find_by_identity( return None - def find_by_binding(self, binding: dict[str, str]) -> Optional["USBDevice"]: # noqa: UP045 + def find_by_binding(self, binding: dict[str, str]) -> Optional["USBDevice"]: """Find a device that matches a binding configuration. The binding dictionary should contain 'vendor_id', 'product_id',