Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eda9053

Browse files
committedOct 26, 2024·
Fix linter
1 parent e17d54b commit eda9053

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed
 

‎src/misc.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
import os
99
import sys
1010
import time
11+
import io
1112
from contextlib import redirect_stdout
1213
from ipaddress import ip_address
1314
from urllib.parse import urlparse
14-
from typing import Any, Callable, Dict, Optional, Type, Tuple
15+
from typing import Any, Callable, Dict, Optional, Tuple
1516

1617
import simplejson as json
1718
from PyQt5.QtCore import QObject, pyqtSignal, QSettings
1819
from PyQt5.QtWidgets import QMessageBox
1920

20-
from constants import log_File, DefaultCache, wqueue, MAX_INPUTS_NO_WARNING
21+
from constants import log_File, DefaultCache, MAX_INPUTS_NO_WARNING
2122

2223

2324
def add_defaultKeys_to_dict(dictObj: Dict[str, Any], defaultObj: Dict[str, Any]) -> None:
@@ -26,7 +27,7 @@ def add_defaultKeys_to_dict(dictObj: Dict[str, Any], defaultObj: Dict[str, Any])
2627
dictObj[key] = defaultObj[key]
2728

2829

29-
QT_MESSAGE_TYPE: Dict[str, Type[QMessageBox.Icon]] = {
30+
QT_MESSAGE_TYPE: Dict[str, QMessageBox.Icon] = {
3031
"info": QMessageBox.Information,
3132
"warn": QMessageBox.Warning,
3233
"crit": QMessageBox.Critical,
@@ -158,7 +159,7 @@ def myPopUp(parentWindow: Any, messType: str, messTitle: str, messText: str, def
158159
def myPopUp_sb(parentWindow: Any, messType: str, messTitle: str, messText: str, singleButton: QMessageBox.StandardButton = QMessageBox.Ok) -> int:
159160
message_type = QT_MESSAGE_TYPE.get(messType, QMessageBox.Information)
160161
mess = QMessageBox(message_type, messTitle, messText, singleButton, parent=parentWindow)
161-
mess.setStandardButtons(singleButton | singleButton)
162+
mess.setStandardButtons(singleButton)
162163
return mess.exec_()
163164

164165

@@ -258,8 +259,9 @@ def readCacheSettings() -> Dict[str, Any]:
258259

259260

260261
def redirect_print(what: str) -> None:
261-
with redirect_stdout(WriteStream(wqueue)):
262-
print(what)
262+
with io.StringIO() as buffer:
263+
with redirect_stdout(buffer):
264+
print(what)
263265

264266

265267
def saveCacheSettings(cache: Dict[str, Any]) -> None:
@@ -316,6 +318,18 @@ def flush(self) -> None:
316318
pass
317319

318320

321+
class WrapperWriteStream:
322+
def __init__(self, write_stream: WriteStream):
323+
self.write_stream = write_stream
324+
325+
def write(self, message: str) -> int:
326+
self.write_stream.write(message)
327+
return len(message)
328+
329+
def flush(self) -> None:
330+
self.write_stream.flush()
331+
332+
319333
# QObject (to be run in QThread) that blocks until data is available
320334
# and then emits a QtSignal to the main thread.
321335
class WriteStreamReceiver(QObject):

‎src/rpcClient.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import http.client as httplib
1010
import ssl
1111
import threading
12-
from typing import Union, Optional
12+
from typing import Union
1313

1414
from constants import DEFAULT_PROTOCOL_VERSION, MINIMUM_FEE
1515
from misc import getCallerName, getFunctionName, printException, printDbg, now, timeThis

‎src/tabRewards.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import threading
88
import simplejson as json
99

10-
from PyQt5.Qt import QApplication
11-
from PyQt5.QtCore import Qt
10+
from PyQt5.Qt import QApplication, Qt
1211
from PyQt5.QtWidgets import QMessageBox, QTableWidgetItem, QHeaderView
1312

1413
from constants import MINIMUM_FEE

0 commit comments

Comments
 (0)
Please sign in to comment.