Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions usb_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
- USBDeviceManager: Manager class for device enumeration and lookup
"""

# ruff: disable[I001,UP045]

import logging
import re
from typing import Optional

import usb.core
import usb.util
Expand Down Expand Up @@ -361,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) -> "USBDevice" | None:
def find_by_bus_id(self, bus_id: str) -> Optional["USBDevice"]:
"""Find a device by its bus ID.

Args:
Expand Down Expand Up @@ -397,8 +400,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:
Expand Down Expand Up @@ -428,7 +431,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',
Expand Down
Loading