# 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))
            continue
        if not client:
            continue
        infos.append(
            DeviceInfo(
                device=device, label=client.label(), initialized=client.is_initialized()
            )
        )

    return infos


# Traceback (AttributeError)
E | gui.qt.installwizard.InstallWizard |
Traceback (most recent call last):
File "/home/matejcik/projekty/prace/electrum/electrum/base_wizard.py", line 540, in create_wallet
password = k.get_password_for_storage_encryption()
File "/home/matejcik/projekty/prace/electrum/electrum/keystore.py", line 768, in get_password_for_storage_encryption
client = self.plugin.get_client(self)
File "/home/matejcik/projekty/prace/electrum/electrum/plugins/trezor/trezor.py", line 184, in get_client
client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
File "/home/matejcik/projekty/prace/electrum/electrum/plugin.py", line 462, in client_for_keystore
info = self.select_device(plugin, handler, keystore, devices)
File "/home/matejcik/projekty/prace/electrum/electrum/plugin.py", line 584, in select_device
if handler.win.wallet is not None:
AttributeError: 'InstallWizard' object has no attribute 'wallet'

# 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,
            )
        )

    return infos