Skip to content

Commit 5e44365

Browse files
committed
api: find: allow 'backend' keyword override.
This change also fixes the case where the 'backend' keyword param passed to usb.core.find() could have multiple values.
1 parent f7a7540 commit 5e44365

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/libusb_package/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,16 @@ def get_libusb1_backend() -> "IBackend":
8989
return usb.backend.libusb1.get_backend(find_library=find_library)
9090

9191

92-
# TODO correct the type signature of find()
92+
# TODO refine the type signature of find()
9393
def find(*args: Any, **kwargs: Any) -> Any:
94-
"""@brief Wrap pyusb's usb.core,find() function."""
94+
"""@brief Wrap pyusb's usb.core,find() function.
95+
96+
A 'backend' keyword argument will override the default of using `get_libusb1_backend()`.
97+
If None is passed for 'backend', then the default backend lookup method of pyusb will
98+
be used.
99+
"""
95100
import usb.core
96-
return usb.core.find(*args, backend=get_libusb1_backend(), **kwargs)
101+
backend = kwargs.pop('backend', get_libusb1_backend())
102+
return usb.core.find(*args, backend=backend, **kwargs)
97103

98104

0 commit comments

Comments
 (0)