def construct_new(
        *args, device: Device, plugin: 'LedgerPlugin', **kwargs,
    ) -> Union['Ledger_Client', HardwareClientDummy]:
        """The 'real' constructor, that automatically decides which subclass to use."""
        if LedgerPlugin.is_hw1(device.product_key):
            return HardwareClientDummy(
                plugin=plugin,
                error_text="ledger hw.1 devices are no longer supported",
            )
        # for nano S or newer hw, decide which client impl to use based on software/firmware version:
        hid_device = HID()
        hid_device.path = device.path
        hid_device.open()
        transport = ledger_bitcoin.TransportClient('hid', hid=hid_device)
        try:
            cl = ledger_bitcoin.createClient(transport, chain=get_chain())
        except (ledger_bitcoin.exception.errors.InsNotSupportedError,
                ledger_bitcoin.exception.errors.ClaNotSupportedError) as e:
            # This can happen on very old versions.
            # E.g. with a "nano s", with bitcoin app 1.1.10, SE 1.3.1, MCU 1.0,
            #      - on machine one, ghost43 got InsNotSupportedError
            #      - on machine two, thomasv got ClaNotSupportedError
            #      unclear why the different exceptions, ledger_bitcoin version 0.2.1 in both cases
            _logger.info(f"ledger_bitcoin.createClient() got exc: {e}. falling back to old plugin.")
            cl = None
        if isinstance(cl, ledger_bitcoin.client.NewClient):
            _logger.debug(f"Ledger_Client.construct_new(). creating NewClient for {device=}.")
            return Ledger_Client_New(hid_device, *args, plugin=plugin, **kwargs)
        else:
            _logger.debug(f"Ledger_Client.construct_new(). creating LegacyClient for {device=}.")
            return Ledger_Client_Legacy(hid_device, *args, plugin=plugin, **kwargs)
The 'real' constructor, that automatically decides which subclass to use.
electrum/plugins/ledger/ledger.py