# Buggy code
def unpaired_device_infos(
    self,
    handler: Optional["HardwareHandlerBase"],
    plugin: "HW_PluginBase",
    devices: List["Device"] = None,
    include_failing_clients=False,
) -> List["DeviceInfo"]:
    """Returns a list of DeviceInfo objects: one for each connected,
    unpaired device accepted by the plugin."""
    if not plugin.libraries_available:
        message = plugin.get_library_not_available_message()
        raise HardwarePluginLibraryUnavailable(message)
    if devices is None:
        devices = self.scan_devices()
    devices = [dev for dev in devices if not self.xpub_by_id(dev.id_)]
    infos = []
    for device in devices:
        if device.product_key not in plugin.DEVICE_IDS:
            continue
        try:
            client = self.create_client(device, handler, plugin)
        except Exception as e:
            self.logger.error(
                f"failed to create client for {plugin.name} at {device.path}: {repr(e)}"
            )
            if include_failing_clients:
                infos.append(
                    DeviceInfo(device=device, exception=e, plugin_name=plugin.name)
                )
            continue
        if not client:
            continue
        infos.append(
            DeviceInfo(
                device=device,
                label=client.label(),
                initialized=client.is_initialized(),
                plugin_name=plugin.name,
            )
        )

    return infos


# Traceback (electrum.plugin.DeviceUnpairableError)
Traceback (most recent call last):
File "/home/matejcik/projekty/prace/electrum/electrum/gui/qt/util.py", line 718, in run
result = task.task()
File "/home/matejcik/projekty/prace/electrum/electrum/plugins/trezor/trezor.py", line 179, in get_client
client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
File "/home/matejcik/projekty/prace/electrum/electrum/plugin.py", line 457, in client_for_keystore
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
File "/home/matejcik/projekty/prace/electrum/electrum/plugin.py", line 505, in force_pair_xpub
'receive will be unspendable.').format(plugin.device))
electrum.plugin.DeviceUnpairableError: Electrum cannot pair with your Trezor.

# Fixed code
def unpaired_device_infos(
    self,
    handler: Optional["HardwareHandlerBase"],
    plugin: "HW_PluginBase",
    devices: List["Device"] = None,
    include_failing_clients=False,
) -> List["DeviceInfo"]:
    """Returns a list of DeviceInfo objects: one for each connected,
    unpaired device accepted by the plugin."""
    if not plugin.libraries_available:
        message = plugin.get_library_not_available_message()
        raise HardwarePluginLibraryUnavailable(message)
    if devices is None:
        devices = self.scan_devices()
    devices = [dev for dev in devices if not self.xpub_by_id(dev.id_)]
    infos = []
    for device in devices:
        if device.product_key not in plugin.DEVICE_IDS:
            continue
        try:
            client = self.create_client(device, handler, plugin)
        except Exception as e:
            self.logger.error(
                f"failed to create client for {plugin.name} at {device.path}: {repr(e)}"
            )
            if include_failing_clients:
                infos.append(
                    DeviceInfo(device=device, exception=e, plugin_name=plugin.name)
                )
            continue
        if not client:
            continue
        infos.append(
            DeviceInfo(
                device=device,
                label=client.label(),
                initialized=client.is_initialized(),
                plugin_name=plugin.name,
                soft_device_id=client.get_soft_device_id(),
            )
        )

    return infos