Apply the following pylint messages:
- use-list-literal - use-dict-literal - consider-using-in - consider-using-from-import
This commit is contained in:
parent
05769e4ff2
commit
9ec4dbd088
8 changed files with 40 additions and 35 deletions
|
@ -160,6 +160,14 @@ enable=F, # Fatal
|
|||
wildcard-import,
|
||||
# Specific refactoring checks:
|
||||
use-implicit-booleaness-not-len,
|
||||
useless-object-inheritance,
|
||||
consider-using-from-import,
|
||||
consider-using-in,
|
||||
consider-using-join,
|
||||
use-list-literal,
|
||||
use-dict-literal,
|
||||
useless-object-inheritance,
|
||||
useless-return,
|
||||
# Specific basic checks:
|
||||
lost-exception,
|
||||
assert-on-tuple,
|
||||
|
|
37
dataobjs.py
37
dataobjs.py
|
@ -166,7 +166,7 @@ class pesterQuirks:
|
|||
# Exclude option is checked
|
||||
if checkstate == 2:
|
||||
# Check for substring that should be excluded.
|
||||
excludes = list()
|
||||
excludes = []
|
||||
# Check for links, store in list.
|
||||
for match in re.finditer(_urlre, string):
|
||||
excludes.append(match)
|
||||
|
@ -189,7 +189,7 @@ class pesterQuirks:
|
|||
if excludes[n].end() > excludes[n + 1].start():
|
||||
excludes.pop(n)
|
||||
# Seperate parts to be quirked.
|
||||
sendparts = list()
|
||||
sendparts = []
|
||||
# Add string until start of exclude at index 0.
|
||||
until = excludes[0].start()
|
||||
sendparts.append(string[:until])
|
||||
|
@ -203,10 +203,10 @@ class pesterQuirks:
|
|||
sendparts.append(string[after:])
|
||||
|
||||
# Quirk to-be-quirked parts.
|
||||
recvparts = list()
|
||||
recvparts = []
|
||||
for part in sendparts:
|
||||
# No split, apply like normal.
|
||||
if q.type == "regexp" or q.type == "random":
|
||||
if q.type in ("regexp", "random"):
|
||||
recvparts.append(
|
||||
q.apply(part, first=(i == 0), last=lastStr)
|
||||
)
|
||||
|
@ -227,8 +227,8 @@ class pesterQuirks:
|
|||
string += recvparts[-1]
|
||||
else:
|
||||
# No split, apply like normal.
|
||||
if q.type != "prefix" and q.type != "suffix":
|
||||
if q.type == "regexp" or q.type == "random":
|
||||
if q.type not in ("prefix", "suffix"):
|
||||
if q.type in ("regexp", "random"):
|
||||
string = q.apply(string, first=(i == 0), last=lastStr)
|
||||
else:
|
||||
string = q.apply(string)
|
||||
|
@ -238,8 +238,8 @@ class pesterQuirks:
|
|||
string = q.apply(string)
|
||||
else:
|
||||
# No split, apply like normal.
|
||||
if q.type != "prefix" and q.type != "suffix":
|
||||
if q.type == "regexp" or q.type == "random":
|
||||
if q.type not in ("prefix", "suffix"):
|
||||
if q.type in ("regexp", "random"):
|
||||
string = q.apply(string, first=(i == 0), last=lastStr)
|
||||
else:
|
||||
string = q.apply(string)
|
||||
|
@ -396,22 +396,21 @@ class PesterProfile:
|
|||
)
|
||||
|
||||
def memoclosemsg(self, syscolor, initials, verb):
|
||||
if type(initials) == type(list()):
|
||||
if isinstance(initials, list):
|
||||
return "<c={}><c={}>{}</c> {}.</c>".format(
|
||||
syscolor.name(),
|
||||
self.colorhtml(),
|
||||
", ".join(initials),
|
||||
verb,
|
||||
)
|
||||
else:
|
||||
return "<c={}><c={}>{}{}{}</c> {}.</c>".format(
|
||||
syscolor.name(),
|
||||
self.colorhtml(),
|
||||
initials.pcf,
|
||||
self.initials(),
|
||||
initials.number,
|
||||
verb,
|
||||
)
|
||||
return "<c={}><c={}>{}{}{}</c> {}.</c>".format(
|
||||
syscolor.name(),
|
||||
self.colorhtml(),
|
||||
initials.pcf,
|
||||
self.initials(),
|
||||
initials.number,
|
||||
verb,
|
||||
)
|
||||
|
||||
def memonetsplitmsg(self, syscolor, initials):
|
||||
if len(initials) <= 0:
|
||||
|
@ -439,7 +438,7 @@ class PesterProfile:
|
|||
|
||||
def memobanmsg(self, opchum, opgrammar, syscolor, initials, reason):
|
||||
opinit = opgrammar.pcf + opchum.initials() + opgrammar.number
|
||||
if type(initials) == type(list()):
|
||||
if isinstance(initials, list):
|
||||
if opchum.handle == reason:
|
||||
return (
|
||||
"<c={}>{}</c> banned <c={}>{}</c> from responding to memo.".format(
|
||||
|
|
6
memos.py
6
memos.py
|
@ -107,7 +107,7 @@ class TimeGrammar:
|
|||
self.temporal = temporal
|
||||
self.pcf = pcf
|
||||
self.when = when
|
||||
if number == "0" or number == 0:
|
||||
if number in ("0", 0):
|
||||
self.number = ""
|
||||
else:
|
||||
self.number = str(number)
|
||||
|
@ -164,7 +164,7 @@ class TimeTracker(list):
|
|||
except TypeError:
|
||||
# (temporal, pcf, when) = pcfGrammar(mysteryTime())
|
||||
pcf = pcfGrammar(mysteryTime())[1]
|
||||
if pcf == "C" or pcf == "?":
|
||||
if pcf in ("C", "?"):
|
||||
return
|
||||
if timed in self.timerecord[pcf]:
|
||||
return
|
||||
|
@ -176,7 +176,7 @@ class TimeTracker(list):
|
|||
pcf = pcfGrammar(timed - timedelta(0))[1]
|
||||
except TypeError:
|
||||
pcf = pcfGrammar(mysteryTime())[1]
|
||||
if pcf == "C" or pcf == "?":
|
||||
if pcf in ("C", "?"):
|
||||
return 0
|
||||
if len(self.timerecord[pcf]) > 1:
|
||||
return self.timerecord[pcf].index(timed) + 1
|
||||
|
|
4
menus.py
4
menus.py
|
@ -37,9 +37,7 @@ class PesterQuirkItem(QtWidgets.QTreeWidgetItem):
|
|||
"""Sets the order of quirks if auto-sorted by Qt. Obsolete now."""
|
||||
if self.quirk.type == "prefix":
|
||||
return True
|
||||
elif (
|
||||
self.quirk.type == "replace" or self.quirk.type == "regexp"
|
||||
) and quirkitem.type == "suffix":
|
||||
elif self.quirk.type in ("replace", "regexp") and quirkitem.type == "suffix":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -13,7 +13,7 @@ except ImportError:
|
|||
import dataobjs
|
||||
|
||||
# karxi: My own contribution to this - a proper lexer.
|
||||
import pnc.lexercon as lexercon
|
||||
from pnc import lexercon
|
||||
from generic import mysteryTime
|
||||
from quirks import ScriptQuirks
|
||||
from pyquirks import PythonQuirks
|
||||
|
|
12
pyinst.py
12
pyinst.py
|
@ -238,10 +238,10 @@ if (_ARGUMENTS.prompts is not False) and (_ARGUMENTS.prompts != "False"):
|
|||
"This is a script to make building with Pyinstaller a bit more conventient."
|
||||
)
|
||||
|
||||
while (delete_builddist != "y") and (delete_builddist != "n"):
|
||||
while delete_builddist not in ("y", "n"):
|
||||
delete_builddist = input("Delete build & dist folders? (Y/N): ").lower()
|
||||
|
||||
while (upx_enabled != "y") and (upx_enabled != "n"):
|
||||
while upx_enabled not in ("y", "n"):
|
||||
upx_enabled = input("Enable UPX? (Y/N): ").lower()
|
||||
if upx_enabled == "y":
|
||||
print("If upx is on your path you don't need to include anything here.")
|
||||
|
@ -257,14 +257,14 @@ if (_ARGUMENTS.prompts is not False) and (_ARGUMENTS.prompts != "False"):
|
|||
elif upx_enabled == "n":
|
||||
upx_dir = ""
|
||||
|
||||
while (windowed != "y") and (windowed != "n"):
|
||||
while windowed not in ("y", "n"):
|
||||
windowed = input("Build with '--windowed'? (Y/N): ").lower()
|
||||
|
||||
if sys.platform == "win32":
|
||||
print(
|
||||
"(https://pyinstaller.readthedocs.io/en/stable/usage.html?highlight=sdk#windows)"
|
||||
)
|
||||
while (package_universal_crt != "y") and (package_universal_crt != "n"):
|
||||
while package_universal_crt not in ("y", "n"):
|
||||
package_universal_crt = input(
|
||||
"Try to include universal CRT? (Y/N): "
|
||||
).lower()
|
||||
|
@ -303,8 +303,8 @@ if (_ARGUMENTS.prompts is not False) and (_ARGUMENTS.prompts != "False"):
|
|||
)
|
||||
print("crt_path = " + crt_path)
|
||||
|
||||
if (sys.platform == "win32") or (sys.platform == "linux"):
|
||||
while (onefile != "y") and (onefile != "n"):
|
||||
if sys.platform in ("win32", "linux"):
|
||||
while onefile not in ("y", "n"):
|
||||
onefile = input("Build with '--onefile'? (Y/N): ").lower()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
|
4
toast.py
4
toast.py
|
@ -93,7 +93,7 @@ class ToastMachine:
|
|||
def show(self):
|
||||
if self.machine.on:
|
||||
# Use libnotify's queue if using libnotify
|
||||
if self.machine.type == "libnotify" or self.machine.type == "twmn":
|
||||
if self.machine.type in ("libnotify", "twmn"):
|
||||
self.realShow()
|
||||
elif self.machine.toasts:
|
||||
self.machine.toasts.append(self)
|
||||
|
@ -116,7 +116,7 @@ class ToastMachine:
|
|||
extras["parent"] = self.machine.parent
|
||||
if "time" in args:
|
||||
extras["time"] = self.time
|
||||
if k == "libnotify" or k == "twmn":
|
||||
if k in ("libnotify", "twmn"):
|
||||
t = v(self.title, self.msg, self.icon, **extras)
|
||||
else:
|
||||
t = v(self.machine, self.title, self.msg, self.icon, **extras)
|
||||
|
|
|
@ -849,7 +849,7 @@ class PesterProfileDB(dict):
|
|||
|
||||
u = []
|
||||
for handle, c in chumdict.items():
|
||||
options = dict()
|
||||
options = {}
|
||||
if "group" in c:
|
||||
options["group"] = c["group"]
|
||||
if "notes" in c:
|
||||
|
|
Loading…
Reference in a new issue