Applied some more code simplifications suggested by the new Simplify checker (Y114: use logical or for multiple if).

Mon, 12 Apr 2021 19:21:40 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Apr 2021 19:21:40 +0200
changeset 8228
772103b14c18
parent 8227
349308e84eeb
child 8229
6fa22aa4fc4a

Applied some more code simplifications suggested by the new Simplify checker (Y114: use logical or for multiple if).

eric6/DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/DebugUtilities.py file | annotate | diff | comparison | revisions
eric6/Debugger/VariablesViewer.py file | annotate | diff | comparison | revisions
eric6/E5Gui/E5ToolButton.py file | annotate | diff | comparison | revisions
eric6/E5Gui/E5TreeWidget.py file | annotate | diff | comparison | revisions
eric6/E5XML/SessionReader.py file | annotate | diff | comparison | revisions
eric6/E5XML/XMLStreamReaderBase.py file | annotate | diff | comparison | revisions
eric6/Graphics/AssociationItem.py file | annotate | diff | comparison | revisions
eric6/PipInterface/PipPackageDetailsDialog.py file | annotate | diff | comparison | revisions
eric6/PluginManager/PluginManager.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py file | annotate | diff | comparison | revisions
eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityContext.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/Project/CreateDialogCodeDialog.py file | annotate | diff | comparison | revisions
eric6/Project/Project.py file | annotate | diff | comparison | revisions
eric6/Project/ProjectFormsBrowser.py file | annotate | diff | comparison | revisions
eric6/Project/ProjectResourcesBrowser.py file | annotate | diff | comparison | revisions
eric6/Project/ProjectTranslationsBrowser.py file | annotate | diff | comparison | revisions
eric6/QScintilla/DocstringGenerator/PyDocstringGenerator.py file | annotate | diff | comparison | revisions
eric6/QScintilla/Editor.py file | annotate | diff | comparison | revisions
eric6/QScintilla/MiniEditor.py file | annotate | diff | comparison | revisions
eric6/QScintilla/TypingCompleters/CompleterPython.py file | annotate | diff | comparison | revisions
eric6/QScintilla/TypingCompleters/CompleterYaml.py file | annotate | diff | comparison | revisions
eric6/Snapshot/SnapshotWaylandGrabber.py file | annotate | diff | comparison | revisions
eric6/UI/Browser.py file | annotate | diff | comparison | revisions
eric6/UI/UserInterface.py file | annotate | diff | comparison | revisions
eric6/Utilities/ClassBrowsers/idlclbr.py file | annotate | diff | comparison | revisions
eric6/Utilities/ClassBrowsers/protoclbr.py file | annotate | diff | comparison | revisions
eric6/Utilities/ClassBrowsers/rbclbr.py file | annotate | diff | comparison | revisions
eric6/WebBrowser/AutoScroll/AutoScroller.py file | annotate | diff | comparison | revisions
eric6/WebBrowser/Network/NetworkUrlInterceptor.py file | annotate | diff | comparison | revisions
eric6/WebBrowser/Passwords/PasswordReader.py file | annotate | diff | comparison | revisions
eric6/eric6_browser.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugBase.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/DebugClients/Python/DebugBase.py	Mon Apr 12 19:21:40 2021 +0200
@@ -334,9 +334,7 @@
                 self.stop_here(frame) or
                 self.__checkBreakInFrame(frame) or
                 Watch.watches != []
-            ):
-                return self.trace_dispatch
-            elif (
+            ) or (
                 self.stopframe and
                 frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS
             ):
--- a/eric6/DebugClients/Python/DebugClientBase.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Mon Apr 12 19:21:40 2021 +0200
@@ -1761,18 +1761,14 @@
         elif qttype == 'QDomAttr':
             varlist.append(("name", "str", "{0}".format(value.name())))
             varlist.append(("value", "str", "{0}".format(value.value())))
-        elif qttype == 'QDomCharacterData':
-            varlist.append(("data", "str", "{0}".format(value.data())))
-        elif qttype == 'QDomComment':
+        elif qttype in ('QDomCharacterData', 'QDomComment', 'QDomText'):
             varlist.append(("data", "str", "{0}".format(value.data())))
         elif qttype == 'QDomDocument':
             varlist.append(("text", "str", "{0}".format(value.toString())))
         elif qttype == 'QDomElement':
             varlist.append(("tagName", "str", "{0}".format(value.tagName())))
             varlist.append(("text", "str", "{0}".format(value.text())))
-        elif qttype == 'QDomText':
-            varlist.append(("data", "str", "{0}".format(value.data())))
-            
+        
         # Networking stuff
         elif qttype == 'QHostAddress':
             varlist.append(
@@ -1846,13 +1842,10 @@
                 if valtype in filterList:
                     continue
             elif (
-                key in SpecialAttributes and
-                "special_attributes" in filterList
-            ):
-                continue
-            elif (
-                key == "__hash__" and
-                "builtin_function_or_method" in filterList
+                (key in SpecialAttributes and
+                 "special_attributes" in filterList) or
+                (key == "__hash__" and
+                 "builtin_function_or_method" in filterList)
             ):
                 continue
             else:
@@ -1872,28 +1865,20 @@
                 
                 # valtypename, e.g. QPoint
                 valtypename = type(value).__name__
-                if valtype in filterList:
-                    continue
-                elif (
-                    valtype in ("sip.enumtype", "sip.wrappertype") and
-                    'class' in filterList
-                ):
-                    continue
-                elif (
-                    valtype in (
+                if (
+                    valtype in filterList or
+                    (valtype in ("sip.enumtype", "sip.wrappertype") and
+                     'class' in filterList) or
+                    (valtype in (
                         "sip.methoddescriptor", "method_descriptor") and
-                    'method' in filterList
+                     'method' in filterList) or
+                    (valtype in ("numpy.ndarray", "array.array") and
+                     'list' in filterList) or
+                    (valtypename == "MultiValueDict" and
+                     'dict' in filterList) or
+                    'instance' in filterList
                 ):
                     continue
-                elif (
-                    valtype in ("numpy.ndarray", "array.array") and
-                    'list' in filterList
-                ):
-                    continue
-                elif valtypename == "MultiValueDict" and 'dict' in filterList:
-                    continue
-                elif 'instance' in filterList:
-                    continue
                 
                 isQt = valtype.startswith(ConfigQtNames)
                 
@@ -2328,11 +2313,8 @@
                     redirect = True
             
             ipOrHost = sys.argv[3]
-            if ':' in ipOrHost:
-                # IPv6 address
-                remoteAddress = ipOrHost
-            elif ipOrHost[0] in '0123456789':
-                # IPv4 address
+            if ':' in ipOrHost or ipOrHost[0] in '0123456789':
+                # IPv6 address or IPv4 address
                 remoteAddress = ipOrHost
             else:
                 remoteAddress = self.__resolveHost(ipOrHost)
--- a/eric6/DebugClients/Python/DebugUtilities.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/DebugClients/Python/DebugUtilities.py	Mon Apr 12 19:21:40 2021 +0200
@@ -194,12 +194,12 @@
                     line = line.strip()
                     if line:
                         for name in PYTHON_NAMES:   # __IGNORE_WARNING_Y110__
-                            if line.startswith(
-                                '#!/usr/bin/env {0}'.format(name)
+                            if (
+                                line.startswith(
+                                    '#!/usr/bin/env {0}'.format(name)) or
+                                (line.startswith('#!') and name in line)
                             ):
                                 return True
-                            elif line.startswith('#!') and name in line:
-                                return True
                         return False
         else:
             return False
@@ -308,11 +308,13 @@
         if pyname in program:
             break
     else:
-        if not isWindowsPlatform() and startsWithShebang(args[0]):
-            # insert our interpreter as first argument
-            args.insert(0, sys.executable)
-        elif isWindowsPlatform() and args[0].lower().endswith(".py"):
-            # it is a Python script; insert our interpreter as first argument
+        if (
+            (not isWindowsPlatform() and startsWithShebang(args[0])) or
+            (isWindowsPlatform() and args[0].lower().endswith(".py"))
+        ):
+            # 1. insert our interpreter as first argument if not Windows
+            # 2. insert our interpreter as first argument if on Windows and
+            #    it is a Python script
             args.insert(0, sys.executable)
     
     # extract list of interpreter arguments, i.e. all arguments before the
--- a/eric6/Debugger/VariablesViewer.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Debugger/VariablesViewer.py	Mon Apr 12 19:21:40 2021 +0200
@@ -145,11 +145,11 @@
         if dtype.startswith('class '):
             dtype = dtype[7:-1]
         # Qt related stuff?
-        elif (dtype.startswith(ConfigQtNames) and
-                dtype.endswith(ConfigKnownQtTypes)):
-            self.hasChildren = True
-            
-        elif dtype in ('instance', 'class'):
+        elif (
+            (dtype.startswith(ConfigQtNames) and
+             dtype.endswith(ConfigKnownQtTypes)) or
+            dtype in ('instance', 'class')
+        ):
             self.hasChildren = True
         
         # Special Qt types should not be expanded infinite
--- a/eric6/E5Gui/E5ToolButton.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/E5Gui/E5ToolButton.py	Mon Apr 12 19:21:40 2021 +0200
@@ -201,15 +201,12 @@
             self.__pressTimer.start()
         
         if (
-            evt.buttons() == Qt.MouseButton.LeftButton and
-            self.__menu is not None and
-            self.popupMode() == QToolButton.ToolButtonPopupMode.InstantPopup
-        ):
-            self.setDown(True)
-            self.__showMenu()
-        elif (
-            evt.buttons() == Qt.MouseButton.RightButton and
-            self.__menu is not None
+            (evt.buttons() == Qt.MouseButton.LeftButton and
+             self.__menu is not None and
+             (self.popupMode() ==
+              QToolButton.ToolButtonPopupMode.InstantPopup)) or
+            (evt.buttons() == Qt.MouseButton.RightButton and
+             self.__menu is not None)
         ):
             self.setDown(True)
             self.__showMenu()
--- a/eric6/E5Gui/E5TreeWidget.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/E5Gui/E5TreeWidget.py	Mon Apr 12 19:21:40 2021 +0200
@@ -213,12 +213,13 @@
             while firstItm:
                 if lFilter in firstItm.text(0).lower():
                     firstItm.setHidden(False)
-                elif not firstItm.parent() and not belowItm:
+                elif (
+                    not firstItm.parent() and
+                    (not belowItm or not belowItm.parent())
+                ):
                     firstItm.setHidden(True)
                 elif not belowItm:
                     break
-                elif not firstItm.parent() and not belowItm.parent():
-                    firstItm.setHidden(True)
                 
                 topLvlIndex += 1
                 firstItm = self.topLevelItem(topLvlIndex)
--- a/eric6/E5XML/SessionReader.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/E5XML/SessionReader.py	Mon Apr 12 19:21:40 2021 +0200
@@ -271,7 +271,10 @@
                         self.project.dbgExcIgnoreList = dbgExcIgnoreList[:]
             
             if self.isStartElement():
-                if self.name() == "VirtualEnv":
+                if self.name() in ("Exceptions", "IgnoredExceptions",
+                                   "CovexcPattern"):
+                    pass    # ignore these start tags
+                elif self.name() == "VirtualEnv":
                     txt = self.readElementText()
                     self.dbg.lastUsedVenvName = txt
                     if not self.isGlobal:
@@ -299,12 +302,8 @@
                     self.dbg.setExceptionReporting(exc)
                     if not self.isGlobal:
                         self.project.dbgReportExceptions = exc
-                elif self.name() == "Exceptions":
-                    pass    # ignore this start tag
                 elif self.name() == "Exception":
                     dbgExcList.append(self.readElementText())
-                elif self.name() == "IgnoredExceptions":
-                    pass    # ignore this start tag
                 elif self.name() == "IgnoredException":
                     dbgExcIgnoreList.append(self.readElementText())
                 elif self.name() == "AutoClearShell":
@@ -332,8 +331,6 @@
                     self.dbg.setMultiprocessNoDebugHistory(txt)
                     if not self.isGlobal:
                         self.project.dbgMultiprocessNoDebug = txt
-                elif self.name() == "CovexcPattern":
-                    pass    # ignore this start tag
                 elif self.name() == "GlobalConfigOverride":
                     configOverride = {
                         "enable": self.toBool(self.attribute("enable")),
--- a/eric6/E5XML/XMLStreamReaderBase.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/E5XML/XMLStreamReaderBase.py	Mon Apr 12 19:21:40 2021 +0200
@@ -143,10 +143,7 @@
                 try:
                     if self.name() == "none":
                         val = None
-                    elif self.name() == "int":
-                        val = int(self.readElementText())
-                    elif self.name() == "long":
-                        # backward compatibility to 4.6
+                    elif self.name() in ("int", "long"):
                         val = int(self.readElementText())
                     elif self.name() == "bool":
                         b = self.readElementText()
--- a/eric6/Graphics/AssociationItem.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Graphics/AssociationItem.py	Mon Apr 12 19:21:40 2021 +0200
@@ -60,10 +60,7 @@
         @param parent reference to the parent object
         @type QGraphicsItem
         """
-        if assocType == Normal:
-            arrowType = NormalArrow
-            arrowFilled = True
-        elif assocType == Imports:
+        if assocType in (Normal, Imports):
             arrowType = NormalArrow
             arrowFilled = True
         elif assocType == Generalisation:
@@ -224,9 +221,7 @@
             self.regionA = East
         elif self.regionA == SouthEast:
             self.regionA = South
-        elif self.regionA == SouthWest:
-            self.regionA = West
-        elif self.regionA == Center:
+        elif self.regionA in (SouthWest, Center):
             self.regionA = West
         
         self.__updateEndPoint(self.regionA, True)
@@ -241,9 +236,7 @@
             self.regionB = East
         elif self.regionB == SouthEast:
             self.regionB = South
-        elif self.regionB == SouthWest:
-            self.regionB = West
-        elif self.regionB == Center:
+        elif self.regionB in (SouthWest, Center):
             self.regionB = West
         
         self.__updateEndPoint(self.regionB, False)
--- a/eric6/PipInterface/PipPackageDetailsDialog.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/PipInterface/PipPackageDetailsDialog.py	Mon Apr 12 19:21:40 2021 +0200
@@ -187,12 +187,10 @@
         @return processed text
         @rtype str
         """
-        if text == "UNKNOWN":
+        if text == "UNKNOWN" or text is None:
             text = ""
         elif text == "any":
             text = self.tr("any")
-        elif text is None:
-            text = ""
         if forUrl and (
             not isinstance(text, str) or
             not text.startswith(("http://", "https://", "ftp://"))
--- a/eric6/PluginManager/PluginManager.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/PluginManager/PluginManager.py	Mon Apr 12 19:21:40 2021 +0200
@@ -1255,18 +1255,13 @@
             if lastModified.isValid() and lastModified.date().isValid():
                 lastModifiedDate = lastModified.date()
                 now = QDate.currentDate()
-                if period == 1 and lastModifiedDate.day() == now.day():
-                    # daily
-                    return
-                elif period == 2 and lastModifiedDate.daysTo(now) < 7:
-                    # weekly
-                    return
-                elif (
-                    period == 3 and
-                    (lastModifiedDate.daysTo(now) <
-                     lastModifiedDate.daysInMonth())
+                if (
+                    (period == 1 and lastModifiedDate.day() == now.day()) or
+                    (period == 2 and lastModifiedDate.daysTo(now) < 7) or
+                    (period == 3 and (lastModifiedDate.daysTo(now) <
+                                      lastModifiedDate.daysInMonth()))
                 ):
-                    # monthly
+                    # daily, weekly, monthly
                     return
         
         self.__updateAvailable = False
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py	Mon Apr 12 19:21:40 2021 +0200
@@ -2100,10 +2100,11 @@
                 # datetime.strptime(...).replace(tzinfo=UTC)
                 parent = getattr(node, '_dtCheckerParent', None)
                 pparent = getattr(parent, '_dtCheckerParent', None)
-                if not (isinstance(parent, ast.Attribute) and
-                        parent.attr == 'replace'):
-                    isCase1 = False
-                elif not isinstance(pparent, ast.Call):
+                if (
+                    not (isinstance(parent, ast.Attribute) and
+                         parent.attr == 'replace') or
+                    not isinstance(pparent, ast.Call)
+                ):
                     isCase1 = False
                 else:
                     tzinfoKeyword = self.__getFromKeywords(pparent.keywords,
@@ -2193,16 +2194,13 @@
         """
         match = False
         if (
-            isinstance(node, ast.Attribute) and
-            isinstance(node.value, ast.Name) and
-            node.value.id == "sys" and
-            node.attr == attr
-        ):
-            match = True
-        elif (
-            isinstance(node, ast.Name) and
-            node.id == attr and
-            self.__fromImports.get(node.id) == "sys"
+            (isinstance(node, ast.Attribute) and
+             isinstance(node.value, ast.Name) and
+             node.value.id == "sys" and
+             node.attr == attr) or
+            (isinstance(node, ast.Name) and
+             node.id == attr and
+             self.__fromImports.get(node.id) == "sys")
         ):
             match = True
         
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py	Mon Apr 12 19:21:40 2021 +0200
@@ -72,15 +72,10 @@
                         value = getattr(node, 'value', None)
                         if (
                             getattr(value, 'id', None) == 'True' or
-                            getattr(value, 'value', None) is True
-                        ):
-                            return
-                        
-                        # Check if select_autoescape function is used.
-                        elif (
-                            isinstance(value, ast.Call) and
-                            (getattr(value.func, 'id', None) ==
-                             'select_autoescape')
+                            getattr(value, 'value', None) is True or
+                            (isinstance(value, ast.Call) and
+                             (getattr(value.func, 'id', None) ==
+                              'select_autoescape'))
                         ):
                             return
                         
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityContext.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityContext.py	Mon Apr 12 19:21:40 2021 +0200
@@ -231,7 +231,7 @@
         if AstUtilities.isNumber(literal):
             literalValue = literal.n
         
-        elif AstUtilities.isString(literal):
+        elif AstUtilities.isString(literal) or AstUtilities.isBytes(literal):
             literalValue = literal.s
         
         elif isinstance(literal, ast.List):
@@ -268,9 +268,6 @@
         elif AstUtilities.isNameConstant(literal):
             literalValue = str(literal.value)
         
-        elif AstUtilities.isBytes(literal):
-            literalValue = literal.s
-        
         else:
             literalValue = None
         
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py	Mon Apr 12 19:21:40 2021 +0200
@@ -55,13 +55,11 @@
         """
         enabled = True
         
-        if self.directoryPicker.text() == "":
-            enabled = False
-        elif self.patternEdit.text() == "":
-            enabled = False
-        elif (
-            self.changesetsEdit.toPlainText() == "" and
-            self.bookmarkCombo.currentText() == ""
+        if (
+            self.directoryPicker.text() == "" or
+            self.patternEdit.text() == "" or
+            (self.changesetsEdit.toPlainText() == "" and
+             self.bookmarkCombo.currentText() == "")
         ):
             enabled = False
         
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgSummaryDialog.py	Mon Apr 12 19:21:40 2021 +0200
@@ -149,9 +149,7 @@
                 else:
                     message = output.pop(0).strip()
                     value.append((int(rev), node, tags, message, remarks))
-            elif name == "branch":
-                pass
-            elif name == "bookmarks":
+            elif name in ("branch", "bookmarks"):
                 pass
             elif name == "commit":
                 stateDict = {}
--- a/eric6/Preferences/__init__.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Preferences/__init__.py	Mon Apr 12 19:21:40 2021 +0200
@@ -1785,10 +1785,7 @@
             return "standard"
         else:
             return debugClientType
-    elif key == "PythonExtensions":
-        # we don't support Python2 anymore
-        return ""
-    elif key == "Python2VirtualEnv":
+    elif key in ("PythonExtensions", "Python2VirtualEnv"):
         # we don't support Python2 anymore
         return ""
     else:
--- a/eric6/Project/CreateDialogCodeDialog.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Project/CreateDialogCodeDialog.py	Mon Apr 12 19:21:40 2021 +0200
@@ -377,18 +377,11 @@
         """
         Private slot to generate the code as requested by the user.
         """
-        # first decide on extension
         if (
-            self.filenameEdit.text().endswith(".py") or
-            self.filenameEdit.text().endswith(".pyw")
+            self.filenameEdit.text().endswith(".rb") or
+            self.project.getProjectLanguage() == "Ruby"
         ):
-            self.__generatePythonCode()
-        elif self.filenameEdit.text().endswith(".rb"):
-            pass
-        # second decide on project language
-        elif self.project.getProjectLanguage() == "Python3":
-            self.__generatePythonCode()
-        elif self.project.getProjectLanguage() == "Ruby":
+            # Ruby code generation is not supported
             pass
         else:
             # assume Python (our global default)
--- a/eric6/Project/Project.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Project/Project.py	Mon Apr 12 19:21:40 2021 +0200
@@ -3540,9 +3540,7 @@
         @return default extension (including the dot) (string)
         """
         lang = self.pdata["PROGLANGUAGE"]
-        if lang == "":
-            lang = "Python3"
-        elif lang == "Python":
+        if lang in ("", "Python"):
             lang = "Python3"
         return self.__sourceExtensions(lang)[0]
         
@@ -3796,11 +3794,10 @@
         """
         newfn = os.path.abspath(fn)
         newfn = self.getRelativePath(newfn)
-        if newfn in self.pdata[group]:
-            return True
-        elif (
-            group == "OTHERS" and
-            any(newfn.startswith(entry) for entry in self.pdata[group])
+        if (
+            newfn in self.pdata[group] or
+            (group == "OTHERS" and
+             any(newfn.startswith(entry) for entry in self.pdata[group]))
         ):
             return True
         
@@ -4723,17 +4720,11 @@
                     (filetype == "RESOURCES" and
                      fn not in self.pdata["RESOURCES"]) or
                     (filetype == "OTHERS" and
-                     fn not in self.pdata["OTHERS"])
-                ):
-                    if autoInclude and AI:
-                        self.appendFile(ns)
-                    else:
-                        newFiles.append(ns)
-                elif (
-                    filetype == "TRANSLATIONS" and
-                    fn not in self.pdata["TRANSLATIONS"] and
-                    (fnmatch.fnmatch(ns, pattern) or
-                     fnmatch.fnmatch(ns, binpattern))
+                     fn not in self.pdata["OTHERS"]) or
+                    (filetype == "TRANSLATIONS" and
+                     fn not in self.pdata["TRANSLATIONS"] and
+                     (fnmatch.fnmatch(ns, pattern) or
+                      fnmatch.fnmatch(ns, binpattern)))
                 ):
                     if autoInclude and AI:
                         self.appendFile(ns)
--- a/eric6/Project/ProjectFormsBrowser.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Project/ProjectFormsBrowser.py	Mon Apr 12 19:21:40 2021 +0200
@@ -684,15 +684,12 @@
         self.__resetUiCompiler()
         
         if self.project.getProjectLanguage() == "Python3":
-            if self.project.getProjectType() in ["PyQt5"]:
+            if self.project.getProjectType() in ["PyQt5", "E6Plugin"]:
                 self.__uicompiler = Utilities.generatePyQtToolPath(
                     'pyuic5', ["py3uic5"])
             elif self.project.getProjectType() in ["PyQt6"]:
                 self.__uicompiler = Utilities.generatePyQtToolPath(
                     'pyuic6')
-            elif self.project.getProjectType() in ["E6Plugin"]:
-                self.__uicompiler = Utilities.generatePyQtToolPath(
-                    'pyuic5', ["py3uic5"])
             elif self.project.getProjectType() == "PySide2":
                 self.__uicompiler = Utilities.generatePySideToolPath(
                     'pyside2-uic', variant=2)
--- a/eric6/Project/ProjectResourcesBrowser.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Project/ProjectResourcesBrowser.py	Mon Apr 12 19:21:40 2021 +0200
@@ -648,9 +648,8 @@
         self.buf = ""
         
         if self.project.getProjectLanguage() == "Python3":
-            if self.project.getProjectType() in ["PyQt5", "PyQt5C"]:
-                self.rccCompiler = Utilities.generatePyQtToolPath('pyrcc5')
-            elif self.project.getProjectType() in ["E6Plugin"]:
+            if self.project.getProjectType() in ["PyQt5", "PyQt5C",
+                                                 "E6Plugin"]:
                 self.rccCompiler = Utilities.generatePyQtToolPath('pyrcc5')
             elif self.project.getProjectType() in ["PySide2", "PySide2C"]:
                 self.rccCompiler = Utilities.generatePySideToolPath(
@@ -873,11 +872,10 @@
                     return
                 if (
                     not os.path.exists(ofn) or
-                    os.stat(ifn).st_mtime > os.stat(ofn).st_mtime
+                    os.stat(ifn).st_mtime > os.stat(ofn).st_mtime or
+                    self.__checkResourcesNewer(ifn, os.stat(ofn).st_mtime)
                 ):
                     changedResources.append(fn)
-                elif self.__checkResourcesNewer(ifn, os.stat(ofn).st_mtime):
-                    changedResources.append(fn)
             progress.setValue(len(self.project.pdata["RESOURCES"]))
             QApplication.processEvents()
             
--- a/eric6/Project/ProjectTranslationsBrowser.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Project/ProjectTranslationsBrowser.py	Mon Apr 12 19:21:40 2021 +0200
@@ -1028,12 +1028,10 @@
         else:
             return
         
-        if self.project.getProjectType() in ["PyQt5", "PyQt5C"]:
+        if self.project.getProjectType() in ["PyQt5", "PyQt5C", "E6Plugin"]:
             self.pylupdate = Utilities.generatePyQtToolPath('pylupdate5')
         elif self.project.getProjectType() in ["PyQt6", "PyQt6C"]:
             self.pylupdate = Utilities.generatePyQtToolPath('pylupdate6')
-        elif self.project.getProjectType() in ["E6Plugin"]:
-            self.pylupdate = Utilities.generatePyQtToolPath('pylupdate5')
         elif self.project.getProjectType() in ["PySide2", "PySide2C"]:
             self.pylupdate = Utilities.generatePySideToolPath(
                 'pyside2-lupdate', variant=2)
--- a/eric6/QScintilla/DocstringGenerator/PyDocstringGenerator.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/QScintilla/DocstringGenerator/PyDocstringGenerator.py	Mon Apr 12 19:21:40 2021 +0200
@@ -581,9 +581,7 @@
                 hasValue = True
             
             if colonPosition > -1:
-                if not hasValue:
-                    hasType = True
-                elif equalPosition > colonPosition:
+                if not hasValue or equalPosition > colonPosition:
                     # exception for def foo(arg1=":")
                     hasType = True
             
@@ -682,9 +680,10 @@
                 self.functionType = "staticmethod"
             elif decorator == "@classmethod":
                 self.functionType = "classmethod"
-            elif re.match(r"@(PyQt[456]\.)?(QtCore\.)?pyqtSlot", decorator):
-                self.functionType = "qtslot"
-            elif re.match(r"@(PySide[26]\.)?(QtCore\.)?Slot", decorator):
+            elif (
+                re.match(r"@(PyQt[456]\.)?(QtCore\.)?pyqtSlot", decorator) or
+                re.match(r"@(PySide[26]\.)?(QtCore\.)?Slot", decorator)
+            ):
                 self.functionType = "qtslot"
         
         text = "".join(textList).strip()
--- a/eric6/QScintilla/Editor.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/QScintilla/Editor.py	Mon Apr 12 19:21:40 2021 +0200
@@ -688,16 +688,12 @@
         
         if not bindName and line0.startswith("#!"):
             # #! marker detection
-            if "python3" in line0:
-                bindName = "dummy.py"
-                self.filetype = "Python3"
-            elif "python" in line0:
-                bindName = "dummy.py"
-                self.filetype = "Python3"
-            elif "pypy3" in line0:
-                bindName = "dummy.py"
-                self.filetype = "Python3"
-            elif "pypy" in line0:
+            if (
+                "python3" in line0 or
+                "python" in line0 or
+                "pypy3" in line0 or
+                "pypy" in line0
+            ):
                 bindName = "dummy.py"
                 self.filetype = "Python3"
             elif ("/bash" in line0 or "/sh" in line0):
@@ -5042,11 +5038,10 @@
                 self.__acTimer.start()
             else:
                 self.__autoComplete(auto, context)
-        elif not auto:
-            self.autoCompleteQScintilla()
         elif (
-            self.autoCompletionSource() !=
-            QsciScintilla.AutoCompletionSource.AcsNone
+            not auto or
+            (self.autoCompletionSource() !=
+             QsciScintilla.AutoCompletionSource.AcsNone)
         ):
             self.autoCompleteQScintilla()
     
@@ -7901,13 +7896,10 @@
         """
         if self.__spellCheckStringsOnly:
             if (
-                self.__fileNameExtension in
-                Preferences.getEditor("FullSpellCheckExtensions")
-            ):
-                return True
-            elif (
-                not self.__fileNameExtension and
-                Preferences.getEditor("FullSpellCheckUnknown")
+                (self.__fileNameExtension in
+                 Preferences.getEditor("FullSpellCheckExtensions")) or
+                (not self.__fileNameExtension and
+                 Preferences.getEditor("FullSpellCheckUnknown"))
             ):
                 return True
             else:
--- a/eric6/QScintilla/MiniEditor.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/QScintilla/MiniEditor.py	Mon Apr 12 19:21:40 2021 +0200
@@ -3459,10 +3459,10 @@
         
         if not bindName and line0.startswith("#!"):
             # #! marker detection
-            if "python3" in line0:
-                bindName = "dummy.py"
-                self.filetype = "Python3"
-            elif "python" in line0:
+            if (
+                "python3" in line0 or
+                "python" in line0
+            ):
                 bindName = "dummy.py"
                 self.filetype = "Python3"
             elif ("/bash" in line0 or "/sh" in line0):
--- a/eric6/QScintilla/TypingCompleters/CompleterPython.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/QScintilla/TypingCompleters/CompleterPython.py	Mon Apr 12 19:21:40 2021 +0200
@@ -277,12 +277,12 @@
         while ifLine >= 0:
             txt = self.editor.text(ifLine)
             edInd = self.editor.indentation(ifLine)
-            if rxIndex(self.__elseRX, txt) == 0 and edInd <= indentation:
-                indentation = edInd - 1
-            elif (
-                rxIndex(self.__elifRX, txt) == 0 and
-                edInd == indentation and
-                edInd == prevInd
+            if (
+                (rxIndex(self.__elseRX, txt) == 0 and
+                 edInd <= indentation) or
+                (rxIndex(self.__elifRX, txt) == 0 and
+                 edInd == indentation and
+                 edInd == prevInd)
             ):
                 indentation = edInd - 1
             elif (
@@ -383,14 +383,11 @@
         while curLine >= 0:
             txt = self.editor.text(curLine)
             if (
-                (rxIndex(self.__defSelfRX, txt) == 0 or
-                 rxIndex(self.__defClsRX, txt) == 0) and
-                self.editor.indentation(curLine) == indentation
-            ):
-                return True
-            elif (
-                rxIndex(self.__classRX, txt) == 0 and
-                self.editor.indentation(curLine) < indentation
+                ((rxIndex(self.__defSelfRX, txt) == 0 or
+                  rxIndex(self.__defClsRX, txt) == 0) and
+                 self.editor.indentation(curLine) == indentation) or
+                (rxIndex(self.__classRX, txt) == 0 and
+                 self.editor.indentation(curLine) < indentation)
             ):
                 return True
             elif (
--- a/eric6/QScintilla/TypingCompleters/CompleterYaml.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/QScintilla/TypingCompleters/CompleterYaml.py	Mon Apr 12 19:21:40 2021 +0200
@@ -93,12 +93,6 @@
                 self.editor.setSelection(line, col, line, col + 1)
                 self.editor.removeSelectedText()
         
-        # dash
-        # insert blank
-        elif char == '-' and self.__insertBlankDash:
-            self.editor.insert(' ')
-            self.editor.setCursorPosition(line, col + 1)
-        
         # colon
         # 1. skip colon if not last character
         # 2. insert blank if last character
@@ -112,15 +106,13 @@
                 self.editor.insert(' ')
                 self.editor.setCursorPosition(line, col + 1)
         
-        # question mark
+        # dash, question mark or comma
         # insert blank
-        elif char == '?' and self.__insertBlankQuestion:
-            self.editor.insert(' ')
-            self.editor.setCursorPosition(line, col + 1)
-        
-        # comma
-        # insert blank
-        elif char == ',' and self.__insertBlankComma:
+        elif (
+            (char == '-' and self.__insertBlankDash) or
+            (char == '?' and self.__insertBlankQuestion) or
+            (char == ',' and self.__insertBlankComma)
+        ):
             self.editor.insert(' ')
             self.editor.setCursorPosition(line, col + 1)
         
--- a/eric6/Snapshot/SnapshotWaylandGrabber.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Snapshot/SnapshotWaylandGrabber.py	Mon Apr 12 19:21:40 2021 +0200
@@ -56,6 +56,7 @@
         @rtype tuple of SnapshotModes
         """
         if DBusAvailable and Globals.isKdeDesktop():
+            # __IGNORE_WARNING_Y114__
             return (
                 SnapshotModes.Fullscreen,
                 SnapshotModes.SelectedScreen,
--- a/eric6/UI/Browser.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/UI/Browser.py	Mon Apr 12 19:21:40 2021 +0200
@@ -466,7 +466,12 @@
             self._activating = True
             for itm in itmList:
                 if isinstance(itm, BrowserFileItem):
-                    if itm.isPython3File():
+                    if (
+                        itm.isPython3File() or
+                        itm.isIdlFile() or
+                        itm.isProtobufFile() or
+                        itm.isResourcesFile()
+                    ):
                         self.sourceFile[str].emit(itm.fileName())
                     elif itm.isRubyFile():
                         self.sourceFile[str, int, str].emit(
@@ -485,12 +490,6 @@
                         self.projectFile.emit(itm.fileName())
                     elif itm.isMultiProjectFile():
                         self.multiProjectFile.emit(itm.fileName())
-                    elif itm.isIdlFile():
-                        self.sourceFile[str].emit(itm.fileName())
-                    elif itm.isProtobufFile():
-                        self.sourceFile[str].emit(itm.fileName())
-                    elif itm.isResourcesFile():
-                        self.sourceFile[str].emit(itm.fileName())
                     elif itm.isSvgFile():
                         self.svgFile.emit(itm.fileName())
                     elif itm.isPixmapFile():
--- a/eric6/UI/UserInterface.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/UI/UserInterface.py	Mon Apr 12 19:21:40 2021 +0200
@@ -7056,15 +7056,13 @@
                         "Updates/LastCheckDate", QDate(1970, 1, 1))
                     if lastCheck.isValid():
                         now = QDate.currentDate()
-                        if period == 2 and lastCheck.day() == now.day():
-                            # daily
-                            return
-                        elif period == 3 and lastCheck.daysTo(now) < 7:
-                            # weekly
-                            return
-                        elif period == 4 and (lastCheck.daysTo(now) <
-                                              lastCheck.daysInMonth()):
-                            # monthly
+                        if (
+                            (period == 2 and lastCheck.day() == now.day()) or
+                            (period == 3 and lastCheck.daysTo(now) < 7) or
+                            (period == 4 and (lastCheck.daysTo(now) <
+                                              lastCheck.daysInMonth()))
+                        ):
+                            # daily, weekly, monthly
                             return
         
         self.__inVersionCheck = True
--- a/eric6/Utilities/ClassBrowsers/idlclbr.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Utilities/ClassBrowsers/idlclbr.py	Mon Apr 12 19:21:40 2021 +0200
@@ -358,10 +358,7 @@
                 f.setEndLine(endline)
             classstack.append((f, thisindent))  # Marker for nested fns
 
-        elif m.start("String") >= 0:
-            pass
-
-        elif m.start("Comment") >= 0:
+        elif m.start("String") >= 0 or m.start("Comment") >= 0:
             pass
 
         elif m.start("Interface") >= 0:
--- a/eric6/Utilities/ClassBrowsers/protoclbr.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Utilities/ClassBrowsers/protoclbr.py	Mon Apr 12 19:21:40 2021 +0200
@@ -323,10 +323,7 @@
                 f.setEndLine(endline)
             classstack.append((f, thisindent))  # Marker for nested fns
 
-        elif m.start("String") >= 0:
-            pass
-
-        elif m.start("Comment") >= 0:
+        elif m.start("String") >= 0 or m.start("Comment") >= 0:
             pass
 
         elif m.start("Message") >= 0:
--- a/eric6/Utilities/ClassBrowsers/rbclbr.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/Utilities/ClassBrowsers/rbclbr.py	Mon Apr 12 19:21:40 2021 +0200
@@ -384,13 +384,12 @@
             cur_obj = f
             classstack.append((f, thisindent))  # Marker for nested fns
 
-        elif m.start("String") >= 0:
-            pass
-
-        elif m.start("Comment") >= 0:
-            pass
-
-        elif m.start("ClassIgnored") >= 0:
+        elif (
+            m.start("String") >= 0 or
+            m.start("Comment") >= 0 or
+            m.start("ClassIgnored") >= 0 or
+            m.start("BeginEnd") >= 0
+        ):
             pass
 
         elif m.start("Class") >= 0:
@@ -602,9 +601,6 @@
                 else:
                     indent = 0
         
-        elif m.start("BeginEnd") >= 0:
-            pass
-        
         elif m.start("CodingLine") >= 0:
             # a coding statement
             coding = m.group("Coding")
--- a/eric6/WebBrowser/AutoScroll/AutoScroller.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/WebBrowser/AutoScroll/AutoScroller.py	Mon Apr 12 19:21:40 2021 +0200
@@ -101,9 +101,10 @@
             
             if view:
                 # test for start
-                if self.__view != view and middleButton:
-                    return self.__showIndicator(view, evt.pos())
-                elif not self.__indicator.isVisible() and middleButton:
+                if (
+                    middleButton and
+                    (self.__view != view or not self.__indicator.isVisible())
+                ):
                     return self.__showIndicator(view, evt.pos())
                 
                 # test for stop
--- a/eric6/WebBrowser/Network/NetworkUrlInterceptor.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/WebBrowser/Network/NetworkUrlInterceptor.py	Mon Apr 12 19:21:40 2021 +0200
@@ -135,13 +135,15 @@
         # see: https://wiki.mozilla.org/Security/Referrer
         # see: https://www.w3.org/TR/referrer-policy/
         
-        if self.__sendReferer == 0:
+        if (
+            self.__sendReferer == 0 or
             # never send referer header
-            info.setHttpHeader(b"Referer", b"")
-        elif (self.__sendReferer == 1 and
-              info.navigationType() !=
-              QWebEngineUrlRequestInfo.NavigationType.NavigationTypeLink):
+            
+            (self.__sendReferer == 1 and
+             (info.navigationType() !=
+              QWebEngineUrlRequestInfo.NavigationType.NavigationTypeLink))
             # send referer header only on click
+        ):
             info.setHttpHeader(b"Referer", b"")
         else:
             # send referer header always applying further policies
--- a/eric6/WebBrowser/Passwords/PasswordReader.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/WebBrowser/Passwords/PasswordReader.py	Mon Apr 12 19:21:40 2021 +0200
@@ -133,9 +133,7 @@
                 if self.name() == "Form":
                     self.__loginForms[key] = form
                     continue
-                elif self.name() == "PostData":
-                    continue
-                elif self.name() in ["Elements", "Element"]:
+                elif self.name() in ["PostData", "Elements", "Element"]:
                     continue
                 else:
                     break
--- a/eric6/eric6_browser.py	Mon Apr 12 19:05:23 2021 +0200
+++ b/eric6/eric6_browser.py	Mon Apr 12 19:21:40 2021 +0200
@@ -104,8 +104,11 @@
         elif arg.startswith("--name="):
             name = arg.replace("--name=", "")
             argv.remove(arg)
-        elif arg.startswith("--newtab="):
-            # only used for single application client
+        elif (
+            arg.startswith(("--newtab=", "--")) or
+            arg == "--quiet"
+        ):
+            # only needed until we reach this point
             argv.remove(arg)
         elif arg == "--private":
             private = True
@@ -113,14 +116,9 @@
         elif arg == "--qthelp":
             qthelp = True
             argv.remove(arg)
-        elif arg == "--quiet":
-            # only needed until we reach this point
-            argv.remove(arg)
         elif arg == "--single":
             single = True
             argv.remove(arg)
-        elif arg.startswith("--"):
-            argv.remove(arg)
     
     try:
         home = argv[1]

eric ide

mercurial