tqt: add some type hints - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit bcdb72ae93f5e42b8c7f7d0eafb89a767a91f12f DIR parent ef5a5151e3d121d28e180d8e27772e1de3ed2aa9 HTML Author: SomberNight <somber.night@protonmail.com> Date: Mon, 9 Sep 2019 22:19:36 +0200 qt: add some type hints Diffstat: M electrum/gui/qt/__init__.py | 9 +++++++-- M electrum/gui/qt/installwizard.py | 12 ++++++++---- M electrum/gui/qt/main_window.py | 8 ++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) --- DIR diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py t@@ -28,7 +28,7 @@ import signal import sys import traceback import threading -from typing import Optional +from typing import Optional, TYPE_CHECKING try: t@@ -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): t@@ -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 DIR diff --git a/electrum/gui/qt/installwizard.py b/electrum/gui/qt/installwizard.py t@@ -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 t@@ -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.") t@@ -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')) DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -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 t@@ -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): t@@ -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