diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index 62649a742..e96d06391 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -28,7 +28,7 @@ import signal import sys import traceback import threading -from typing import Optional +from typing import Optional, TYPE_CHECKING try: @@ -57,6 +57,11 @@ from .network_dialog import NetworkDialog from .stylesheet_patcher import patch_qt_stylesheet from .lightning_dialog import LightningDialog +if TYPE_CHECKING: + from electrum.daemon import Daemon + from electrum.simple_config import SimpleConfig + from electrum.plugin import Plugins + class OpenFileEventFilter(QObject): def __init__(self, windows): @@ -82,7 +87,7 @@ class QNetworkUpdatedSignalObject(QObject): class ElectrumGui(Logger): @profiler - def __init__(self, config, daemon, plugins): + def __init__(self, config: 'SimpleConfig', daemon: 'Daemon', plugins: 'Plugins'): set_language(config.get('language', get_default_language())) Logger.__init__(self) # Uncomment this call to verify objects are being properly diff --git a/electrum/gui/qt/installwizard.py b/electrum/gui/qt/installwizard.py index 90dc8bb4c..c40ad8996 100644 --- a/electrum/gui/qt/installwizard.py +++ b/electrum/gui/qt/installwizard.py @@ -6,13 +6,13 @@ import os import sys import threading import traceback -from typing import Tuple, List, Callable, NamedTuple, Optional +from typing import Tuple, List, Callable, NamedTuple, Optional, TYPE_CHECKING from PyQt5.QtCore import QRect, QEventLoop, Qt, pyqtSignal from PyQt5.QtGui import QPalette, QPen, QPainter, QPixmap from PyQt5.QtWidgets import (QWidget, QDialog, QLabel, QHBoxLayout, QMessageBox, QVBoxLayout, QLineEdit, QFileDialog, QPushButton, - QGridLayout, QSlider, QScrollArea) + QGridLayout, QSlider, QScrollArea, QApplication) from electrum.wallet import Wallet, Abstract_Wallet from electrum.storage import WalletStorage @@ -25,7 +25,11 @@ from .network_dialog import NetworkChoiceLayout from .util import (MessageBoxMixin, Buttons, icon_path, ChoicesLayout, WWLabel, InfoButton, char_width_in_lineedit) from .password_dialog import PasswordLayout, PasswordLayoutForHW, PW_NEW -from electrum.plugin import run_hook +from electrum.plugin import run_hook, Plugins + +if TYPE_CHECKING: + from electrum.simple_config import SimpleConfig + MSG_ENTER_PASSWORD = _("Choose a password to encrypt your wallet keys.") + '\n'\ + _("Leave this field empty if you want to disable encryption.") @@ -115,7 +119,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): accept_signal = pyqtSignal() - def __init__(self, config, app, plugins): + def __init__(self, config: 'SimpleConfig', app: QApplication, plugins: 'Plugins'): QDialog.__init__(self, None) BaseWizard.__init__(self, config, plugins) self.setWindowTitle('Electrum - ' + _('Install Wizard')) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 41cfc5a85..c283245c7 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -36,7 +36,7 @@ import base64 from functools import partial import queue import asyncio -from typing import Optional +from typing import Optional, TYPE_CHECKING from PyQt5.QtGui import QPixmap, QKeySequence, QIcon, QCursor from PyQt5.QtCore import Qt, QRect, QStringListModel, QSize, pyqtSignal @@ -93,6 +93,10 @@ from .history_list import HistoryList, HistoryModel from .update_checker import UpdateCheck, UpdateCheckThread from .channels_list import ChannelsList +if TYPE_CHECKING: + from . import ElectrumGui + + LN_NUM_PAYMENT_ATTEMPTS = 10 class StatusBarButton(QPushButton): @@ -125,7 +129,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): computing_privkeys_signal = pyqtSignal() show_privkeys_signal = pyqtSignal() - def __init__(self, gui_object, wallet: Abstract_Wallet): + def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet): QMainWindow.__init__(self) self.gui_object = gui_object