Fixed all Python syntax warnings

This commit is contained in:
TheJackiMonster 2021-02-21 23:45:34 +01:00
parent 6731051e92
commit 12be4c3a3d
No known key found for this signature in database
GPG key ID: D850A5F772E880F9
34 changed files with 103 additions and 102 deletions

View file

@ -26,7 +26,7 @@ class markdownConverter(abstractConverter):
@classmethod @classmethod
def isValid(self): def isValid(self):
return MD is not None return MD != None
@classmethod @classmethod
def convert(self, markdown): def convert(self, markdown):

View file

@ -24,7 +24,7 @@ class HTML(markdown):
exportDefaultSuffix = ".html" exportDefaultSuffix = ".html"
def isValid(self): def isValid(self):
return MD is not None return MD != None
def settingsWidget(self): def settingsWidget(self):
w = markdownSettings(self) w = markdownSettings(self)

View file

@ -51,10 +51,10 @@ class plainText(basicFormat):
def getExportFilename(self, settingsWidget, varName=None, filter=None): def getExportFilename(self, settingsWidget, varName=None, filter=None):
if varName is None: if varName == None:
varName = self.exportVarName varName = self.exportVarName
if filter is None: if filter == None:
filter = self.exportFilter filter = self.exportFilter
settings = settingsWidget.getSettings() settings = settingsWidget.getSettings()

View file

@ -31,7 +31,7 @@ class PDF(abstractOutput):
def isValid(self): def isValid(self):
path = shutil.which("pdflatex") or shutil.which("xelatex") path = shutil.which("pdflatex") or shutil.which("xelatex")
return path is not None return path != None
def output(self, settingsWidget, outputfile=None): def output(self, settingsWidget, outputfile=None):
args = settingsWidget.runnableSettings() args = settingsWidget.runnableSettings()

View file

@ -75,7 +75,7 @@ class pandocSetting:
"""Return whether the specific setting is active with the given format.""" """Return whether the specific setting is active with the given format."""
# Empty formats means all # Empty formats means all
if self.formats is "": if self.formats == "":
return True return True
# "html" in "html markdown latex" # "html" in "html markdown latex"

View file

@ -111,7 +111,7 @@ class Spellchecker:
(lib, name) = values (lib, name) = values
try: try:
d = Spellchecker.dictionaries.get(dictionary, None) d = Spellchecker.dictionaries.get(dictionary, None)
if d is None: if d == None:
for impl in Spellchecker.implementations: for impl in Spellchecker.implementations:
if impl.isInstalled() and lib == impl.getLibraryName(): if impl.isInstalled() and lib == impl.getLibraryName():
d = impl(name) d = impl(name)
@ -267,7 +267,7 @@ class EnchantDictionary(BasicDictionary):
@staticmethod @staticmethod
def isInstalled(): def isInstalled():
return enchant is not None return enchant != None
@staticmethod @staticmethod
def availableDictionaries(): def availableDictionaries():
@ -284,9 +284,9 @@ class EnchantDictionary(BasicDictionary):
if default_locale and not enchant.dict_exists(default_locale): if default_locale and not enchant.dict_exists(default_locale):
default_locale = None default_locale = None
if default_locale is None: if default_locale == None:
default_locale = QLocale.system().name() default_locale = QLocale.system().name()
if default_locale is None: if default_locale == None:
default_locale = self.availableDictionaries()[0] default_locale = self.availableDictionaries()[0]
return default_locale return default_locale
@ -330,7 +330,7 @@ class PySpellcheckerDictionary(BasicDictionary):
@staticmethod @staticmethod
def isInstalled(): def isInstalled():
return pyspellchecker is not None return pyspellchecker != None
@staticmethod @staticmethod
def availableDictionaries(): def availableDictionaries():
@ -350,7 +350,7 @@ class PySpellcheckerDictionary(BasicDictionary):
default_locale = QLocale.system().name() default_locale = QLocale.system().name()
if default_locale: if default_locale:
default_locale = default_locale[0:2] default_locale = default_locale[0:2]
if default_locale is None: if default_locale == None:
default_locale = "en" default_locale = "en"
return default_locale return default_locale
@ -415,7 +415,7 @@ class SymSpellDictionary(BasicDictionary):
@staticmethod @staticmethod
def isInstalled(): def isInstalled():
return symspellpy is not None return symspellpy != None
@classmethod @classmethod
def availableDictionaries(cls): def availableDictionaries(cls):
@ -524,7 +524,7 @@ class LanguageToolDictionary(BasicDictionary):
@staticmethod @staticmethod
def isInstalled(): def isInstalled():
if languagetool is not None: if languagetool != None:
# This check, if Java is installed, is necessary to # This check, if Java is installed, is necessary to
# make sure LanguageTool can be run without problems. # make sure LanguageTool can be run without problems.
@ -550,9 +550,9 @@ class LanguageToolDictionary(BasicDictionary):
if default_locale and not default_locale in languagetool.get_languages(): if default_locale and not default_locale in languagetool.get_languages():
default_locale = None default_locale = None
if default_locale is None: if default_locale == None:
default_locale = QLocale.system().name() default_locale = QLocale.system().name()
if default_locale is None: if default_locale == None:
default_locale = self.availableDictionaries()[0] default_locale = self.availableDictionaries()[0]
return default_locale return default_locale

View file

@ -47,7 +47,7 @@ class mindMapImporter(abstractImporter):
node = root.find("node") node = root.find("node")
items = [] items = []
if node is not None: if node != None:
items.extend(self.parseItems(node, parentItem)) items.extend(self.parseItems(node, parentItem))
ret = True ret = True
@ -97,7 +97,7 @@ class mindMapImporter(abstractImporter):
# Rich text content # Rich text content
content = "" content = ""
content = underElement.find("richcontent") content = underElement.find("richcontent")
if content is not None: if content != None:
# In Freemind, can be note or node # In Freemind, can be note or node
# Note: it's a note # Note: it's a note
# Node: it's the title of the node, in rich text # Node: it's the title of the node, in rich text
@ -130,7 +130,7 @@ class mindMapImporter(abstractImporter):
children = underElement.findall('node') children = underElement.findall('node')
# Process children # Process children
if children is not None and len(children) > 0: if children != None and len(children) > 0:
for c in children: for c in children:
items.extend(self.parseItems(c, item)) items.extend(self.parseItems(c, item))

View file

@ -52,10 +52,10 @@ class opmlImporter(abstractImporter):
bodyNode = opmlNode.find("body") bodyNode = opmlNode.find("body")
items = [] items = []
if bodyNode is not None: if bodyNode != None:
outlineEls = bodyNode.findall("outline") outlineEls = bodyNode.findall("outline")
if outlineEls is not None: if outlineEls != None:
for element in outlineEls: for element in outlineEls:
items.extend(cls.parseItems(element, parentItem)) items.extend(cls.parseItems(element, parentItem))
ret = True ret = True
@ -74,19 +74,20 @@ class opmlImporter(abstractImporter):
def parseItems(cls, underElement, parentItem=None): def parseItems(cls, underElement, parentItem=None):
items = [] items = []
title = underElement.get('text') title = underElement.get('text')
if title is not None: if title != None:
card = outlineItem(parent=parentItem, title=title) card = outlineItem(parent=parentItem, title=title)
items.append(card) items.append(card)
body = "" body = ""
note = underElement.get('_note') note = underElement.get('_note')
if note is not None and not cls.isWhitespaceOnly(note):
if note != None and not cls.isWhitespaceOnly(note):
#body = cls.restoreNewLines(note) #body = cls.restoreNewLines(note)
body = note body = note
children = underElement.findall('outline') children = underElement.findall('outline')
if children is not None and len(children) > 0:
if children != None and len(children) > 0:
for el in children: for el in children:
items.extend(cls.parseItems(el, card)) items.extend(cls.parseItems(el, card))
else: else:
@ -121,4 +122,4 @@ class opmlImporter(abstractImporter):
s = cls.restoreNewLines(inString) s = cls.restoreNewLines(inString)
s = ''.join(s.split()) s = ''.join(s.split())
return len(s) is 0 return len(s) == 0

View file

@ -38,7 +38,7 @@ class pandocImporter(abstractImporter):
r = pandocExporter().run(args) r = pandocExporter().run(args)
if r is None: if r == None:
return None return None
if formatTo == "opml": if formatTo == "opml":

View file

@ -107,7 +107,7 @@ def saveProject(zip=None):
settings. settings.
@return: True if successful, False otherwise. @return: True if successful, False otherwise.
""" """
if zip is None: if zip == None:
zip = settings.saveToZip zip = settings.saveToZip
log("\n\nSaving to:", "zip" if zip else "folder") log("\n\nSaving to:", "zip" if zip else "folder")
@ -124,7 +124,7 @@ def saveProject(zip=None):
project = mw.currentProject project = mw.currentProject
# Sanity check (see PR-583): make sure we actually have a current project. # Sanity check (see PR-583): make sure we actually have a current project.
if project is None: if project == None:
print("Error: cannot save project because there is no current project in the UI.") print("Error: cannot save project because there is no current project in the UI.")
return False return False
@ -198,7 +198,7 @@ def saveProject(zip=None):
# We skip the first row, which is empty and transparent # We skip the first row, which is empty and transparent
for i in range(1, mdl.rowCount()): for i in range(1, mdl.rowCount()):
color = "" color = ""
if mdl.data(mdl.index(i, 0), Qt.DecorationRole) is not None: if mdl.data(mdl.index(i, 0), Qt.DecorationRole) != None:
color = iconColor(mdl.data(mdl.index(i, 0), Qt.DecorationRole)).name(QColor.HexRgb) color = iconColor(mdl.data(mdl.index(i, 0), Qt.DecorationRole)).name(QColor.HexRgb)
color = color if color != "#ff000000" else "#00000000" color = color if color != "#ff000000" else "#00000000"
@ -901,7 +901,7 @@ def addTextItems(mdl, odict, parent=None):
@param odict: OrderedDict @param odict: OrderedDict
@return: nothing @return: nothing
""" """
if parent is None: if parent == None:
parent = mdl.rootItem parent = mdl.rootItem
for k in odict: for k in odict:

View file

@ -101,7 +101,7 @@ def prepare(tests=False):
def respectSystemDarkThemeSetting(): def respectSystemDarkThemeSetting():
"""Adjusts the Qt theme to match the OS 'dark theme' setting configured by the user.""" """Adjusts the Qt theme to match the OS 'dark theme' setting configured by the user."""
if platform.system() is not 'Windows': if platform.system() != 'Windows':
return return
# Basic Windows 10 Dark Theme support. # Basic Windows 10 Dark Theme support.
@ -168,7 +168,7 @@ def prepare(tests=False):
def launch(app, MW = None): def launch(app, MW = None):
if MW is None: if MW == None:
from manuskript.functions import mainWindow from manuskript.functions import mainWindow
MW = mainWindow() MW = mainWindow()
@ -176,7 +176,7 @@ def launch(app, MW = None):
# Support for IPython Jupyter QT Console as a debugging aid. # Support for IPython Jupyter QT Console as a debugging aid.
# Last argument must be --console to enable it # Last argument must be --console to enable it
# Code reference : # Code reference :
# https://github.com/ipython/ipykernel/blob/master/examples/embedding/ipkernel_qtapp.py # https://github.com/ipython/ipykernel/blob/master/examples/embedding/ipkernel_qtapp.py
# https://github.com/ipython/ipykernel/blob/master/examples/embedding/internal_ipkernel.py # https://github.com/ipython/ipykernel/blob/master/examples/embedding/internal_ipkernel.py
if len(sys.argv) > 1 and sys.argv[-1] == "--console": if len(sys.argv) > 1 and sys.argv[-1] == "--console":
@ -188,7 +188,7 @@ def launch(app, MW = None):
# Create IPython kernel within our application # Create IPython kernel within our application
kernel = IPKernelApp.instance() kernel = IPKernelApp.instance()
# Initialize it and use matplotlib for main event loop integration with QT # Initialize it and use matplotlib for main event loop integration with QT
kernel.initialize(['python', '--matplotlib=qt']) kernel.initialize(['python', '--matplotlib=qt'])

View file

@ -270,7 +270,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.mainEditor self.mainEditor
] ]
while new is not None: while new != None:
if new in targets: if new in targets:
self._lastFocus = new self._lastFocus = new
break break
@ -838,7 +838,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# risk a scenario where the timer somehow triggers a new save while saving. # risk a scenario where the timer somehow triggers a new save while saving.
self.saveTimerNoChanges.stop() self.saveTimerNoChanges.stop()
if self.currentProject is None: if self.currentProject == None:
# No UI feedback here as this code path indicates a race condition that happens # No UI feedback here as this code path indicates a race condition that happens
# after the user has already closed the project through some way. But in that # after the user has already closed the project through some way. But in that
# scenario, this code should not be reachable to begin with. # scenario, this code should not be reachable to begin with.
@ -1095,7 +1095,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# disconnect only removes one connection at a time. # disconnect only removes one connection at a time.
while True: while True:
try: try:
if oldHandler is not None: if oldHandler != None:
signal.disconnect(oldHandler) signal.disconnect(oldHandler)
else: else:
signal.disconnect() signal.disconnect()
@ -1375,7 +1375,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
dictionaries = Spellchecker.availableDictionaries() dictionaries = Spellchecker.availableDictionaries()
# Set first run dictionary # Set first run dictionary
if settings.dict is None: if settings.dict == None:
settings.dict = Spellchecker.getDefaultDictionary() settings.dict = Spellchecker.getDefaultDictionary()
# Check if project dict is unavailable on this machine # Check if project dict is unavailable on this machine
@ -1586,7 +1586,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
w.cmbPOV.setVisible(val) w.cmbPOV.setVisible(val)
# POV in outline view # POV in outline view
if val is None and Outline.POV in settings.outlineViewColumns: if val == None and Outline.POV in settings.outlineViewColumns:
settings.outlineViewColumns.remove(Outline.POV) settings.outlineViewColumns.remove(Outline.POV)
from manuskript.ui.views.outlineView import outlineView from manuskript.ui.views.outlineView import outlineView

View file

@ -39,7 +39,7 @@ class abstractItem():
self._data[self.enum.title] = title self._data[self.enum.title] = title
self._data[self.enum.type] = _type self._data[self.enum.type] = _type
if xml is not None: if xml != None:
self.setFromXML(xml) self.setFromXML(xml)
if ID: if ID:

View file

@ -131,7 +131,7 @@ class abstractModel(QAbstractItemModel):
# Check whether the parent is the root, or is otherwise invalid. # Check whether the parent is the root, or is otherwise invalid.
# That is to say: no parent or the parent lacks a parent. # That is to say: no parent or the parent lacks a parent.
if (parentItem == self.rootItem) or \ if (parentItem == self.rootItem) or \
(parentItem is None) or (parentItem.parent() is None): (parentItem == None) or (parentItem.parent() == None):
return QModelIndex() return QModelIndex()
return self.createIndex(parentItem.row(), 0, parentItem) return self.createIndex(parentItem.row(), 0, parentItem)
@ -283,7 +283,7 @@ class abstractModel(QAbstractItemModel):
# # Gets encoded mime data to retrieve the item # # Gets encoded mime data to retrieve the item
items = self.decodeMimeData(data) items = self.decodeMimeData(data)
if items is None: if items == None:
return False return False
# We check if parent is not a child of one of the items # We check if parent is not a child of one of the items
@ -321,7 +321,7 @@ class abstractModel(QAbstractItemModel):
return None return None
encodedData = bytes(data.data("application/xml")).decode() encodedData = bytes(data.data("application/xml")).decode()
root = ET.XML(encodedData) root = ET.XML(encodedData)
if root is None: if root == None:
return None return None
if root.tag != "outlineItems": if root.tag != "outlineItems":
@ -381,7 +381,7 @@ class abstractModel(QAbstractItemModel):
items = self.decodeMimeData(data) items = self.decodeMimeData(data)
if items is None: if items == None:
return False return False
if column > 0: if column > 0:

View file

@ -153,7 +153,7 @@ class characterModel(QAbstractItemModel):
return r return r
def getCharacterByID(self, ID): def getCharacterByID(self, ID):
if ID is not None: if ID != None:
ID = str(ID) ID = str(ID)
for c in self.characters: for c in self.characters:
if c.ID() == ID: if c.ID() == ID:

View file

@ -187,7 +187,7 @@ def infos(ref):
elif _type == CharacterLetter: elif _type == CharacterLetter:
m = mainWindow().mdlCharacter m = mainWindow().mdlCharacter
c = m.getCharacterByID(int(_ref)) c = m.getCharacterByID(int(_ref))
if c is None: if c == None:
return qApp.translate("references", "Unknown reference: {}.").format(ref) return qApp.translate("references", "Unknown reference: {}.").format(ref)
index = c.index() index = c.index()

View file

@ -189,7 +189,7 @@ class worldModel(QStandardItemModel):
for index in indexes: for index in indexes:
item = self.itemFromIndex(index) item = self.itemFromIndex(index)
parent = item.parent() parent = item.parent()
if parent is None: if parent == None:
parent = self.invisibleRootItem() parent = self.invisibleRootItem()
row_indexes.append((parent, item.row())) row_indexes.append((parent, item.row()))

View file

@ -12,7 +12,7 @@ def MW():
""" """
from manuskript import functions as F from manuskript import functions as F
MW = F.mainWindow() MW = F.mainWindow()
assert MW is not None assert MW != None
assert MW == F.MW assert MW == F.MW
return MW return MW
@ -23,7 +23,7 @@ def MWNoProject(MW):
Take the MainWindow and close andy possibly open project. Take the MainWindow and close andy possibly open project.
""" """
MW.closeProject() MW.closeProject()
assert MW.currentProject is None assert MW.currentProject == None
return MW return MW
@pytest.fixture @pytest.fixture
@ -35,9 +35,9 @@ def MWEmptyProject(MW):
tf = tempfile.NamedTemporaryFile(suffix=".msk") tf = tempfile.NamedTemporaryFile(suffix=".msk")
MW.closeProject() MW.closeProject()
assert MW.currentProject is None assert MW.currentProject == None
MW.welcome.createFile(tf.name, overwrite=True) MW.welcome.createFile(tf.name, overwrite=True)
assert MW.currentProject is not None assert MW.currentProject != None
return MW return MW
# If using with: @pytest.fixture(scope='session', autouse=True) # If using with: @pytest.fixture(scope='session', autouse=True)
@ -67,6 +67,6 @@ def MWSampleProject(MW):
shutil.copyfile(src, tf.name) shutil.copyfile(src, tf.name)
shutil.copytree(src[:-4], tf.name[:-4]) shutil.copytree(src[:-4], tf.name[:-4])
MW.loadProject(tf.name) MW.loadProject(tf.name)
assert MW.currentProject is not None assert MW.currentProject != None
return MW return MW

View file

@ -130,9 +130,9 @@ def test_modelStuff(outlineModelBasic):
folder.setModel(k) folder.setModel(k)
assert folder.columnCount() == len(folder.enum) assert folder.columnCount() == len(folder.enum)
text1 = text2.copy() text1 = text2.copy()
assert text1.ID() is None assert text1.ID() == None
folder.appendChild(text1) folder.appendChild(text1)
assert text1.ID() is not None assert text1.ID() != None
assert folder.childCountRecursive() == 2 assert folder.childCountRecursive() == 2
assert text1.path() == "Folder > Text" assert text1.path() == "Folder > Text"
assert len(text1.pathID()) == 2 assert len(text1.pathID()) == 2

View file

@ -39,7 +39,7 @@ def test_references(MWSampleProject):
assert "\n" in Ref.infos(Ref.plotReference(plotID)) assert "\n" in Ref.infos(Ref.plotReference(plotID))
assert "Not a ref" in Ref.infos("<invalid>") assert "Not a ref" in Ref.infos("<invalid>")
assert "Unknown" in Ref.infos(Ref.plotReference("999")) assert "Unknown" in Ref.infos(Ref.plotReference("999"))
assert Ref.shortInfos(Ref.plotReference(plotID)) is not None assert Ref.shortInfos(Ref.plotReference(plotID)) != None
assert Ref.shortInfos(Ref.plotReference("999")) == None assert Ref.shortInfos(Ref.plotReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1 assert Ref.shortInfos("<invalidref>") == -1
@ -50,7 +50,7 @@ def test_references(MWSampleProject):
charID = IDs[0] charID = IDs[0]
assert "\n" in Ref.infos(Ref.characterReference(charID)) assert "\n" in Ref.infos(Ref.characterReference(charID))
assert "Unknown" in Ref.infos(Ref.characterReference("999")) assert "Unknown" in Ref.infos(Ref.characterReference("999"))
assert Ref.shortInfos(Ref.characterReference(charID)) is not None assert Ref.shortInfos(Ref.characterReference(charID)) != None
assert Ref.shortInfos(Ref.characterReference("999")) == None assert Ref.shortInfos(Ref.characterReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1 assert Ref.shortInfos("<invalidref>") == -1
@ -62,7 +62,7 @@ def test_references(MWSampleProject):
assert "\n" in Ref.infos(Ref.textReference(textID)) assert "\n" in Ref.infos(Ref.textReference(textID))
assert "Unknown" in Ref.infos(Ref.textReference("999")) assert "Unknown" in Ref.infos(Ref.textReference("999"))
assert Ref.shortInfos(Ref.textReference(textID)) is not None assert Ref.shortInfos(Ref.textReference(textID)) != None
assert Ref.shortInfos(Ref.textReference("999")) == None assert Ref.shortInfos(Ref.textReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1 assert Ref.shortInfos("<invalidref>") == -1
@ -73,7 +73,7 @@ def test_references(MWSampleProject):
assert "\n" in Ref.infos(Ref.worldReference(worldID)) assert "\n" in Ref.infos(Ref.worldReference(worldID))
assert "Unknown" in Ref.infos(Ref.worldReference("999")) assert "Unknown" in Ref.infos(Ref.worldReference("999"))
assert Ref.shortInfos(Ref.worldReference(worldID)) is not None assert Ref.shortInfos(Ref.worldReference(worldID)) != None
assert Ref.shortInfos(Ref.worldReference("999")) == None assert Ref.shortInfos(Ref.worldReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1 assert Ref.shortInfos("<invalidref>") == -1
@ -84,9 +84,9 @@ def test_references(MWSampleProject):
# Titles # Titles
for ref in refs: for ref in refs:
assert Ref.title(ref) is not None assert Ref.title(ref) != None
assert Ref.title("<invalid>") is None assert Ref.title("<invalid>") == None
assert Ref.title(Ref.plotReference("999")) is None assert Ref.title(Ref.plotReference("999")) == None
# Other stuff # Other stuff
assert Ref.type(Ref.plotReference(plotID)) == Ref.PlotLetter assert Ref.type(Ref.plotReference(plotID)) == Ref.PlotLetter
@ -94,10 +94,10 @@ def test_references(MWSampleProject):
assert "Unknown" in Ref.tooltip(Ref.worldReference("999")) assert "Unknown" in Ref.tooltip(Ref.worldReference("999"))
assert "Not a ref" in Ref.tooltip("<invalid>") assert "Not a ref" in Ref.tooltip("<invalid>")
for ref in refs: for ref in refs:
assert Ref.tooltip(ref) is not None assert Ref.tooltip(ref) != None
# Links # Links
assert Ref.refToLink("<invalid>") is None assert Ref.refToLink("<invalid>") == None
assert Ref.refToLink(Ref.plotReference("999")) == Ref.plotReference("999") assert Ref.refToLink(Ref.plotReference("999")) == Ref.plotReference("999")
assert Ref.refToLink(Ref.characterReference("999")) == Ref.characterReference("999") assert Ref.refToLink(Ref.characterReference("999")) == Ref.characterReference("999")
assert Ref.refToLink(Ref.textReference("999")) == Ref.textReference("999") assert Ref.refToLink(Ref.textReference("999")) == Ref.textReference("999")
@ -106,7 +106,7 @@ def test_references(MWSampleProject):
assert "<a href" in Ref.refToLink(ref) assert "<a href" in Ref.refToLink(ref)
# Open # Open
assert Ref.open("<invalid>") is None assert Ref.open("<invalid>") == None
assert Ref.open(Ref.plotReference("999")) == False assert Ref.open(Ref.plotReference("999")) == False
assert Ref.open(Ref.characterReference("999")) == False assert Ref.open(Ref.characterReference("999")) == False
assert Ref.open(Ref.textReference("999")) == False assert Ref.open(Ref.textReference("999")) == False

View file

@ -46,8 +46,8 @@ def test_several():
assert F.iconColor(icon).name().lower() == "#ff0000" assert F.iconColor(icon).name().lower() == "#ff0000"
# themeIcon # themeIcon
assert F.themeIcon("text") is not None assert F.themeIcon("text") != None
assert F.themeIcon("nonexistingname") is not None assert F.themeIcon("nonexistingname") != None
# randomColor # randomColor
c1 = F.randomColor() c1 = F.randomColor()
@ -75,10 +75,10 @@ def test_outlineItemColors():
def test_paths(): def test_paths():
assert F.appPath() is not None assert F.appPath() != None
assert F.writablePath is not None assert F.writablePath != None
assert len(F.allPaths("suffix")) == 2 assert len(F.allPaths("suffix")) == 2
assert F.tempFile("yop") is not None assert F.tempFile("yop") != None
f = F.findBackground("spacedreams.jpg") f = F.findBackground("spacedreams.jpg")
assert "resources/backgrounds/spacedreams.jpg" in f assert "resources/backgrounds/spacedreams.jpg" in f
assert len(F.customIcons()) > 1 assert len(F.customIcons()) > 1
@ -87,8 +87,8 @@ def test_mainWindow():
from PyQt5.QtWidgets import QWidget, QLCDNumber from PyQt5.QtWidgets import QWidget, QLCDNumber
assert F.mainWindow() is not None assert F.mainWindow() != None
assert F.MW is not None assert F.MW != None
F.statusMessage("Test") F.statusMessage("Test")
F.printObjects() F.printObjects()

View file

@ -55,7 +55,7 @@ def test_general(MWSampleProject):
state = settings() state = settings()
assert chk.isChecked() == state assert chk.isChecked() == state
chk.setChecked(not state) chk.setChecked(not state)
assert chk.isChecked() is not state assert chk.isChecked() != state
# Loading and Saving # Loading and Saving
SW.txtAutoSave.setText("0") SW.txtAutoSave.setText("0")
@ -86,7 +86,7 @@ def test_general(MWSampleProject):
SW.chkOutlineTitle.setChecked(Qt.Unchecked) SW.chkOutlineTitle.setChecked(Qt.Unchecked)
SW.chkOutlineTitle.setChecked(Qt.Checked) SW.chkOutlineTitle.setChecked(Qt.Checked)
# Can't test because of the dialog # Can't test because of the dialog
# assert SW.setCorkColor() is None # assert SW.setCorkColor() == None
SW.sldTreeIconSize.setValue(SW.sldTreeIconSize.value() + 1) SW.sldTreeIconSize.setValue(SW.sldTreeIconSize.value() + 1)
SW.rdoCorkNewStyle.toggled.emit(True) SW.rdoCorkNewStyle.toggled.emit(True)
SW.cmbCorkImage.currentIndexChanged.emit(0) SW.cmbCorkImage.currentIndexChanged.emit(0)
@ -98,7 +98,7 @@ def test_general(MWSampleProject):
# Test editor # Test editor
switchCheckBoxAndAssert(SW.chkEditorBackgroundTransparent, switchCheckBoxAndAssert(SW.chkEditorBackgroundTransparent,
lambda: S.textEditor["backgroundTransparent"]) lambda: S.textEditor["backgroundTransparent"])
assert SW.restoreEditorColors() is None assert SW.restoreEditorColors() == None
switchCheckBoxAndAssert(SW.chkEditorNoBlinking, switchCheckBoxAndAssert(SW.chkEditorNoBlinking,
lambda: S.textEditor["cursorNotBlinking"]) lambda: S.textEditor["cursorNotBlinking"])
# Twice on purpose: set and restore # Twice on purpose: set and restore
@ -108,7 +108,7 @@ def test_general(MWSampleProject):
SW.updateAllWidgets() SW.updateAllWidgets()
# Labels # Labels
assert SW.updateLabelColor(MW.mdlLabels.item(1).index()) is None assert SW.updateLabelColor(MW.mdlLabels.item(1).index()) == None
rc = MW.mdlLabels.rowCount() rc = MW.mdlLabels.rowCount()
SW.addLabel() SW.addLabel()
SW.lstLabels.setCurrentIndex( SW.lstLabels.setCurrentIndex(
@ -150,7 +150,7 @@ def test_general(MWSampleProject):
for i in range(4): for i in range(4):
SW.updateLineSpacing(i) SW.updateLineSpacing(i)
SW.updateUIFromTheme() # No time to wait on timer SW.updateUIFromTheme() # No time to wait on timer
assert SW._editingTheme is not None assert SW._editingTheme != None
SW.resize(SW.geometry().size()) # resizeEvent SW.resize(SW.geometry().size()) # resizeEvent
#TODO: other edit test (see SW.loadTheme #TODO: other edit test (see SW.loadTheme
SW.saveTheme() SW.saveTheme()

View file

@ -96,7 +96,7 @@ class collapsibleDockWidgets(QToolBar):
def setCurrentGroup(self, group): def setCurrentGroup(self, group):
self.currentGroup = group self.currentGroup = group
for btn, action, widget, grp in self.otherWidgets: for btn, action, widget, grp in self.otherWidgets:
if not grp == group or grp is None: if not grp == group or grp == None:
action.setVisible(False) action.setVisible(False)
else: else:
action.setVisible(True) action.setVisible(True)

View file

@ -8,7 +8,7 @@ class blockUserData(QTextBlockUserData):
def getUserData(block): def getUserData(block):
"""Returns userData if it exists, or a blank one.""" """Returns userData if it exists, or a blank one."""
data = block.userData() data = block.userData()
if data is None: if data == None:
data = blockUserData() data = blockUserData()
return data return data

View file

@ -338,8 +338,8 @@ class fullScreenEditor(QWidget):
item = self._index.internalPointer() item = self._index.internalPointer()
previousItem = self.previousTextItem(item) previousItem = self.previousTextItem(item)
nextItem = self.nextTextItem(item) nextItem = self.nextTextItem(item)
self.btnPrevious.setEnabled(previousItem is not None) self.btnPrevious.setEnabled(previousItem != None)
self.btnNext.setEnabled(nextItem is not None) self.btnNext.setEnabled(nextItem != None)
self.wPath.setItem(item) self.wPath.setItem(item)
def updateStatusBar(self): def updateStatusBar(self):
@ -572,11 +572,11 @@ class myPanel(QWidget):
def addWidgetSetting(self, label, config_name, widgets): def addWidgetSetting(self, label, config_name, widgets):
setting = (label, config_name, widgets) setting = (label, config_name, widgets)
self._settings.append(setting) self._settings.append(setting)
if settings.fullscreenSettings.get(config_name, None) is not None: if settings.fullscreenSettings.get(config_name, None) != None:
self._setSettingValue(setting, settings.fullscreenSettings[config_name]) self._setSettingValue(setting, settings.fullscreenSettings[config_name])
def addSetting(self, label, config_name, default=True): def addSetting(self, label, config_name, default=True):
if settings.fullscreenSettings.get(config_name, None) is None: if settings.fullscreenSettings.get(config_name, None) == None:
self._setConfig(config_name, default) self._setConfig(config_name, default)
self.addWidgetSetting(label, config_name, None) self.addWidgetSetting(label, config_name, None)
@ -651,7 +651,7 @@ class myPath(QWidget):
if i == item: if i == item:
a.setIcon(QIcon.fromTheme("stock_yes")) a.setIcon(QIcon.fromTheme("stock_yes"))
a.setEnabled(False) a.setEnabled(False)
elif self.editor.firstTextItem(i) is None: elif self.editor.firstTextItem(i) == None:
a.setEnabled(False) a.setEnabled(False)
else: else:
a.triggered.connect(gen_cb(i)) a.triggered.connect(gen_cb(i))

View file

@ -105,6 +105,6 @@ class locker(QWidget, Ui_locker):
text)) text))
# Word locked # Word locked
elif self._target is not None: elif self._target != None:
self.btnLock.setText(self.tr("{} words remaining").format( self.btnLock.setText(self.tr("{} words remaining").format(
self._target - self._words)) self._target - self._words))

View file

@ -120,7 +120,7 @@ class mainEditor(QWidget, Ui_mainEditor):
return self.tabSplitter.tab return self.tabSplitter.tab
def currentEditor(self, tabWidget=None): def currentEditor(self, tabWidget=None):
if tabWidget is None: if tabWidget == None:
tabWidget = self.currentTabWidget() tabWidget = self.currentTabWidget()
return tabWidget.currentWidget() return tabWidget.currentWidget()
# return self.tab.currentWidget() # return self.tab.currentWidget()
@ -153,7 +153,7 @@ class mainEditor(QWidget, Ui_mainEditor):
def allTabs(self, tabWidget=None): def allTabs(self, tabWidget=None):
"""Returns all the tabs from the given tabWidget. If tabWidget is None, from the current tabWidget.""" """Returns all the tabs from the given tabWidget. If tabWidget is None, from the current tabWidget."""
if tabWidget is None: if tabWidget == None:
tabWidget = self.currentTabWidget() tabWidget = self.currentTabWidget()
return [tabWidget.widget(i) for i in range(tabWidget.count())] return [tabWidget.widget(i) for i in range(tabWidget.count())]
@ -205,7 +205,7 @@ class mainEditor(QWidget, Ui_mainEditor):
title = self.getIndexTitle(index) title = self.getIndexTitle(index)
if tabWidget is None: if tabWidget == None:
tabWidget = self.currentTabWidget() tabWidget = self.currentTabWidget()
# Checking if tab is already opened # Checking if tab is already opened

View file

@ -145,8 +145,8 @@ class tabSplitter(QWidget, Ui_tabSplitter):
def split(self, toggled=None, state=None): def split(self, toggled=None, state=None):
if state is None and self.splitState == 0 or state == 1: if state == None and self.splitState == 0 or state == 1:
if self.secondTab is None: if self.secondTab == None:
self.addSecondTab() self.addSecondTab()
self.splitState = 1 self.splitState = 1
@ -155,8 +155,8 @@ class tabSplitter(QWidget, Ui_tabSplitter):
self.btnSplit.setIcon(QIcon.fromTheme("split-vertical")) self.btnSplit.setIcon(QIcon.fromTheme("split-vertical"))
self.btnSplit.setToolTip(self.tr("Split horizontally")) self.btnSplit.setToolTip(self.tr("Split horizontally"))
elif state is None and self.splitState == 1 or state == 2: elif state == None and self.splitState == 1 or state == 2:
if self.secondTab is None: if self.secondTab == None:
self.addSecondTab() self.addSecondTab()
self.splitter.setOrientation(Qt.Vertical) self.splitter.setOrientation(Qt.Vertical)
@ -212,7 +212,7 @@ class tabSplitter(QWidget, Ui_tabSplitter):
# self.btnSplit.setGeometry(QRect(0, 0, 24, 24)) # self.btnSplit.setGeometry(QRect(0, 0, 24, 24))
def focusChanged(self, old, new): def focusChanged(self, old, new):
if self.secondTab is None or new is None: if self.secondTab == None or new == None:
return return
oldFT = self.focusTab oldFT = self.focusTab

View file

@ -713,7 +713,7 @@ class MarkdownHighlighter(BasicHighlighter):
# FIXME: TypeError: could not convert 'TextBlockData' to 'QTextBlockUserData' # FIXME: TypeError: could not convert 'TextBlockData' to 'QTextBlockUserData'
# blockData = self.currentBlockUserData() # blockData = self.currentBlockUserData()
# if blockData is None: # if blockData == None:
# blockData = TextBlockData(self.document(), self.currentBlock()) # blockData = TextBlockData(self.document(), self.currentBlock())
# #
# self.setCurrentBlockUserData(blockData) # self.setCurrentBlockUserData(blockData)

View file

@ -66,7 +66,7 @@ class characterTreeView(QTreeWidget):
for child in range(item.childCount()): for child in range(item.childCount()):
sub = item.child(child) sub = item.child(child)
ID = sub.data(0, Qt.UserRole) ID = sub.data(0, Qt.UserRole)
if ID is not None: if ID != None:
# Update name # Update name
c = self._model.getCharacterByID(ID) c = self._model.getCharacterByID(ID)
name = c.name() name = c.name()
@ -124,8 +124,8 @@ class characterTreeView(QTreeWidget):
curr_importance = 0 curr_importance = 0
# check if an item is selected # check if an item is selected
if curr_item is not None: if curr_item != None:
if curr_item.parent() is None: if curr_item.parent() == None:
# this is a top-level category, so find its importance # this is a top-level category, so find its importance
# get the current text, then look up the importance level # get the current text, then look up the importance level
text = curr_item.text(0) text = curr_item.text(0)

View file

@ -31,7 +31,7 @@ class lineEditView(QLineEdit):
self._index = index self._index = index
self._model = index.model() self._model = index.model()
# self.item = index.internalPointer() # self.item = index.internalPointer()
if self._placeholderText is not None: if self._placeholderText != None:
self.setPlaceholderText(self._placeholderText) self.setPlaceholderText(self._placeholderText)
self.textEdited.connect(self.submit) self.textEdited.connect(self.submit)
self.updateText() self.updateText()

View file

@ -34,7 +34,7 @@ class textEditView(QTextEdit):
self._themeData = None self._themeData = None
self._highlighterClass = BasicHighlighter self._highlighterClass = BasicHighlighter
if spellcheck is None: if spellcheck == None:
spellcheck = settings.spellcheck spellcheck = settings.spellcheck
self.spellcheck = spellcheck self.spellcheck = spellcheck

View file

@ -69,7 +69,7 @@ class treeView(QTreeView, dndView, outlineBasics):
return menu return menu
def expandCurrentIndex(self, index=None): def expandCurrentIndex(self, index=None):
if index is None or type(index) == bool: if index == None or type(index) == bool:
index = self._indexesToOpen[0] # self.currentIndex() index = self._indexesToOpen[0] # self.currentIndex()
self.expand(index) self.expand(index)
@ -78,7 +78,7 @@ class treeView(QTreeView, dndView, outlineBasics):
self.expandCurrentIndex(index=idx) self.expandCurrentIndex(index=idx)
def collapseCurrentIndex(self, index=None): def collapseCurrentIndex(self, index=None):
if index is None or type(index) == bool: if index == None or type(index) == bool:
index = self._indexesToOpen[0] # self.currentIndex() index = self._indexesToOpen[0] # self.currentIndex()
self.collapse(index) self.collapse(index)

View file

@ -371,7 +371,7 @@ class welcome(QWidget, Ui_welcome):
Qt.FindChildrenRecursively): Qt.FindChildrenRecursively):
# Update self.template to reflect the changed name values # Update self.template to reflect the changed name values
templateIndex = t.property("templateIndex") templateIndex = t.property("templateIndex")
if templateIndex is not None : if templateIndex != None :
self.template[1][templateIndex] = ( self.template[1][templateIndex] = (
self.template[1][templateIndex][0], self.template[1][templateIndex][0],
t.text()) t.text())