Minor linting

This commit is contained in:
Dpeta 2022-11-17 08:42:10 +01:00
parent 8d1bef4db2
commit 340ef73380
5 changed files with 36 additions and 35 deletions

View file

@ -144,7 +144,7 @@ class pesterQuirks(object):
def apply(self, lexed, first=False, last=False): def apply(self, lexed, first=False, last=False):
prefix = [q for q in self.quirklist if q.type == "prefix"] prefix = [q for q in self.quirklist if q.type == "prefix"]
suffix = [q for q in self.quirklist if q.type == "suffix"] #suffix = [q for q in self.quirklist if q.type == "suffix"]
newlist = [] newlist = []
for (i, o) in enumerate(lexed): for (i, o) in enumerate(lexed):
@ -320,7 +320,7 @@ class PesterProfile(object):
def colorcmd(self): def colorcmd(self):
if self.color: if self.color:
(r, g, b, a) = self.color.getRgb() (r, g, b, _) = self.color.getRgb()
return "%d,%d,%d" % (r, g, b) return "%d,%d,%d" % (r, g, b)
else: else:
return "0,0,0" return "0,0,0"
@ -422,14 +422,10 @@ class PesterProfile(object):
) )
def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel): def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel):
(temporal, pcf, when) = ( """timeGrammar.temporal and timeGrammar.when are unused"""
timeGrammar.temporal,
timeGrammar.pcf,
timeGrammar.when,
)
timetext = timeDifference(td) timetext = timeDifference(td)
PchumLog.debug("pre pcf+self.initials()") PchumLog.debug("pre pcf+self.initials()")
initials = pcf + self.initials() initials = timeGrammar.pcf + self.initials()
PchumLog.debug("post pcf+self.initials()") PchumLog.debug("post pcf+self.initials()")
return "<c=%s><c=%s>%s</c> %s %s %s.</c>" % ( return "<c=%s><c=%s>%s</c> %s %s %s.</c>" % (
syscolor.name(), syscolor.name(),

2
irc.py
View file

@ -179,7 +179,7 @@ class PesterIRC(QtCore.QThread):
c = a.rfind("<c", 0, c) c = a.rfind("<c", 0, c)
# end all ctags in first part # end all ctags in first part
for i in range(a.count("<c") - a.count("</c>")): for _ in range(a.count("<c") - a.count("</c>")):
a = a + "</c>" a = a + "</c>"
# start them up again in the second part # start them up again in the second part
for c in hanging: for c in hanging:

View file

@ -79,7 +79,7 @@ class PesterLogUserSelect(QtWidgets.QDialog):
self.chumsBox.setStyleSheet(self.theme["main/chums/style"]) self.chumsBox.setStyleSheet(self.theme["main/chums/style"])
self.chumsBox.optionsMenu = QtWidgets.QMenu(self) self.chumsBox.optionsMenu = QtWidgets.QMenu(self)
for (i, t) in enumerate(chumMemoList): for (_, t) in enumerate(chumMemoList):
item = QtWidgets.QListWidgetItem(t) item = QtWidgets.QListWidgetItem(t)
item.setForeground( item.setForeground(
QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])) QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"]))

View file

@ -160,9 +160,11 @@ class TimeTracker(list):
def addRecord(self, timed): def addRecord(self, timed):
try: try:
(temporal, pcf, when) = pcfGrammar(timed - timedelta(0)) #(temporal, pcf, when) = pcfGrammar(timed - timedelta(0))
pcf = pcfGrammar(timed - timedelta(0))[1]
except TypeError: except TypeError:
(temporal, pcf, when) = pcfGrammar(mysteryTime()) #(temporal, pcf, when) = pcfGrammar(mysteryTime())
pcf = pcfGrammar(mysteryTime())[1]
if pcf == "C" or pcf == "?": if pcf == "C" or pcf == "?":
return return
if timed in self.timerecord[pcf]: if timed in self.timerecord[pcf]:
@ -171,9 +173,10 @@ class TimeTracker(list):
def getRecord(self, timed): def getRecord(self, timed):
try: try:
(temporal, pcf, when) = pcfGrammar(timed - timedelta(0)) #(temporal, pcf, when) = pcfGrammar(timed - timedelta(0))
pcf = pcfGrammar(timed - timedelta(0))[1]
except TypeError: except TypeError:
(temporal, pcf, when) = pcfGrammar(mysteryTime()) pcf = pcfGrammar(mysteryTime())[1]
if pcf == "C" or pcf == "?": if pcf == "C" or pcf == "?":
return 0 return 0
if len(self.timerecord[pcf]) > 1: if len(self.timerecord[pcf]) > 1:
@ -418,7 +421,7 @@ class MemoText(PesterText):
def makeSafe(msg): def makeSafe(msg):
if msg.count("<c") > msg.count("</c>"): if msg.count("<c") > msg.count("</c>"):
for i in range(msg.count("<c") - msg.count("</c>")): for _ in range(msg.count("<c") - msg.count("</c>")):
msg = msg + "</c>" msg = msg + "</c>"
return '<span style="color:#000000">' + msg + "</span>" return '<span style="color:#000000">' + msg + "</span>"
@ -1362,7 +1365,7 @@ class PesterMemo(PesterConvo):
timed = timedelta.min timed = timedelta.min
else: else:
timed = timedelta.max timed = timedelta.max
except (OSError, ValueError) as e: except (OSError, ValueError):
try: try:
if cmd == "i": if cmd == "i":
timed = timedelta(0) timed = timedelta(0)

View file

@ -178,7 +178,8 @@ except ImportError:
"All possible audio modules failed to import." "All possible audio modules failed to import."
"\nPossible audio modules in order of preference (Windows/MacOS): PyQt6 QtMultimedia > PyQt5 QtMultimedia > pygame" "\nPossible audio modules in order of preference (Windows/MacOS): PyQt6 QtMultimedia > PyQt5 QtMultimedia > pygame"
) )
elif ostools.isLinux() or True: # Linux or misc.
else:
# PyQt5 QtMultimedia needs gstreamer on linux, so pygame is prefered. # PyQt5 QtMultimedia needs gstreamer on linux, so pygame is prefered.
try: try:
try: try:
@ -1398,7 +1399,7 @@ class PesterWindow(MovingWindow):
try: try:
themeChecker(self.theme) themeChecker(self.theme)
except ThemeException as inst: except ThemeException as inst:
PchumLog.error("Caught: " + inst.parameter) PchumLog.error("Caught: %s", inst.parameter)
themeWarning = QtWidgets.QMessageBox(self) themeWarning = QtWidgets.QMessageBox(self)
themeWarning.setText("Theme Error: %s" % inst) themeWarning.setText("Theme Error: %s" % inst)
themeWarning.exec() themeWarning.exec()
@ -1705,14 +1706,14 @@ class PesterWindow(MovingWindow):
"""Check if server is alive on app level, """Check if server is alive on app level,
this function is called every 15sec""" this function is called every 15sec"""
# Return without irc # Return without irc
if hasattr(self.parent, "irc") == False: if not hasattr(self.parent, "irc"):
self.lastCheckPing = None self.lastCheckPing = None
self.sincerecv = 0 self.sincerecv = 0
return return
# We have IRC but we're missing a variable? # We have IRC but we're missing a variable?
# gweh.jpg # gweh.jpg
if None in [self.lastCheckPing, self.sincerecv]: if self.lastCheckPing is None or self.sincerecv is None:
return return
# Desync check, happens if pc comes out of sleep. # Desync check, happens if pc comes out of sleep.
@ -1736,7 +1737,7 @@ class PesterWindow(MovingWindow):
# Show unresponsive if timing out # Show unresponsive if timing out
if self.sincerecv >= 45: if self.sincerecv >= 45:
if self.parent.irc.unresponsive == False: if not self.parent.irc.unresponsive:
self.parent.irc.unresponsive = True self.parent.irc.unresponsive = True
self.parent.showLoading(self.parent.widget, "S3RV3R NOT R3SPOND1NG >:?") self.parent.showLoading(self.parent.widget, "S3RV3R NOT R3SPOND1NG >:?")
self.show() self.show()
@ -1744,7 +1745,7 @@ class PesterWindow(MovingWindow):
else: else:
self.parent.irc.unresponsive = False self.parent.irc.unresponsive = False
if hasattr(self, "loadingscreen"): if hasattr(self, "loadingscreen"):
if self.loadingscreen != None: if self.loadingscreen is not None:
PchumLog.info("Server alive !! :O") PchumLog.info("Server alive !! :O")
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted) self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.loadingscreen = None self.loadingscreen = None
@ -1779,7 +1780,8 @@ class PesterWindow(MovingWindow):
else: else:
m.sendtime() m.sendtime()
def paintEvent(self, event): def paintEvent(self, _):
"""Argument 'event'"""
try: try:
self.backgroundImage self.backgroundImage
except: except:
@ -3459,7 +3461,7 @@ class PesterWindow(MovingWindow):
"If you got this message at launch you may want to " "If you got this message at launch you may want to "
"change your default profile." "change your default profile."
"<br><br>%s<\h3><\html>" "<br><br>%s<\h3><\html>"
% (self.profiledir, self.profiledir, user, e) % (self.profiledir, self.profiledir, handle, e)
) )
except: except:
@ -3617,7 +3619,7 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
def nickCollision(self, handle, tmphandle): def nickCollision(self, handle, tmphandle):
if hasattr(self, "loadingscreen"): if hasattr(self, "loadingscreen"):
if self.loadingscreen != None: if self.loadingscreen is not None:
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted) self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.loadingscreen = None self.loadingscreen = None
@ -3640,7 +3642,7 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
def getSvsnickedOn(self, oldhandle, newhandle): def getSvsnickedOn(self, oldhandle, newhandle):
if hasattr(self, "loadingscreen"): if hasattr(self, "loadingscreen"):
if self.loadingscreen != None: if self.loadingscreen is not None:
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted) self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.loadingscreen = None self.loadingscreen = None
@ -3764,7 +3766,7 @@ class PesterWindow(MovingWindow):
msgbox.addButton( msgbox.addButton(
QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.ButtonRole.NoRole QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.ButtonRole.NoRole
) )
msgbox.exec() reply = msgbox.exec()
if reply == QtWidgets.QMessageBox.ButtonRole.YesRole: if reply == QtWidgets.QMessageBox.ButtonRole.YesRole:
with open(_datadir + "serverlist.json", "w") as server_file: with open(_datadir + "serverlist.json", "w") as server_file:
@ -3791,7 +3793,7 @@ class PesterWindow(MovingWindow):
for i in range(len(server_list_obj)): for i in range(len(server_list_obj)):
server_list_items.append(server_list_obj[i]["server"]) server_list_items.append(server_list_obj[i]["server"])
except: except:
if self.chooseServerAskedToReset == False: if not self.chooseServerAskedToReset:
self.chooseServerAskedToReset = True self.chooseServerAskedToReset = True
self.resetServerlist() self.resetServerlist()
return 1 return 1
@ -3801,7 +3803,7 @@ class PesterWindow(MovingWindow):
for i in range(len(server_list_obj)): for i in range(len(server_list_obj)):
if server_list_obj[i]["server"] == self.removeServerBox.currentText(): if server_list_obj[i]["server"] == self.removeServerBox.currentText():
selected_entry = i selected_entry = i
if selected_entry != None: if selected_entry is not None:
server_list_obj.pop(selected_entry) server_list_obj.pop(selected_entry)
try: try:
@ -3884,7 +3886,7 @@ class PesterWindow(MovingWindow):
for i in range(len(server_obj)): for i in range(len(server_obj)):
server_list_items.append(server_obj[i]["server"]) server_list_items.append(server_obj[i]["server"])
except: except:
if self.chooseServerAskedToReset == False: if not self.chooseServerAskedToReset:
self.chooseServerAskedToReset = True self.chooseServerAskedToReset = True
self.resetServerlist() self.resetServerlist()
return 1 return 1
@ -3979,7 +3981,7 @@ class PesterWindow(MovingWindow):
for i in range(len(server_obj)): for i in range(len(server_obj)):
server_list_items.append(server_obj[i]["server"]) server_list_items.append(server_obj[i]["server"])
except: except:
if self.chooseServerAskedToReset == False: if not self.chooseServerAskedToReset:
self.chooseServerAskedToReset = True self.chooseServerAskedToReset = True
self.resetServerlist() self.resetServerlist()
return 1 return 1
@ -4423,7 +4425,7 @@ class MainProgram(QtCore.QObject):
if ( if (
hasattr(self, "irc") hasattr(self, "irc")
and self.irc.registeredIRC and self.irc.registeredIRC
and self.irc.unresponsive == False and not self.irc.unresponsive
): ):
return return
if self.reconnectok: if self.reconnectok:
@ -4481,9 +4483,9 @@ class MainProgram(QtCore.QObject):
# since --help causes Qt to raise an exception otherwise. # since --help causes Qt to raise an exception otherwise.
args = _ARGUMENTS args = _ARGUMENTS
try: try:
if args.server != None: if args.server is not None:
options["server"] = args.server options["server"] = args.server
if args.port != None: if args.port is not None:
options["port"] = args.port options["port"] = args.port
# Set log level # Set log level
PchumLog.setLevel(args.logging.upper()) PchumLog.setLevel(args.logging.upper())
@ -4492,7 +4494,7 @@ class MainProgram(QtCore.QObject):
# Enable advanced # Enable advanced
options["advanced"] = args.advanced options["advanced"] = args.advanced
# Disable honks # Disable honks
if args.nohonk == True: if args.nohonk:
options["honk"] = False options["honk"] = False
except Exception as e: except Exception as e:
print(e) print(e)