@@ -119,8 +119,7 @@ def getDriversForConnectedUsbDevices(
119119 )
120120 usbComDeviceMatches = (
121121 DeviceMatch (KEY_SERIAL , port ["usbID" ], port ["port" ], port )
122- for port in deviceInfoFetcher .comPorts
123- if "usbID" in port
122+ for port in deviceInfoFetcher .usbComPorts
124123 )
125124 # Tee is used to ensure that the DeviceMatches aren't created multiple times.
126125 # The processing of these HID device matches, looking for a custom driver, means that all
@@ -234,9 +233,9 @@ def _set_btDevsCache(
234233 self ._btDevsCache = cache .copy () if cache else None
235234
236235 #: Type info for auto property: _get_comPorts
237- comPorts : List [ Dict ]
236+ comPorts : list [ dict [ str , str ] ]
238237
239- def _get_comPorts (self ) -> List [ Dict ]:
238+ def _get_comPorts (self ) -> list [ dict [ str , str ] ]:
240239 return list (hwPortUtils .listComPorts (onlyAvailable = True ))
241240
242241 #: Type info for auto property: _get_usbDevices
@@ -245,6 +244,21 @@ def _get_comPorts(self) -> List[Dict]:
245244 def _get_usbDevices (self ) -> List [Dict ]:
246245 return list (hwPortUtils .listUsbDevices (onlyAvailable = True ))
247246
247+ #: Type info for auto property: _get_usbComPorts
248+ usbComPorts : list [dict [str , str ]]
249+
250+ def _get_usbComPorts (self ) -> list [dict [str , str ]]:
251+ comPorts = []
252+ for port in self .comPorts :
253+ if (usbId := port .get ("usbID" )) is None :
254+ continue
255+ if (usbDict := next (
256+ (d for d in self .usbDevices if d .get ("usbID" ) == usbId ),
257+ None
258+ )) is not None :
259+ comPorts .append (port | usbDict )
260+ return comPorts
261+
248262 #: Type info for auto property: _get_hidDevices
249263 hidDevices : List [Dict ]
250264
@@ -432,7 +446,7 @@ def getConnectedUsbDevicesForDriver(driver: str) -> Iterator[DeviceMatch]:
432446 ),
433447 (
434448 DeviceMatch (KEY_SERIAL , port ["usbID" ], port ["port" ], port )
435- for port in deviceInfoFetcher .comPorts if "usbID" in port
449+ for port in deviceInfoFetcher .usbComPorts
436450 )
437451 )
438452 for match in usbDevs :
0 commit comments