From 8266ebcc46a283c97630a1d2e1e3e54c252bc25b Mon Sep 17 00:00:00 2001 From: SomberNight Date: Sun, 23 Apr 2023 01:48:42 +0000 Subject: [PATCH] fix flake8-bugbear B008 B008 Do not perform function calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time function call. If this is intended, assign the function call to a module-level variable and use that variable as a default value. --- electrum/gui/kivy/main_window.py | 4 +++- electrum/gui/qt/main_window.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py index 38e3eff98..892d6ffa3 100644 --- a/electrum/gui/kivy/main_window.py +++ b/electrum/gui/kivy/main_window.py @@ -1119,7 +1119,7 @@ class ElectrumWindow(App, Logger, EventListener): arrow_pos=arrow_pos) @scheduled_in_gui_thread - def show_info_bubble(self, text=_('Hello World'), pos=None, duration=0, + def show_info_bubble(self, text=None, pos=None, duration=0, arrow_pos='bottom_mid', width=None, icon='', modal=False, exit=False): '''Method to show an Information Bubble @@ -1130,6 +1130,8 @@ class ElectrumWindow(App, Logger, EventListener): width: width of the Bubble arrow_pos: arrow position for the bubble ''' + if text is None: + text = _('Hello World') text = str(text) # so that we also handle e.g. Exception info_bubble = self.info_bubble if not info_bubble: diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 89a3f87ef..a67420ce2 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -1294,8 +1294,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): else: self.show_message(message) - def query_choice(self, msg, choices, title=_('Question'), default_choice=None): + def query_choice(self, msg, choices, title=None, default_choice=None): # Needed by QtHandler for hardware wallets + if title is None: + title = _('Question') dialog = WindowModalDialog(self.top_level_window(), title=title) dialog.setMinimumWidth(400) clayout = ChoicesLayout(msg, choices, checked_index=default_choice) @@ -1918,10 +1920,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): d = SeedDialog(self, seed, passphrase, config=self.config) d.exec_() - def show_qrcode(self, data, title = _("QR code"), parent=None, *, + def show_qrcode(self, data, title=None, parent=None, *, help_text=None, show_copy_text_btn=False): if not data: return + if title is None: + title = _("QR code") d = QRDialog( data=data, parent=parent or self,