Wed, 21 Apr 2021 19:40:50 +0200
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
--- a/eric6/HexEdit/HexEditChunks.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/HexEdit/HexEditChunks.py Wed Apr 21 19:40:50 2021 +0200 @@ -301,10 +301,11 @@ # position is out of range, do nothing return False - if pos == self.__size: - chunkIdx = self.__getChunkIndex(pos - 1) - else: - chunkIdx = self.__getChunkIndex(pos) + chunkIdx = ( + self.__getChunkIndex(pos - 1) + if pos == self.__size else + self.__getChunkIndex(pos) + ) chunk = self.__chunks[chunkIdx] posInChunk = pos - chunk.absPos chunk.data.insert(posInChunk, data)
--- a/eric6/HexEdit/HexEditMainWindow.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/HexEdit/HexEditMainWindow.py Wed Apr 21 19:40:50 2021 +0200 @@ -1045,10 +1045,11 @@ @return flag indicating success @rtype bool """ - if not self.__fileName: - ok = self.__saveHexFileAs() - else: - ok = self.__saveHexDataFile(self.__fileName) + ok = ( + self.__saveHexDataFile(self.__fileName) + if self.__fileName else + self.__saveHexFileAs() + ) if ok: self.__editor.undoStack().setClean() @@ -1186,10 +1187,11 @@ .format(fileName, file.errorString())) return - if selectionOnly: - readableData = self.__editor.selectionToReadableString() - else: - readableData = self.__editor.toReadableString() + readableData = ( + self.__editor.selectionToReadableString() + if selectionOnly else + self.__editor.toReadableString() + ) res = file.write(readableData.encode("latin1")) != -1 file.close() @@ -1235,10 +1237,11 @@ # insert filename into list of recently opened files self.__addToRecentList(fileName) - if not self.__fileName: - shownName = self.tr("Untitled") - else: - shownName = self.__strippedName(self.__fileName) + shownName = ( + self.tr("Untitled") + if not self.__fileName else + self.__strippedName(self.__fileName) + ) self.setWindowTitle(self.tr("{0}[*] - {1}") .format(shownName, self.tr("Hex Editor"))) @@ -1320,10 +1323,11 @@ """ self.__replaceWidget.hide() self.__gotoWidget.hide() - if self.__editor.hasSelection(): - txt = self.__editor.selectionToHexString() - else: - txt = "" + txt = ( + self.__editor.selectionToHexString() + if self.__editor.hasSelection() else + "" + ) self.__searchWidget.show(txt) def __replace(self): @@ -1332,10 +1336,11 @@ """ self.__searchWidget.hide() self.__gotoWidget.hide() - if self.__editor.hasSelection(): - txt = self.__editor.selectionToHexString() - else: - txt = "" + txt = ( + self.__editor.selectionToHexString() + if self.__editor.hasSelection() else + "" + ) self.__replaceWidget.show(txt) def __goto(self):
--- a/eric6/IconEditor/IconEditorGrid.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/IconEditor/IconEditorGrid.py Wed Apr 21 19:40:50 2021 +0200 @@ -613,14 +613,16 @@ x, y = self.__imageCoordinates(pos) isize = self.__image.size() - if x + self.__clipboardSize.width() <= isize.width(): - sx = self.__clipboardSize.width() - else: - sx = isize.width() - x - if y + self.__clipboardSize.height() <= isize.height(): - sy = self.__clipboardSize.height() - else: - sy = isize.height() - y + sx = ( + self.__clipboardSize.width() + if x + self.__clipboardSize.width() <= isize.width() else + isize.width() - x + ) + sy = ( + self.__clipboardSize.height() + if y + self.__clipboardSize.height() <= isize.height() else + isize.height() - y + ) self.__pasteRect = QRect(QPoint(x, y), QSize(sx - 1, sy - 1))
--- a/eric6/IconEditor/IconEditorPalette.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/IconEditor/IconEditorPalette.py Wed Apr 21 19:40:50 2021 +0200 @@ -34,10 +34,11 @@ """ super().__init__(parent) - if self.layoutDirection == Qt.Orientation.Horizontal: - direction = QBoxLayout.Direction.LeftToRight - else: - direction = QBoxLayout.Direction.TopToBottom + direction = ( + QBoxLayout.Direction.LeftToRight + if self.layoutDirection == Qt.Orientation.Horizontal else + QBoxLayout.Direction.TopToBottom + ) self.__layout = QBoxLayout(direction, self) self.setLayout(self.__layout)
--- a/eric6/IconEditor/IconEditorWindow.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/IconEditor/IconEditorWindow.py Wed Apr 21 19:40:50 2021 +0200 @@ -1224,10 +1224,11 @@ """ self.__fileName = fileName - if not self.__fileName: - shownName = self.tr("Untitled") - else: - shownName = self.__strippedName(self.__fileName) + shownName = ( + self.__strippedName(self.__fileName) + if self.__fileName else + self.tr("Untitled") + ) self.setWindowTitle(self.tr("{0}[*] - {1}") .format(shownName, self.tr("Icon Editor")))
--- a/eric6/MicroPython/MicroPythonDevices.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/MicroPython/MicroPythonDevices.py Wed Apr 21 19:40:50 2021 +0200 @@ -272,11 +272,12 @@ a pixmap (iconFormat == False) @rtype QIcon or QPixmap """ - if boardName in SupportedBoards: - iconName = SupportedBoards[boardName]["icon"] - else: + iconName = ( + SupportedBoards[boardName]["icon"] + if boardName in SupportedBoards else # return a generic MicroPython icon - iconName = "micropython48" + "micropython48" + ) if iconFormat: return UI.PixmapCache.getIcon(iconName)
--- a/eric6/MicroPython/MicroPythonFileManager.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/MicroPython/MicroPythonFileManager.py Wed Apr 21 19:40:50 2021 +0200 @@ -318,10 +318,11 @@ for sourceBasename in toAdd: # name exists in source but not in device sourceFilename = os.path.join(hostDirectory, sourceBasename) - if deviceDirectory == "/": - destFilename = "/" + sourceBasename - else: - destFilename = deviceDirectory + "/" + sourceBasename + destFilename = ( + "/" + sourceBasename + if deviceDirectory == "/" else + deviceDirectory + "/" + sourceBasename + ) self.rsyncProgressMessage.emit( self.tr("{1}Adding <b>{0}</b>...") .format(destFilename, indentStr)) @@ -343,10 +344,11 @@ if mirror: for destBasename in toDelete: # name exists in device but not local, delete - if deviceDirectory == "/": - destFilename = "/" + sourceBasename - else: - destFilename = deviceDirectory + "/" + destBasename + destFilename = ( + "/" + sourceBasename + if deviceDirectory == "/" else + deviceDirectory + "/" + destBasename + ) self.rsyncProgressMessage.emit( self.tr("{1}Removing <b>{0}</b>...") .format(destFilename, indentStr)) @@ -363,10 +365,11 @@ sourceStat = sourceDict[sourceBasename] destStat = destinationDict[sourceBasename] sourceFilename = os.path.join(hostDirectory, sourceBasename) - if deviceDirectory == "/": - destFilename = "/" + sourceBasename - else: - destFilename = deviceDirectory + "/" + sourceBasename + destFilename = ( + "/" + sourceBasename + if deviceDirectory == "/" else + deviceDirectory + "/" + sourceBasename + ) destMode = destStat[0] if os.path.isdir(sourceFilename): if stat.S_ISDIR(destMode):
--- a/eric6/MicroPython/MicroPythonFileManagerWidget.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/MicroPython/MicroPythonFileManagerWidget.py Wed Apr 21 19:40:50 2021 +0200 @@ -251,10 +251,11 @@ mode2string(s[0]), str(s[6]), mtime2string(s[8])) for f, s in filesStatList] - if localDevice: - fileTreeWidget = self.deviceFileTreeWidget - else: - fileTreeWidget = self.localFileTreeWidget + fileTreeWidget = ( + self.deviceFileTreeWidget + if localDevice else + self.localFileTreeWidget + ) fileTreeWidget.clear() for item in filesList: itm = QTreeWidgetItem(fileTreeWidget, item)
--- a/eric6/MicroPython/MicroPythonWidget.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/MicroPython/MicroPythonWidget.py Wed Apr 21 19:40:50 2021 +0200 @@ -1429,10 +1429,11 @@ name = self.tr("unknown") else: name = impInfo["name"] - if impInfo["version"] == "unknown": - version = self.tr("unknown") - else: - version = impInfo["version"] + version = ( + self.tr("unknown") + if impInfo["version"] == "unknown" else + impInfo["version"] + ) E5MessageBox.information( self,
--- a/eric6/MicroPython/MicrobitDevices.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/MicroPython/MicrobitDevices.py Wed Apr 21 19:40:50 2021 +0200 @@ -306,10 +306,11 @@ if not aw: return - if scriptName: - title = self.tr("Save Script as '{0}'").format(scriptName) - else: - title = self.tr("Save Script") + title = ( + self.tr("Save Script as '{0}'").format(scriptName) + if scriptName else + self.tr("Save Script") + ) if not (aw.isPyFile() or aw.isMicroPythonFile()): yes = E5MessageBox.yesNo(
--- a/eric6/MultiProject/MultiProject.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/MultiProject/MultiProject.py Wed Apr 21 19:40:50 2021 +0200 @@ -616,13 +616,12 @@ @rtype bool """ defaultFilter = self.tr("Multi Project Files (*.emj)") - if self.ppath: - defaultPath = self.ppath - else: - defaultPath = ( - Preferences.getMultiProject("Workspace") or - Utilities.getHomeDir() - ) + defaultPath = ( + self.ppath + if self.ppath else + (Preferences.getMultiProject("Workspace") or + Utilities.getHomeDir()) + ) fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self.parent(), self.tr("Save multiproject as"),
--- a/eric6/Network/IRC/IrcChannelWidget.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Network/IRC/IrcChannelWidget.py Wed Apr 21 19:40:50 2021 +0200 @@ -1392,10 +1392,11 @@ fname = Utilities.toNativeSeparators(fname) try: - if ext.lower() in ["htm", "html"]: - txt = self.messages.toHtml() - else: - txt = self.messages.toPlainText() + txt = ( + self.messages.toHtml() + if ext.lower() in ["htm", "html"] else + self.messages.toPlainText() + ) with open(fname, "w", encoding="utf-8") as f: f.write(txt) except OSError as err:
--- a/eric6/Network/IRC/IrcIdentitiesEditDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Network/IRC/IrcIdentitiesEditDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -337,15 +337,14 @@ if inUse: break - if inUse: - msg = self.tr( - """This identity is in use. If you remove it, the network""" - """ settings using it will fall back to the default""" - """ identity. Should it be deleted anyway?""") - else: - msg = self.tr( - """Do you really want to delete all information for""" - """ this identity?""") + msg = ( + self.tr("This identity is in use. If you remove it, the network" + " settings using it will fall back to the default" + " identity. Should it be deleted anyway?") + if inUse else + self.tr("Do you really want to delete all information for" + " this identity?") + ) res = E5MessageBox.yesNo( self, self.tr("Delete Identity"),
--- a/eric6/Network/IRC/IrcNetworkWidget.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Network/IRC/IrcNetworkWidget.py Wed Apr 21 19:40:50 2021 +0200 @@ -444,10 +444,11 @@ fname = Utilities.toNativeSeparators(fname) try: - if ext.lower() in ["htm", "html"]: - txt = self.messages.toHtml() - else: - txt = self.messages.toPlainText() + txt = ( + self.messages.toHtml() + if ext.lower() in ["htm", "html"] else + self.messages.toPlainText() + ) with open(fname, "w", encoding="utf-8") as f: f.write(txt) except OSError as err:
--- a/eric6/PipInterface/Pip.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/PipInterface/Pip.py Wed Apr 21 19:40:50 2021 +0200 @@ -156,10 +156,11 @@ pip = "pip.ini" if Globals.isWindowsPlatform() else "pip.conf" venvManager = e5App().getObject("VirtualEnvManager") - if venvManager.isGlobalEnvironment(venvName): - venvDirectory = os.path.dirname(self.getUserConfig()) - else: - venvDirectory = venvManager.getVirtualenvDirectory(venvName) + venvDirectory = ( + os.path.dirname(self.getUserConfig()) + if venvManager.isGlobalEnvironment(venvName) else + venvManager.getVirtualenvDirectory(venvName) + ) config = os.path.join(venvDirectory, pip) if venvDirectory else "" @@ -239,10 +240,11 @@ return dia = PipDialog(self.tr('Install PIP')) - if userSite: - commands = [(interpreter, ["-m", "ensurepip", "--user"])] - else: - commands = [(interpreter, ["-m", "ensurepip"])] + commands = ( + [(interpreter, ["-m", "ensurepip", "--user"])] + if userSite else + [(interpreter, ["-m", "ensurepip"])] + ) if Preferences.getPip("PipSearchIndex"): indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" args = ["-m", "pip", "install", "--index-url", indexUrl, @@ -297,8 +299,8 @@ if p.lower() in ["pyqt5", "pyqt5-sip", "pyqtwebengine", "qscintilla", "sip"]] - if bool(pyqtPackages): - abort = not E5MessageBox.yesNo( + abort = ( + not E5MessageBox.yesNo( None, self.tr("Upgrade Packages"), self.tr( @@ -306,8 +308,9 @@ """ not work for the current instance of Python ({0}).""" """ Do you want to continue?""").format(sys.executable), icon=E5MessageBox.Critical) - else: - abort = False + if bool(pyqtPackages) else + False + ) return abort @@ -500,10 +503,11 @@ @return index URL for PyPI @rtype str """ - if Preferences.getPip("PipSearchIndex"): - indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" - else: - indexUrl = Pip.DefaultIndexUrlSimple + indexUrl = ( + Preferences.getPip("PipSearchIndex") + "/simple" + if Preferences.getPip("PipSearchIndex") else + Pip.DefaultIndexUrlSimple + ) return indexUrl @@ -514,10 +518,11 @@ @return index URL for XML RPC calls @rtype str """ - if Preferences.getPip("PipSearchIndex"): - indexUrl = Preferences.getPip("PipSearchIndex") + "/pypi" - else: - indexUrl = Pip.DefaultIndexUrlPypi + indexUrl = ( + Preferences.getPip("PipSearchIndex") + "/pypi" + if Preferences.getPip("PipSearchIndex") else + Pip.DefaultIndexUrlPypi + ) return indexUrl @@ -528,10 +533,11 @@ @return index URL for XML RPC calls @rtype str """ - if Preferences.getPip("PipSearchIndex"): - indexUrl = Preferences.getPip("PipSearchIndex") + "/search/" - else: - indexUrl = Pip.DefaultIndexUrlSearch + indexUrl = ( + Preferences.getPip("PipSearchIndex") + "/search/" + if Preferences.getPip("PipSearchIndex") else + Pip.DefaultIndexUrlSearch + ) return indexUrl
--- a/eric6/PipInterface/PipFreezeDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/PipInterface/PipFreezeDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -112,14 +112,15 @@ """ Private slot to refresh the displayed list. """ - if self.__requirementsEdited: - ok = E5MessageBox.yesNo( + ok = ( + E5MessageBox.yesNo( self, self.tr("Generate Requirements"), self.tr("""The requirements were changed. Do you want""" """ to overwrite these changes?""")) - else: - ok = True + if self.__requirementsEdited else + True + ) if ok: self.start(self.__environmentName)
--- a/eric6/PipInterface/PipPackageDetailsDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/PipInterface/PipPackageDetailsDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -132,11 +132,11 @@ self.__formatUploadDate(download["upload_time"]), self.__formatSize(download["size"]), ]) - if download["has_sig"]: - pgpLink = ' (<a href="{0}">pgp</a>)'.format( - download["url"] + ".asc") - else: - pgpLink = "" + pgpLink = ( + ' (<a href="{0}">pgp</a>)'.format(download["url"] + ".asc") + if download["has_sig"] else + "" + ) urlLabel = QLabel('<a href="{0}#md5={2}">{1}</a>{3}'.format( download["url"], download["filename"], download["md5_digest"], pgpLink))
--- a/eric6/PluginManager/PluginInstallDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/PluginManager/PluginInstallDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -563,10 +563,11 @@ @param pluginFileName name of the plugin file (string) @param packageName name of the plugin package (string) """ - if packageName in ("", "None"): - packageDir = None - else: - packageDir = os.path.join(destination, packageName) + packageDir = ( + None + if packageName in ("", "None") else + os.path.join(destination, packageName) + ) pluginFile = os.path.join(destination, pluginFileName) with contextlib.suppress(OSError, os.error):
--- a/eric6/PluginManager/PluginManager.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/PluginManager/PluginManager.py Wed Apr 21 19:40:50 2021 +0200 @@ -587,10 +587,11 @@ """ try: try: - if onDemand: - module = self.__onDemandInactiveModules[name] - else: - module = self.__inactiveModules[name] + module = ( + self.__onDemandInactiveModules[name] + if onDemand else + self.__inactiveModules[name] + ) except KeyError: return None @@ -695,10 +696,11 @@ on demand plugin (boolean) """ try: - if onDemand: - module = self.__onDemandActiveModules[name] - else: - module = self.__activeModules[name] + module = ( + self.__onDemandActiveModules[name] + if onDemand else + self.__activeModules[name] + ) except KeyError: return
--- a/eric6/PluginManager/PluginRepositoryDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/PluginManager/PluginRepositoryDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -935,14 +935,13 @@ for pluginName in downloads: downloads[pluginName].sort(key=lambda x: x[1]) - if ( - pluginName in hiddenPlugins and - not Preferences.getPluginManager("KeepHidden") - ): - removeFiles = [f[0] for f in downloads[pluginName]] - else: - removeFiles = [f[0] for f in downloads[pluginName][ + removeFiles = ( + [f[0] for f in downloads[pluginName]] + if (pluginName in hiddenPlugins and + not Preferences.getPluginManager("KeepHidden")) else + [f[0] for f in downloads[pluginName][ :-Preferences.getPluginManager("KeepGenerations")]] + ) for removeFile in removeFiles: try: os.remove(os.path.join(downloadPath, removeFile))
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py Wed Apr 21 19:40:50 2021 +0200 @@ -288,11 +288,12 @@ src = "".join(source) try: - if sys.version_info >= (3, 8): + tree = ( + ast.parse(src, filename, 'exec', type_comments=True) # need the 'type_comments' parameter to include type annotations - tree = ast.parse(src, filename, 'exec', type_comments=True) - else: - tree = ast.parse(src, filename, 'exec') + if sys.version_info >= (3, 8) else + ast.parse(src, filename, 'exec') + ) return None, None, tree except (SyntaxError, TypeError): exc_type, exc = sys.exc_info()[:2]
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -1154,10 +1154,11 @@ @return eol string @rtype str """ - if self.__project.isOpen() and self.__project.isProjectFile(fn): - eol = self.__project.getEolString() - else: - eol = Utilities.linesep() + eol = ( + self.__project.getEolString() + if self.__project.isOpen() and self.__project.isProjectFile(fn) + else Utilities.linesep() + ) return eol @pyqtSlot() @@ -1978,12 +1979,11 @@ @param selectedFutures comma separated list of expected future imports @type str """ - if selectedFutures: - expectedImports = [ - i.strip() for i in selectedFutures.split(",") - if bool(i.strip())] - else: - expectedImports = [] + expectedImports = ( + [i.strip() for i in selectedFutures.split(",") if bool(i.strip())] + if selectedFutures else + [] + ) for row in range(self.futuresList.count()): itm = self.futuresList.item(row) if itm.text() in expectedImports: @@ -2077,13 +2077,12 @@ categories @type str """ - if enabledCategories: - enabledCategoriesList = [ - c.strip() for c in enabledCategories.split(",") - if bool(c.strip())] - else: - enabledCategoriesList = list( - CodeStyleCheckerDialog.checkCategories.keys()) + enabledCategoriesList = ( + [c.strip() for c in enabledCategories.split(",") + if bool(c.strip())] + if enabledCategories else + list(CodeStyleCheckerDialog.checkCategories.keys()) + ) for row in range(self.categoriesList.count()): itm = self.categoriesList.item(row) if itm.data(Qt.ItemDataRole.UserRole) in enabledCategoriesList: @@ -2237,12 +2236,11 @@ visibleChildren = topItem.childCount() for childIndex in range(topItem.childCount()): childItem = topItem.child(childIndex) - if selectedMessageCode: - hideChild = ( - childItem.data(0, self.codeRole) != selectedMessageCode - ) - else: - hideChild = False + hideChild = ( + childItem.data(0, self.codeRole) != selectedMessageCode + if selectedMessageCode else + False + ) childItem.setHidden(hideChild) if hideChild: visibleChildren -= 1
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py Wed Apr 21 19:40:50 2021 +0200 @@ -1432,10 +1432,11 @@ # goes past the end of the physical line. This happens in cases like, # foo(bar\n=None) col = min(pos, len(text) - 1) - if text[col].strip(): - newText = text - else: - newText = text[:col].rstrip() + text[col:].lstrip() + newText = ( + text + if text[col].strip() else + text[:col].rstrip() + text[col:].lstrip() + ) # There could be an escaped newline if newText.endswith(('=\\\n', '=\\\r\n', '=\\\r')):
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/DocStyle/DocStyleChecker.py Wed Apr 21 19:40:50 2021 +0200 @@ -383,14 +383,16 @@ .replace("u'''", "", 1) .replace("'''", "") .strip()) - if len(lines) > 1: - line1 = lines[1].strip().replace('"""', "").replace("'''", "") - else: - line1 = "" - if len(lines) > 2: - line2 = lines[2].strip().replace('"""', "").replace("'''", "") - else: - line2 = "" + line1 = ( + lines[1].strip().replace('"""', "").replace("'''", "") + if len(lines) > 1 else + "" + ) + line2 = ( + lines[2].strip().replace('"""', "").replace("'''", "") + if len(lines) > 2 else + "" + ) if line0: lineno = 0 summaries.append(line0) @@ -793,10 +795,11 @@ return indent = min(len(line) - len(line.strip()) for line in nonEmptyLines) - if context.contextType() == "module": - expectedIndent = 0 - else: - expectedIndent = len(context.indent()) + 4 + expectedIndent = ( + 0 + if context.contextType() == "module" else + len(context.indent()) + 4 + ) if indent != expectedIndent: self.__error(docstringContext.start(), 0, "D122")
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/djangoXssVulnerability.py Wed Apr 21 19:40:50 2021 +0200 @@ -181,10 +181,11 @@ elif isinstance(node, ast.With): for withitem in node.items: varId = getattr(withitem.optional_vars, 'id', None) - if varId == self.__varName.id: - assigned = node - else: - assigned = self.isAssignedIn(node.body) + assigned = ( + node + if varId == self.__varName.id else + self.isAssignedIn(node.body) + ) elif isinstance(node, ast.Try): assigned = [] assigned.extend(self.isAssignedIn(node.body))
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedTmp.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedTmp.py Wed Apr 21 19:40:50 2021 +0200 @@ -44,10 +44,11 @@ @param config dictionary with configuration data @type dict """ - if config and "hardcoded_tmp_directories" in config: - tmpDirs = config["hardcoded_tmp_directories"] - else: - tmpDirs = SecurityDefaults["hardcoded_tmp_directories"] + tmpDirs = ( + config["hardcoded_tmp_directories"] + if config and "hardcoded_tmp_directories" in config else + SecurityDefaults["hardcoded_tmp_directories"] + ) if any(context.stringVal.startswith(s) for s in tmpDirs): reportError(
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionShell.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionShell.py Wed Apr 21 19:40:50 2021 +0200 @@ -109,10 +109,11 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_subprocess" in config: - functionNames = config["shell_injection_subprocess"] - else: - functionNames = SecurityDefaults["shell_injection_subprocess"] + functionNames = ( + config["shell_injection_subprocess"] + if config and "shell_injection_subprocess" in config else + SecurityDefaults["shell_injection_subprocess"] + ) if context.callFunctionNameQual in functionNames: shell, shellValue = hasShell(context) @@ -147,10 +148,11 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_subprocess" in config: - functionNames = config["shell_injection_subprocess"] - else: - functionNames = SecurityDefaults["shell_injection_subprocess"] + functionNames = ( + config["shell_injection_subprocess"] + if config and "shell_injection_subprocess" in config else + SecurityDefaults["shell_injection_subprocess"] + ) if ( context.callFunctionNameQual in functionNames and @@ -176,10 +178,11 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_subprocess" in config: - functionNames = config["shell_injection_subprocess"] - else: - functionNames = SecurityDefaults["shell_injection_subprocess"] + functionNames = ( + config["shell_injection_subprocess"] + if config and "shell_injection_subprocess" in config else + SecurityDefaults["shell_injection_subprocess"] + ) if context.callFunctionNameQual not in functionNames: shell, shellValue = hasShell(context) @@ -204,10 +207,11 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_shell" in config: - functionNames = config["shell_injection_shell"] - else: - functionNames = SecurityDefaults["shell_injection_shell"] + functionNames = ( + config["shell_injection_shell"] + if config and "shell_injection_shell" in config else + SecurityDefaults["shell_injection_shell"] + ) if ( context.callFunctionNameQual in functionNames and @@ -243,10 +247,11 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_noshell" in config: - functionNames = config["shell_injection_noshell"] - else: - functionNames = SecurityDefaults["shell_injection_noshell"] + functionNames = ( + config["shell_injection_noshell"] + if config and "shell_injection_noshell" in config else + SecurityDefaults["shell_injection_noshell"] + ) if context.callFunctionNameQual in functionNames: reportError( @@ -269,10 +274,11 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_subprocess" in config: - functionNames = config["shell_injection_subprocess"] - else: - functionNames = SecurityDefaults["shell_injection_subprocess"] + functionNames = ( + config["shell_injection_subprocess"] + if config and "shell_injection_subprocess" in config else + SecurityDefaults["shell_injection_subprocess"] + ) if config and "shell_injection_shell" in config: functionNames += config["shell_injection_shell"]
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionWildcard.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/injectionWildcard.py Wed Apr 21 19:40:50 2021 +0200 @@ -44,16 +44,17 @@ @param config dictionary with configuration data @type dict """ - if config and "shell_injection_subprocess" in config: - subProcessFunctionNames = config["shell_injection_subprocess"] - else: - subProcessFunctionNames = SecurityDefaults[ - "shell_injection_subprocess"] + subProcessFunctionNames = ( + config["shell_injection_subprocess"] + if config and "shell_injection_subprocess" in config else + SecurityDefaults["shell_injection_subprocess"] + ) - if config and "shell_injection_shell" in config: - shellFunctionNames = config["shell_injection_shell"] - else: - shellFunctionNames = SecurityDefaults["shell_injection_shell"] + shellFunctionNames = ( + config["shell_injection_shell"] + if config and "shell_injection_shell" in config else + SecurityDefaults["shell_injection_shell"] + ) vulnerableFunctions = ['chown', 'chmod', 'tar', 'rsync'] if (
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/insecureHashlibNew.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/insecureHashlibNew.py Wed Apr 21 19:40:50 2021 +0200 @@ -46,10 +46,11 @@ @param config dictionary with configuration data @type dict """ - if config and "insecure_hashes" in config: - insecureHashes = [h.lower() for h in config["insecure_hashes"]] - else: - insecureHashes = SecurityDefaults["insecure_hashes"] + insecureHashes = ( + [h.lower() for h in config["insecure_hashes"]] + if config and "insecure_hashes" in config else + SecurityDefaults["insecure_hashes"] + ) if isinstance(context.callFunctionNameQual, str): qualnameList = context.callFunctionNameQual.split('.')
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/insecureSslTls.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/insecureSslTls.py Wed Apr 21 19:40:50 2021 +0200 @@ -48,11 +48,11 @@ @param config dictionary with configuration data @type dict """ - if config and "insecure_ssl_protocol_versions" in config: - insecureProtocolVersions = config["insecure_ssl_protocol_versions"] - else: - insecureProtocolVersions = SecurityDefaults[ - "insecure_ssl_protocol_versions"] + insecureProtocolVersions = ( + config["insecure_ssl_protocol_versions"] + if config and "insecure_ssl_protocol_versions" in config else + SecurityDefaults["insecure_ssl_protocol_versions"] + ) if context.callFunctionNameQual == 'ssl.wrap_socket': if context.checkCallArgValue('ssl_version', insecureProtocolVersions): @@ -109,11 +109,11 @@ @param config dictionary with configuration data @type dict """ - if config and "insecure_ssl_protocol_versions" in config: - insecureProtocolVersions = config["insecure_ssl_protocol_versions"] - else: - insecureProtocolVersions = SecurityDefaults[ - "insecure_ssl_protocol_versions"] + insecureProtocolVersions = ( + config["insecure_ssl_protocol_versions"] + if config and "insecure_ssl_protocol_versions" in config else + SecurityDefaults["insecure_ssl_protocol_versions"] + ) for default in context.functionDefDefaultsQual: val = default.split(".")[-1]
--- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/tryExcept.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/tryExcept.py Wed Apr 21 19:40:50 2021 +0200 @@ -47,10 +47,11 @@ @param config dictionary with configuration data @type dict """ - if config and "check_typed_exception" in config: - checkTypedException = config["check_typed_exception"] - else: - checkTypedException = SecurityDefaults["check_typed_exception"] + checkTypedException = ( + config["check_typed_exception"] + if config and "check_typed_exception" in config else + SecurityDefaults["check_typed_exception"] + ) node = context.node if len(node.body) == 1: @@ -82,10 +83,11 @@ @param config dictionary with configuration data @type dict """ - if config and "check_typed_exception" in config: - checkTypedException = config["check_typed_exception"] - else: - checkTypedException = SecurityDefaults["check_typed_exception"] + checkTypedException = ( + config["check_typed_exception"] + if config and "check_typed_exception" in config else + SecurityDefaults["check_typed_exception"] + ) node = context.node if len(node.body) == 1:
--- a/eric6/Plugins/PluginTranslator.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/PluginTranslator.py Wed Apr 21 19:40:50 2021 +0200 @@ -59,12 +59,11 @@ @return dictionary containing the relevant data """ - if e5App().usesDarkPalette(): - icon = os.path.join("UiExtensionPlugins", "Translator", "icons", - "flag-dark") - else: - icon = os.path.join("UiExtensionPlugins", "Translator", "icons", - "flag-light") + icon = ( + os.path.join("UiExtensionPlugins", "Translator", "icons", "flag-dark") + if e5App().usesDarkPalette() else + os.path.join("UiExtensionPlugins", "Translator", "icons", "flag-light") + ) return { "translatorPage": [ QCoreApplication.translate("TranslatorPlugin",
--- a/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorWidget.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/UiExtensionPlugins/Translator/TranslatorWidget.py Wed Apr 21 19:40:50 2021 +0200 @@ -339,10 +339,7 @@ """ Private slot to set the state of the pronounce buttons. """ - if self.__translationEngine is not None: - hasTTS = self.__translationEngine.hasTTS() - else: - hasTTS = False + hasTTS = self.__translationEngine and self.__translationEngine.hasTTS() self.pronounceOrigButton.setEnabled( hasTTS and bool(self.origEdit.toPlainText())) self.pronounceTransButton.setEnabled(
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitCopyDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitCopyDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -80,19 +80,20 @@ Private slot to handle the button press for selecting the target via a selection dialog. """ - if os.path.isdir(self.source): - target = E5FileDialog.getExistingDirectory( + target = ( + E5FileDialog.getExistingDirectory( self, self.tr("Select target"), self.targetEdit.text(), E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) - else: - target = E5FileDialog.getSaveFileName( + if os.path.isdir(self.source) else + E5FileDialog.getSaveFileName( self, self.tr("Select target"), self.targetEdit.text(), "", E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) + ) if target: self.targetEdit.setText(Utilities.toNativeSeparators(target))
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitFetchDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitFetchDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -123,10 +123,11 @@ """ singleSelection = len(self.remoteBranchesList.selectedItems()) == 1 self.localBranchComboBox.setEnabled(singleSelection) - if singleSelection: - txt = self.remoteBranchesList.selectedItems()[0].text() - else: - txt = "" + txt = ( + self.remoteBranchesList.selectedItems()[0].text() + if singleSelection else + "" + ) index = self.localBranchComboBox.findText(txt) if index == -1: self.localBranchComboBox.setEditText(txt)
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitLogBrowserDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -728,14 +728,13 @@ for parent in parents: self.__childrenInfo[parent].append(commitId) - if self.logTree.topLevelItemCount() > 1: - topedges = ( - self.logTree.topLevelItem( - self.logTree.indexOfTopLevelItem(itm) - 1) - .data(0, self.__edgesRole) - ) - else: - topedges = None + topedges = ( + self.logTree.topLevelItem( + self.logTree.indexOfTopLevelItem(itm) - 1 + ).data(0, self.__edgesRole) + if self.logTree.topLevelItemCount() > 1 else + None + ) icon = self.__generateIcon(column, color, edges, topedges, QColor("blue"),
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -1165,10 +1165,11 @@ """ cursor = self.lDiffEdit.textCursor() startIndex, endIndex = self.__selectedLinesIndexes(self.lDiffEdit) - if cursor.hasSelection(): - patch = self.lDiffParser.createLinesPatch(startIndex, endIndex) - else: - patch = self.lDiffParser.createHunkPatch(startIndex) + patch = ( + self.lDiffParser.createLinesPatch(startIndex, endIndex) + if cursor.hasSelection() else + self.lDiffParser.createHunkPatch(startIndex) + ) if patch: patchFile = self.__tmpPatchFileName() try: @@ -1186,11 +1187,12 @@ """ cursor = self.rDiffEdit.textCursor() startIndex, endIndex = self.__selectedLinesIndexes(self.rDiffEdit) - if cursor.hasSelection(): - patch = self.rDiffParser.createLinesPatch(startIndex, endIndex, - reverse=True) - else: - patch = self.rDiffParser.createHunkPatch(startIndex) + patch = ( + self.rDiffParser.createLinesPatch(startIndex, endIndex, + reverse=True) + if cursor.hasSelection() else + self.rDiffParser.createHunkPatch(startIndex) + ) if patch: patchFile = self.__tmpPatchFileName() try: @@ -1208,10 +1210,11 @@ """ cursor = self.lDiffEdit.textCursor() startIndex, endIndex = self.__selectedLinesIndexes(self.lDiffEdit) - if cursor.hasSelection(): - title = self.tr("Revert selected lines") - else: - title = self.tr("Revert hunk") + title = ( + self.tr("Revert selected lines") + if cursor.hasSelection() else + self.tr("Revert hunk") + ) res = E5MessageBox.yesNo( self, title,
--- a/eric6/Plugins/VcsPlugins/vcsGit/GitSubmodulesUpdateOptionsDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitSubmodulesUpdateOptionsDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -55,10 +55,8 @@ else: procedure = "--merge" - if self.remoteCheckBox.isChecked(): - nofetch = self.nofetchCheckBox.isChecked() - else: - nofetch = False + nofetch = (self.remoteCheckBox.isChecked() and + self.nofetchCheckBox.isChecked()) return ( procedure,
--- a/eric6/Plugins/VcsPlugins/vcsGit/git.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/git.py Wed Apr 21 19:40:50 2021 +0200 @@ -1383,15 +1383,16 @@ ] ignoreName = os.path.join(name, Git.IgnoreFileName) - if os.path.exists(ignoreName): - res = E5MessageBox.yesNo( + res = ( + E5MessageBox.yesNo( self.__ui, self.tr("Create {0} file").format(ignoreName), self.tr("""<p>The file <b>{0}</b> exists already.""" """ Overwrite it?</p>""").format(ignoreName), icon=E5MessageBox.Warning) - else: - res = True + if os.path.exists(ignoreName) else + True + ) if res: try: # create a .gitignore file
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -227,11 +227,12 @@ """ searchRxText = self.rxEdit.text() filterTop = self.categoryCombo.currentText() == self.tr("Revision") - if filterTop and searchRxText.startswith("^"): - searchRx = re.compile( + searchRx = ( + re.compile( r"^\s*{0}".format(searchRxText[1:]), re.IGNORECASE) - else: - searchRx = re.compile(searchRxText, re.IGNORECASE) + if filterTop and searchRxText.startswith("^") else + re.compile(searchRxText, re.IGNORECASE) + ) for topIndex in range(self.signaturesList.topLevelItemCount()): topLevelItem = self.signaturesList.topLevelItem(topIndex) if filterTop:
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgArchiveDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgArchiveDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -58,12 +58,11 @@ self.tr("Compressed ZIP-Archive (*.zip)"), self.tr("Uncompressed ZIP-Archive (*.uzip)") ] - if Utilities.isWindowsPlatform(): - fileFilters = ";;".join( - self.__windowsFileFilters + self.__unixFileFilters) - else: - fileFilters = ";;".join( - self.__unixFileFilters + self.__windowsFileFilters) + fileFilters = ( + ";;".join(self.__windowsFileFilters + self.__unixFileFilters) + if Utilities.isWindowsPlatform() else + ";;".join(self.__unixFileFilters + self.__windowsFileFilters) + ) fileFilters += ";;" + self.tr("All Files (*)") self.archivePicker.setFilters(fileFilters)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -165,15 +165,17 @@ else: rev = "" - if self.dateEdit.dateTime() != self.__initDateTime: - date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") - else: - date = "" + date = ( + self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") + if self.dateEdit.dateTime() != self.__initDateTime else + "" + ) - if self.messageEdit.toPlainText(): - msg = self.messageEdit.toPlainText() - else: - msg = self.tr("Backed out changeset <{0}>.").format(rev) + msg = ( + self.messageEdit.toPlainText() + if self.messageEdit.toPlainText() else + self.tr("Backed out changeset <{0}>.").format(rev) + ) return (rev, self.mergeCheckBox.isChecked,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarkDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -59,10 +59,11 @@ """ Private slot to update the OK button. """ - if self.__mode == self.MOVE_MODE: - enabled = self.nameCombo.currentText() != "" - else: - enabled = self.nameEdit.text() != "" + enabled = ( + self.nameCombo.currentText() != "" + if self.__mode == self.MOVE_MODE else + self.nameEdit.text() != "" + ) if self.idButton.isChecked(): enabled = enabled and self.idEdit.text() != "" elif self.tagButton.isChecked(): @@ -205,9 +206,10 @@ else: rev = "" - if self.__mode == self.MOVE_MODE: - name = self.nameCombo.currentText().replace(" ", "_") - else: - name = self.nameEdit.text().replace(" ", "_") + name = ( + self.nameCombo.currentText().replace(" ", "_") + if self.__mode == self.MOVE_MODE else + self.nameEdit.text().replace(" ", "_") + ) return rev, name
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksInOutDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgBookmarksInOutDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -86,10 +86,11 @@ if self.mode not in (self.INCOMING, self.OUTGOING): raise ValueError("Bad value for mode") - if self.mode == self.INCOMING: - args = self.vcs.initCommand("incoming") - else: - args = self.vcs.initCommand("outgoing") + args = ( + self.vcs.initCommand("incoming") + if self.mode == self.INCOMING else + self.vcs.initCommand("outgoing") + ) args.append('--bookmarks')
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -140,11 +140,11 @@ self.__vcs.getPlugin().setPreferences( 'CommitAuthors', commitAuthors) - if self.dateTimeGroup.isChecked(): - dateTime = self.dateTimeEdit.dateTime().toString( - "yyyy-MM-dd hh:mm") - else: - dateTime = "" + dateTime = ( + self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm") + if self.dateTimeGroup.isChecked() else + "" + ) return ( msg,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgImportDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgImportDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -73,10 +73,11 @@ indicating to enforce the import @rtype tuple of (str, bool, str, str, str, bool, int, bool) """ - if self.dateEdit.dateTime() != self.__initDateTime: - date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") - else: - date = "" + date = ( + self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") + if self.dateEdit.dateTime() != self.__initDateTime else + "" + ) return (self.patchFilePicker.text(), self.noCommitCheckBox.isChecked(), self.messageEdit.toPlainText(), date, self.userEdit.text(),
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -947,12 +947,13 @@ self.__childrenInfo[parent].append(int(rev)) itm.setData(0, self.__incomingRole, self.commandMode == "incoming") - if self.logTree.topLevelItemCount() > 1: - topedges = self.logTree.topLevelItem( + topedges = ( + self.logTree.topLevelItem( self.logTree.indexOfTopLevelItem(itm) - 1 ).data(0, self.__edgesRole) - else: - topedges = None + if self.logTree.topLevelItemCount() > 1 else + None + ) icon = self.__generateIcon(column, color, edges, topedges, QColor(self.__branchColor(branches[0])),
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgRepoConfigDataDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgRepoConfigDataDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -104,10 +104,11 @@ defaultPushUrl.setUserName(username) if password: defaultPushUrl.setPassword(password) - if not defaultPushUrl.isValid(): - defaultPushUrl = "" - else: - defaultPushUrl = defaultPushUrl.toString() + defaultPushUrl = ( + defaultPushUrl.toString() + if defaultPushUrl.isValid() else + "" + ) return defaultUrl, defaultPushUrl
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -226,24 +226,22 @@ """ super().show() - if self.__mq: - geom = self.vcs.getPlugin().getPreferences( - "MqStatusDialogGeometry") - else: - geom = self.vcs.getPlugin().getPreferences( - "StatusDialogGeometry") + geom = ( + self.vcs.getPlugin().getPreferences("MqStatusDialogGeometry") + if self.__mq else + self.vcs.getPlugin().getPreferences("StatusDialogGeometry") + ) if geom.isEmpty(): s = QSize(800, 600) self.resize(s) else: self.restoreGeometry(geom) - if self.__mq: - diffSplitterState = self.vcs.getPlugin().getPreferences( - "MqStatusDialogSplitterState") - else: - diffSplitterState = self.vcs.getPlugin().getPreferences( - "StatusDialogSplitterState") + diffSplitterState = ( + self.vcs.getPlugin().getPreferences("MqStatusDialogSplitterState") + if self.__mq else + self.vcs.getPlugin().getPreferences("StatusDialogSplitterState") + ) if diffSplitterState is not None: self.diffSplitter.restoreState(diffSplitterState)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -43,10 +43,11 @@ self.tagCombo.clear() self.tagCombo.addItem("", False) for tag, isLocal in sorted(taglist, reverse=True): - if isLocal: - icon = UI.PixmapCache.getIcon("vcsTagLocal") - else: - icon = UI.PixmapCache.getIcon("vcsTagGlobal") + icon = ( + UI.PixmapCache.getIcon("vcsTagLocal") + if isLocal else + UI.PixmapCache.getIcon("vcsTagGlobal") + ) self.tagCombo.addItem(icon, tag, isLocal) if revision:
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -141,12 +141,11 @@ @return tuple containig the host name and the fingerprint @rtype tuple of two str """ - if self.__version < (3, 9, 0): - fingerprint = self.fingerprintEdit.text() - else: - fingerprint = "{0}:{1}".format( - self.hashComboBox.currentText(), - self.fingerprintEdit.text().strip() - ) + fingerprint = ( + self.fingerprintEdit.text() + if self.__version < (3, 9, 0) else + "{0}:{1}".format(self.hashComboBox.currentText(), + self.fingerprintEdit.text().strip()) + ) return self.hostEdit.text().strip(), fingerprint
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -53,13 +53,12 @@ """ Private slot to update the UI. """ - if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE: - enable = self.messageEdit.toPlainText() != "" - else: - enable = ( - self.nameEdit.text() != "" and - self.messageEdit.toPlainText() != "" - ) + enable = ( + self.messageEdit.toPlainText() != "" + if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE else + (self.nameEdit.text() != "" and + self.messageEdit.toPlainText() != "") + ) if self.userGroup.isChecked(): enable = ( enable and
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/queues.py Wed Apr 21 19:40:50 2021 +0200 @@ -564,13 +564,15 @@ @param isCreate flag indicating to create a new queue (boolean) """ - if isCreate: - title = self.tr("Create New Queue") - else: - title = self.tr("Rename Active Queue") from .HgQueuesQueueManagementDialog import ( HgQueuesQueueManagementDialog ) + + title = ( + self.tr("Create New Queue") + if isCreate else + self.tr("Rename Active Queue") + ) dlg = HgQueuesQueueManagementDialog( HgQueuesQueueManagementDialog.NAME_INPUT, title, False, self.vcs)
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelveDataDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelveDataDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -48,10 +48,11 @@ shelved changes in the working directory @rtype tuple of (str, QDateTime, str, bool, bool) """ - if self.dateTimeEdit.dateTime() != self.__initialDateTime: - dateTime = self.dateTimeEdit.dateTime() - else: - dateTime = QDateTime() + dateTime = ( + self.dateTimeEdit.dateTime() + if self.dateTimeEdit.dateTime() != self.__initialDateTime else + QDateTime() + ) return ( self.nameEdit.text().replace(" ", "_"), dateTime,
--- a/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Wed Apr 21 19:40:50 2021 +0200 @@ -1244,10 +1244,11 @@ """<tr><td><b>Committed time</b></td><td>{2}</td></tr>""") .format(author, cdate, ctime)) infoBlock.append("\n".join(info)) - if infoBlock: - infoStr = """<tr></tr>{0}""".format("<tr></tr>".join(infoBlock)) - else: - infoStr = "" + infoStr = ( + """<tr></tr>{0}""".format("<tr></tr>".join(infoBlock)) + if infoBlock else + "" + ) url = "" args = self.initCommand("showconfig") @@ -1780,10 +1781,11 @@ else: args.append(name) - if unresolve: - title = self.tr("Marking as 'unresolved'") - else: - title = self.tr("Marking as 'resolved'") + title = ( + self.tr("Marking as 'unresolved'") + if unresolve else + self.tr("Marking as 'resolved'") + ) dia = HgDialog(title, self) res = dia.startProcess(args) if res: @@ -2018,15 +2020,16 @@ ] ignoreName = os.path.join(name, Hg.IgnoreFileName) - if os.path.exists(ignoreName): - res = E5MessageBox.yesNo( + res = ( + E5MessageBox.yesNo( self.__ui, self.tr("Create .hgignore file"), self.tr("""<p>The file <b>{0}</b> exists already.""" """ Overwrite it?</p>""").format(ignoreName), icon=E5MessageBox.Warning) - else: - res = True + if os.path.exists(ignoreName) else + True + ) if res: try: # create a .hgignore file @@ -3160,10 +3163,11 @@ """ bookmarksList = [] - if incoming: - args = self.initCommand("incoming") - else: - args = self.initCommand("outgoing") + args = ( + self.initCommand("incoming") + if incoming else + self.initCommand("outgoing") + ) args.append('--bookmarks') client = self.getClient()
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnLogBrowserDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -217,15 +217,16 @@ changes = [] for changedPath in changedPaths: - if changedPath["copyfrom_path"] is None: - copyPath = "" - else: - copyPath = changedPath["copyfrom_path"] - if changedPath["copyfrom_revision"] is None: - copyRev = "" - else: - copyRev = "{0:7d}".format( - changedPath["copyfrom_revision"].number) + copyPath = ( + "" + if changedPath["copyfrom_path"] is None else + changedPath["copyfrom_path"] + ) + copyRev = ( + "" + if changedPath["copyfrom_revision"] is None else + "{0:7d}".format(changedPath["copyfrom_revision"].number) + ) change = { "action": changedPath["action"], "path": changedPath["path"], @@ -292,11 +293,12 @@ with E5MutexLocker(self.vcs.vcsExecutionMutex): while fetched < limit: flimit = min(fetchLimit, limit - fetched) - if fetched == 0: - revstart = start - else: - revstart = pysvn.Revision( - pysvn.opt_revision_kind.number, nextRev) + revstart = ( + start + if fetched == 0 else + pysvn.Revision(pysvn.opt_revision_kind.number, + nextRev) + ) allLogs = self.client.log( self.fname, revision_start=revstart, discover_changed_paths=True, limit=flimit + 1,
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py Wed Apr 21 19:40:50 2021 +0200 @@ -585,14 +585,15 @@ QApplication.processEvents() try: with E5MutexLocker(self.vcsExecutionMutex): - if changelists: - rev = client.checkin(fnames, msg, - recurse=recurse, keep_locks=keeplocks, - keep_changelist=keepChangelists, - changelists=changelists) - else: - rev = client.checkin(fnames, msg, - recurse=recurse, keep_locks=keeplocks) + rev = ( + client.checkin( + fnames, msg, recurse=recurse, keep_locks=keeplocks, + keep_changelist=keepChangelists, + changelists=changelists) + if changelists else + client.checkin( + fnames, msg, recurse=recurse, keep_locks=keeplocks) + ) except pysvn.ClientError as e: rev = None if not noDialog: @@ -1045,10 +1046,11 @@ """ will be aborted""")) return - if self.otherData["standardLayout"]: - url = None - else: - url = self.svnNormalizeURL(reposURL) + url = ( + None + if self.otherData["standardLayout"] else + self.svnNormalizeURL(reposURL) + ) from .SvnTagDialog import SvnTagDialog dlg = SvnTagDialog(self.allTagsBranchesList, url, self.otherData["standardLayout"]) @@ -1187,10 +1189,11 @@ """ operation will be aborted""")) return False - if self.otherData["standardLayout"]: - url = None - else: - url = self.svnNormalizeURL(reposURL) + url = ( + None + if self.otherData["standardLayout"] else + self.svnNormalizeURL(reposURL) + ) from .SvnSwitchDialog import SvnSwitchDialog dlg = SvnSwitchDialog(self.allTagsBranchesList, url, self.otherData["standardLayout"]) @@ -1709,12 +1712,13 @@ except pysvn.ClientError as e: return e.args[0] - if hasattr(pysvn, 'svn_api_version'): - apiVersion = "{0} {1}".format( + apiVersion = ( + "{0} {1}".format( ".".join([str(v) for v in pysvn.svn_api_version[:3]]), pysvn.svn_api_version[3]) - else: - apiVersion = QCoreApplication.translate('subversion', "unknown") + if hasattr(pysvn, 'svn_api_version') else + QCoreApplication.translate('subversion', "unknown") + ) hmsz = time.strftime("%H:%M:%S %Z", time.localtime(entry.commit_time)) return QCoreApplication.translate(
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py Wed Apr 21 19:40:50 2021 +0200 @@ -970,10 +970,11 @@ """ will be aborted""")) return - if self.otherData["standardLayout"]: - url = None - else: - url = self.svnNormalizeURL(reposURL) + url = ( + None + if self.otherData["standardLayout"] else + self.svnNormalizeURL(reposURL) + ) from .SvnTagDialog import SvnTagDialog dlg = SvnTagDialog(self.allTagsBranchesList, url, self.otherData["standardLayout"]) @@ -1093,10 +1094,11 @@ """ operation will be aborted""")) return False - if self.otherData["standardLayout"]: - url = None - else: - url = self.svnNormalizeURL(reposURL) + url = ( + None + if self.otherData["standardLayout"] else + self.svnNormalizeURL(reposURL) + ) from .SvnSwitchDialog import SvnSwitchDialog dlg = SvnSwitchDialog(self.allTagsBranchesList, url, self.otherData["standardLayout"])
--- a/eric6/Plugins/ViewManagerPlugins/Listspace/Listspace.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/ViewManagerPlugins/Listspace/Listspace.py Wed Apr 21 19:40:50 2021 +0200 @@ -649,10 +649,11 @@ self.currentStack = stack stack.currentChanged.connect(self.__currentChanged) stack.installEventFilter(self) - if self.stackArea.orientation() == Qt.Orientation.Horizontal: - size = self.stackArea.width() - else: - size = self.stackArea.height() + size = ( + self.stackArea.width() + if self.stackArea.orientation() == Qt.Orientation.Horizontal else + self.stackArea.height() + ) self.stackArea.setSizes( [int(size / len(self.stacks))] * len(self.stacks)) self.splitRemoveAct.setEnabled(True)
--- a/eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/ViewManagerPlugins/Tabview/Tabview.py Wed Apr 21 19:40:50 2021 +0200 @@ -1166,10 +1166,11 @@ tw.currentChanged.connect(self.__currentChanged) tw.installEventFilter(self) tw.tabBar().installEventFilter(self) - if self.__splitter.orientation() == Qt.Orientation.Horizontal: - size = self.width() - else: - size = self.height() + size = ( + self.width() + if self.__splitter.orientation() == Qt.Orientation.Horizontal else + self.height() + ) self.__splitter.setSizes( [int(size / len(self.tabWidgets))] * len(self.tabWidgets)) self.splitRemoveAct.setEnabled(True)
--- a/eric6/Plugins/WizardPlugins/E5MessageBoxWizard/E5MessageBoxWizardDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/WizardPlugins/E5MessageBoxWizard/E5MessageBoxWizardDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -428,11 +428,11 @@ istring2 = istring + indString joinstring = ' |{0}{1}'.format(os.linesep, istring2) - if withIntro: - btnCode = ',{0}{1}E5MessageBox.StandardButtons('.format( - os.linesep, istring) - else: - btnCode = 'E5MessageBox.StandardButtons(' + btnCode = ( + ',{0}{1}E5MessageBox.StandardButtons('.format(os.linesep, istring) + if withIntro else + 'E5MessageBox.StandardButtons(' + ) btnCode += '{0}{1}{2})'.format( os.linesep, istring2, joinstring.join(buttons))
--- a/eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardCharactersDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -587,11 +587,12 @@ for entrieslist in self.singlesEntries: formatIdentifier = entrieslist[0].itemData( entrieslist[0].currentIndex()) - if formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn", "-csp", - "-csn", "-psp", "-psn"]: - char = entrieslist[2].itemData(entrieslist[2].currentIndex()) - else: - char = entrieslist[1].text() + char = ( + entrieslist[2].itemData(entrieslist[2].currentIndex()) + if formatIdentifier in ["-ccp", "-ccn", "-cbp", "-cbn", "-csp", + "-csn", "-psp", "-psn"] else + entrieslist[1].text() + ) regexp += self.__formatCharacter(char, formatIdentifier) # character ranges
--- a/eric6/Preferences/ConfigurationDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/ConfigurationDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -617,14 +617,13 @@ text = text.lower() for index in range(parent.childCount()): itm = parent.child(index) - if itm.childCount() > 0: - enable = ( - self.__searchChildItems(itm, text) or - text == "" or - text in itm.text(0).lower() - ) - else: - enable = text == "" or text in itm.text(0).lower() + enable = ( + (self.__searchChildItems(itm, text) or + text == "" or + text in itm.text(0).lower()) + if itm.childCount() > 0 else + (text == "" or text in itm.text(0).lower()) + ) if enable: childEnabled = True itm.setDisabled(not enable)
--- a/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py Wed Apr 21 19:40:50 2021 +0200 @@ -354,10 +354,11 @@ self.sampleText.setFont(font) style, substyle = self.__currentStyles() - if self.monospacedButton.isChecked(): - options = MonospacedFontsOption - else: - options = NoFontsOption + options = ( + MonospacedFontsOption + if self.monospacedButton.isChecked() else + NoFontsOption + ) font, ok = QFontDialog.getFont(self.lexer.font(style, substyle), self, "", options) if ok: @@ -565,14 +566,15 @@ if ex: fn += ex - if os.path.exists(fn): - ok = E5MessageBox.yesNo( + ok = ( + E5MessageBox.yesNo( self, self.tr("Export Highlighting Styles"), self.tr("""<p>The highlighting styles file <b>{0}</b> exists""" """ already. Overwrite it?</p>""").format(fn)) - else: - ok = True + if os.path.exists(fn) else + True + ) if ok: if fn.endswith(".ehj"):
--- a/eric6/Preferences/ConfigurationPages/EditorKeywordsPage.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/ConfigurationPages/EditorKeywordsPage.py Wed Apr 21 19:40:50 2021 +0200 @@ -170,14 +170,15 @@ """ Private slot to set the current keyword set to default values. """ - if bool(self.keywordsEdit.toPlainText()): - ok = E5MessageBox.yesNo( + ok = ( + E5MessageBox.yesNo( self, self.tr("Reset to Default"), self.tr("Shall the current keyword set really be reset to" " default values?")) - else: - ok = True + if bool(self.keywordsEdit.toPlainText()) else + True + ) if ok: language = self.languageCombo.currentText() kwSet = self.setSpinBox.value()
--- a/eric6/Preferences/ConfigurationPages/InterfacePage.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/ConfigurationPages/InterfacePage.py Wed Apr 21 19:40:50 2021 +0200 @@ -138,10 +138,11 @@ # save the language settings uiLanguageIndex = self.languageComboBox.currentIndex() - if uiLanguageIndex: - uiLanguage = self.languageComboBox.itemData(uiLanguageIndex) - else: - uiLanguage = None + uiLanguage = ( + self.languageComboBox.itemData(uiLanguageIndex) + if uiLanguageIndex else + None + ) Preferences.setUILanguage(uiLanguage) # save the interface layout settings
--- a/eric6/Preferences/ConfigurationPages/WebBrowserPage.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/ConfigurationPages/WebBrowserPage.py Wed Apr 21 19:40:50 2021 +0200 @@ -333,11 +333,12 @@ Preferences.setWebBrowser("HistoryLimit", historyLimit) languageIndex = self.languageCombo.currentIndex() - if languageIndex > -1: - language = self.languageCombo.itemData(languageIndex) - else: + language = ( + self.languageCombo.itemData(languageIndex) + if languageIndex > -1 else # fall back to system default - language = QLocale.system().language() + QLocale.system().language() + ) Preferences.setWebBrowser("SearchLanguage", language) Preferences.setWebBrowser(
--- a/eric6/Preferences/PreferencesLexer.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/PreferencesLexer.py Wed Apr 21 19:40:50 2021 +0200 @@ -158,10 +158,11 @@ @return default color @rtype QColor """ - if substyle >= 0: - color = self.__lex.substyleDefaultColor(style, substyle) - else: - color = self.__lex.defaultColor(style) + color = ( + self.__lex.substyleDefaultColor(style, substyle) + if substyle >= 0 else + self.__lex.defaultColor(style) + ) return color @@ -176,10 +177,11 @@ @return color @rtype QColor """ - if substyle >= 0: - color = self.__lex.substyleColor(style, substyle) - else: - color = self.__lex.color(style) + color = ( + self.__lex.substyleColor(style, substyle) + if substyle >= 0 else + self.__lex.color(style) + ) return color @@ -210,10 +212,11 @@ @return default background color @rtype QColor """ - if substyle >= 0: - color = self.__lex.substyleDefaultPaper(style, substyle) - else: - color = self.__lex.defaultPaper(style) + color = ( + self.__lex.substyleDefaultPaper(style, substyle) + if substyle >= 0 else + self.__lex.defaultPaper(style) + ) return color @@ -228,10 +231,11 @@ @return background color @rtype QColor """ - if substyle >= 0: - color = self.__lex.substylePaper(style, substyle) - else: - color = self.__lex.paper(style) + color = ( + self.__lex.substylePaper(style, substyle) + if substyle >= 0 else + self.__lex.paper(style) + ) return color @@ -262,10 +266,11 @@ @return default eolFill flag @rtype bool """ - if substyle >= 0: - eolFill = self.__lex.substyleDefaultEolFill(style, substyle) - else: - eolFill = self.__lex.defaultEolFill(style) + eolFill = ( + self.__lex.substyleDefaultEolFill(style, substyle) + if substyle >= 0 else + self.__lex.defaultEolFill(style) + ) return eolFill @@ -280,10 +285,11 @@ @return eolFill flag @rtype bool """ - if substyle >= 0: - eolFill = self.__lex.substyleEolFill(style, substyle) - else: - eolFill = self.__lex.eolFill(style) + eolFill = ( + self.__lex.substyleEolFill(style, substyle) + if substyle >= 0 else + self.__lex.eolFill(style) + ) return eolFill @@ -314,10 +320,11 @@ @return default font @rtype QFont """ - if substyle >= 0: - font = self.__lex.substyleDefaultFont(style, substyle) - else: - font = self.__lex.defaultFont(style) + font = ( + self.__lex.substyleDefaultFont(style, substyle) + if substyle >= 0 else + self.__lex.defaultFont(style) + ) return font @@ -332,10 +339,11 @@ @return font @rtype QFont """ - if substyle >= 0: - font = self.__lex.substyleFont(style, substyle) - else: - font = self.__lex.font(style) + font = ( + self.__lex.substyleFont(style, substyle) + if substyle >= 0 else + self.__lex.font(style) + ) return font @@ -366,10 +374,11 @@ @return whitespace separated default list of words @rtype str """ - if substyle >= 0: - words = self.__lex.substyleDefaultWords(style, substyle) - else: - words = "" + words = ( + self.__lex.substyleDefaultWords(style, substyle) + if substyle >= 0 else + "" + ) return words @@ -415,11 +424,12 @@ @return default description of the style @rtype str """ - if substyle >= 0: - desc = self.__lex.substyleDefaultDescription(style, substyle) - else: + desc = ( + self.__lex.substyleDefaultDescription(style, substyle) + if substyle >= 0 else # for base styles return the hard coded description - desc = self.__lex.description(style) + self.__lex.description(style) + ) return desc @@ -434,10 +444,11 @@ @return description of the style @rtype str """ - if substyle >= 0: - desc = self.__lex.substyleDescription(style, substyle) - else: - desc = self.__lex.description(style) + desc = ( + self.__lex.substyleDescription(style, substyle) + if substyle >= 0 else + self.__lex.description(style) + ) return desc
--- a/eric6/Preferences/ProgramsDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/ProgramsDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -357,10 +357,11 @@ """ itmList = self.programsList.findItems( description, Qt.MatchFlag.MatchCaseSensitive) - if itmList: - itm = itmList[0] - else: - itm = QTreeWidgetItem(self.programsList, [description]) + itm = ( + itmList[0] + if itmList else + QTreeWidgetItem(self.programsList, [description]) + ) font = itm.font(0) font.setBold(True) itm.setFont(0, font)
--- a/eric6/Preferences/SubstyleDefinitionDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/SubstyleDefinitionDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -102,14 +102,15 @@ bool(self.descriptionEdit.text().strip()) or bool(self.wordsEdit.toPlainText().strip()) ) - if filled: - ok = E5MessageBox.yesNo( + ok = ( + E5MessageBox.yesNo( self, self.tr("Set Sub-Style Data to Default"), self.tr("""Shall the sub-style data be set to default""" """ values?""")) - else: - ok = True + if filled else + True + ) if ok: if self.__substyle >= 0: self.descriptionEdit.setText(self.__lexer.defaultDescription(
--- a/eric6/Preferences/__init__.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Preferences/__init__.py Wed Apr 21 19:40:50 2021 +0200 @@ -2318,10 +2318,7 @@ editorLexerAssoc[key] = editorLexerAssocDefaults[key] else: for key in keyList: - if key in editorLexerAssocDefaults: - defaultValue = editorLexerAssocDefaults[key] - else: - defaultValue = "" + defaultValue = editorLexerAssocDefaults.get(key, "") editorLexerAssoc[key] = prefClass.settings.value( "Editor/LexerAssociations/" + key, defaultValue)
--- a/eric6/Project/CreateDialogCodeDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Project/CreateDialogCodeDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -500,10 +500,11 @@ break # do the coding stuff - if self.project.getProjectType() in ("PySide2", "PySide6"): - pyqtSignatureFormat = '@Slot({0})' - else: - pyqtSignatureFormat = '@pyqtSlot({0})' + pyqtSignatureFormat = ( + '@Slot({0})' + if self.project.getProjectType() in ("PySide2", "PySide6") else + '@pyqtSlot({0})' + ) for row in range(self.slotsModel.rowCount()): topItem = self.slotsModel.item(row) for childRow in range(topItem.rowCount()):
--- a/eric6/Project/Project.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Project/Project.py Wed Apr 21 19:40:50 2021 +0200 @@ -607,10 +607,11 @@ } # Sources - if self.pdata["MIXEDLANGUAGE"]: - sourceKey = "Mixed" - else: - sourceKey = self.pdata["PROGLANGUAGE"] + sourceKey = ( + "Mixed" + if self.pdata["MIXEDLANGUAGE"] else + self.pdata["PROGLANGUAGE"] + ) for ext in self.__sourceExtensions(sourceKey): self.pdata["FILETYPES"]["*{0}".format(ext)] = "SOURCES" @@ -3130,13 +3131,12 @@ @return flag indicating success (boolean) """ defaultFilter = self.tr("Project Files (*.epj)") - if self.ppath: - defaultPath = self.ppath - else: - defaultPath = ( - Preferences.getMultiProject("Workspace") or - Utilities.getHomeDir() - ) + defaultPath = ( + self.ppath + if self.ppath else + (Preferences.getMultiProject("Workspace") or + Utilities.getHomeDir()) + ) fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self.parent(), self.tr("Save project as"), @@ -4646,13 +4646,11 @@ newSources = os.listdir(curpath) except OSError: newSources = [] - if self.pdata["TRANSLATIONPATTERN"]: - pattern = ( - self.pdata["TRANSLATIONPATTERN"] - .replace("%language%", "*") - ) - else: - pattern = "*.ts" + pattern = ( + self.pdata["TRANSLATIONPATTERN"].replace("%language%", "*") + if self.pdata["TRANSLATIONPATTERN"] else + "*.ts" + ) binpattern = self.__binaryTranslationFile(pattern) for ns in newSources: # ignore hidden files and directories @@ -5422,12 +5420,12 @@ continue names = sorted(names) - if archiveName: - archive = os.path.join(self.ppath, archiveName) - else: - archive = os.path.join( - self.ppath, - self.pdata["MAINSCRIPT"].replace(".py", ".zip")) + archive = ( + os.path.join(self.ppath, archiveName) + if archiveName else + os.path.join(self.ppath, + self.pdata["MAINSCRIPT"].replace(".py", ".zip")) + ) try: archiveFile = zipfile.ZipFile(archive, "w") except OSError as why: @@ -5658,10 +5656,11 @@ ): return - if self.pdata["MAKEPARAMS"]["MakeExecutable"]: - prog = self.pdata["MAKEPARAMS"]["MakeExecutable"] - else: - prog = Project.DefaultMake + prog = ( + self.pdata["MAKEPARAMS"]["MakeExecutable"] + if self.pdata["MAKEPARAMS"]["MakeExecutable"] else + Project.DefaultMake + ) args = [] if self.pdata["MAKEPARAMS"]["MakeParameters"]:
--- a/eric6/Project/ProjectBaseBrowser.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Project/ProjectBaseBrowser.py Wed Apr 21 19:40:50 2021 +0200 @@ -500,11 +500,11 @@ if self.project.vcs is None: return - if local: - compareString = QCoreApplication.translate( - 'ProjectBaseBrowser', "local") - else: - compareString = self.project.vcs.vcsName() + compareString = ( + QCoreApplication.translate('ProjectBaseBrowser', "local") + if local else + self.project.vcs.vcsName() + ) # expand all directories in order to iterate over all entries self._expandAllDirs()
--- a/eric6/Project/ProjectBrowser.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Project/ProjectBrowser.py Wed Apr 21 19:40:50 2021 +0200 @@ -259,11 +259,11 @@ """ Private slot to handle the projectPropertiesChanged signal. """ - if self.project.isOpen(): - flags = Preferences.getProjectBrowserFlags( - self.project.getProjectType()) - else: - flags = AllBrowsersFlag + flags = ( + Preferences.getProjectBrowserFlags(self.project.getProjectType()) + if self.project.isOpen() else + AllBrowsersFlag + ) if flags != self.__currentBrowsersFlags: self.__currentBrowsersFlags = flags
--- a/eric6/Project/ProjectBrowserModel.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Project/ProjectBrowserModel.py Wed Apr 21 19:40:50 2021 +0200 @@ -345,15 +345,15 @@ qdir = QDir(parentItem.dirName()) - if Preferences.getProject("BrowsersListHiddenFiles"): - fileFilter = QDir.Filters( + fileFilter = ( + QDir.Filters( QDir.Filter.AllEntries | QDir.Filter.Hidden | QDir.Filter.NoDotAndDotDot ) - else: - fileFilter = QDir.Filters( - QDir.Filter.AllEntries | QDir.Filter.NoDotAndDotDot) + if Preferences.getProject("BrowsersListHiddenFiles") else + QDir.Filters(QDir.Filter.AllEntries | QDir.Filter.NoDotAndDotDot) + ) entryInfoList = qdir.entryInfoList(fileFilter) if len(entryInfoList) > 0: @@ -371,16 +371,17 @@ states = self.project.vcs.vcsAllRegisteredStates(states, dname) for f in entryInfoList: - if f.isDir(): - node = ProjectBrowserDirectoryItem( + node = ( + ProjectBrowserDirectoryItem( parentItem, Utilities.toNativeSeparators(f.absoluteFilePath()), parentItem.getProjectTypes()[0], False) - else: - node = ProjectBrowserFileItem( + if f.isDir() else + ProjectBrowserFileItem( parentItem, Utilities.toNativeSeparators(f.absoluteFilePath()), parentItem.getProjectTypes()[0]) + ) if self.project.vcs is not None: fname = f.absoluteFilePath() if ( @@ -448,14 +449,15 @@ fname = os.path.join(self.project.ppath, fn) parentItem, dt = self.findParentItemByName( self.projectBrowserTypes[key], fn) - if os.path.isdir(fname): - itm = ProjectBrowserDirectoryItem( + itm = ( + ProjectBrowserDirectoryItem( parentItem, fname, self.projectBrowserTypes[key], False, bold) - else: - itm = ProjectBrowserFileItem( + if os.path.isdir(fname) else + ProjectBrowserFileItem( parentItem, fname, self.projectBrowserTypes[key], False, bold, sourceLanguage=sourceLanguage) + ) self._addItem(itm, parentItem) if self.project.vcs is not None: if ( @@ -552,10 +554,11 @@ fname = os.path.join(self.project.ppath, name) parentItem, dt = self.findParentItemByName( self.projectBrowserTypes[typeString], name) - if parentItem == self.rootItem: - parentIndex = QModelIndex() - else: - parentIndex = self.createIndex(parentItem.row(), 0, parentItem) + parentIndex = ( + QModelIndex() + if parentItem == self.rootItem else + self.createIndex(parentItem.row(), 0, parentItem) + ) if os.path.isdir(fname): itm = ProjectBrowserDirectoryItem( parentItem, fname, self.projectBrowserTypes[typeString], @@ -686,15 +689,15 @@ # just ignore the situation we don't have a reference to the item return - if Preferences.getProject("BrowsersListHiddenFiles"): - fileFilter = QDir.Filters( + fileFilter = ( + QDir.Filters( QDir.Filter.AllEntries | QDir.Filter.Hidden | QDir.Filter.NoDotAndDotDot ) - else: - fileFilter = QDir.Filters( - QDir.Filter.AllEntries | QDir.Filter.NoDotAndDotDot) + if Preferences.getProject("BrowsersListHiddenFiles") else + QDir.Filters(QDir.Filter.AllEntries | QDir.Filter.NoDotAndDotDot) + ) for itm in self.watchedItems[path]: oldCnt = itm.childCount() @@ -719,17 +722,18 @@ cnt = itm.childCount() self.beginInsertRows( self.createIndex(itm.row(), 0, itm), cnt, cnt) - if f.isDir(): - node = ProjectBrowserDirectoryItem( + node = ( + ProjectBrowserDirectoryItem( itm, Utilities.toNativeSeparators(f.absoluteFilePath()), itm.getProjectTypes()[0], False) - else: - node = ProjectBrowserFileItem( + if f.isDir() else + ProjectBrowserFileItem( itm, Utilities.toNativeSeparators(f.absoluteFilePath()), itm.getProjectTypes()[0]) + ) self._addItem(node, itm) if self.project.vcs is not None: self.project.vcs.clearStatusCache() @@ -821,10 +825,11 @@ """ fname = os.path.basename(name) parentItem = self.findParentItemByName(0, name)[0] - if parentItem == self.rootItem: - parentIndex = QModelIndex() - else: - parentIndex = self.createIndex(parentItem.row(), 0, parentItem) + parentIndex = ( + QModelIndex() + if parentItem == self.rootItem else + self.createIndex(parentItem.row(), 0, parentItem) + ) childItem = self.findChildItem(fname, 0, parentItem) if childItem is not None: self.beginRemoveRows(parentIndex, childItem.row(), childItem.row())
--- a/eric6/Project/TranslationPropertiesDialog.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/Project/TranslationPropertiesDialog.py Wed Apr 21 19:40:50 2021 +0200 @@ -129,10 +129,11 @@ Private slot to add the shown exception to the listwidget. """ texcept = self.exceptionEdit.text() - if self.project.ppath == '': - texcept = texcept.replace(self.parent.getPPath() + os.sep, "") - else: - texcept = self.project.getRelativePath(texcept) + texcept = ( + texcept.replace(self.parent.getPPath() + os.sep, "") + if self.project.ppath == '' else + self.project.getRelativePath(texcept) + ) if texcept.endswith(os.sep): texcept = texcept[:-1] if texcept:
--- a/eric6/QScintilla/Editor.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Editor.py Wed Apr 21 19:40:50 2021 +0200 @@ -1804,10 +1804,11 @@ self.SCN_STYLENEEDED.connect(self.__styleNeeded) # get the font for style 0 and set it as the default font - if pyname and pyname.startswith("Pygments|"): - key = 'Scintilla/Guessed/style0/font' - else: - key = 'Scintilla/{0}/style0/font'.format(self.lexer_.language()) + key = ( + 'Scintilla/Guessed/style0/font' + if pyname and pyname.startswith("Pygments|") else + 'Scintilla/{0}/style0/font'.format(self.lexer_.language()) + ) fdesc = Preferences.Prefs.settings.value(key) if fdesc is not None: font = QFont(fdesc[0], int(fdesc[1])) @@ -1820,10 +1821,11 @@ self.lexer_.initProperties() # initialize the lexer APIs settings - if self.project.isOpen() and self.project.isProjectFile(filename): - projectType = self.project.getProjectType() - else: - projectType = "" + projectType = ( + self.project.getProjectType() + if self.project.isOpen() and self.project.isProjectFile(filename) + else "" + ) api = self.vm.getAPIsManager().getAPIs(self.apiLanguage, projectType=projectType) if api is not None and not api.isEmpty(): @@ -3567,10 +3569,11 @@ else: wc = re.sub(r'\w', "", wc) pattern = r"\b[\w{0}]+\b".format(re.escape(wc)) - if self.caseSensitive(): - rx = re.compile(pattern) - else: - rx = re.compile(pattern, re.IGNORECASE) + rx = ( + re.compile(pattern) + if self.caseSensitive() else + re.compile(pattern, re.IGNORECASE) + ) text = self.text(line) for match in rx.finditer(text): @@ -5025,10 +5028,11 @@ line, col = self.getCursorPosition() text = self.text(line) try: - if self.__isStartChar(text[col - 1]): - acText = self.getWordLeft(line, col - 1) + text[col - 1] - else: - acText = self.getWordLeft(line, col) + acText = ( + self.getWordLeft(line, col - 1) + text[col - 1] + if self.__isStartChar(text[col - 1]) else + self.getWordLeft(line, col) + ) except IndexError: acText = "" @@ -5050,10 +5054,11 @@ if auto and self.__acText == '': return - if self.__acCacheEnabled: - completions = self.__acCache.get(self.__acText) - else: - completions = None + completions = ( + self.__acCache.get(self.__acText) + if self.__acCacheEnabled else + None + ) if completions is not None: # show list with cached entries if self.isListActive(): @@ -5130,12 +5135,13 @@ @param completions completions to be shown @type list of str or set of str """ - if Preferences.getEditor("AutoCompletionReversedList"): - acCompletions = sorted( + acCompletions = ( + sorted( list(completions), key=self.__replaceLeadingUnderscores) - else: - acCompletions = sorted(list(completions)) + if Preferences.getEditor("AutoCompletionReversedList") else + sorted(list(completions)) + ) self.showUserList(EditorAutoCompletionListID, acCompletions) def __replaceLeadingUnderscores(self, txt): @@ -5338,12 +5344,13 @@ ctshift = shift cv = self.callTipsVisible() - if cv > 0: + ct = ( # this is just a safe guard - ct = self._encodeString("\n".join(callTips[:cv])) - else: + self._encodeString("\n".join(callTips[:cv])) + if cv > 0 else # until here and unindent below - ct = self._encodeString("\n".join(callTips)) + self._encodeString("\n".join(callTips)) + ) self.SendScintilla(QsciScintilla.SCI_CALLTIPSHOW, self.__adjustedCallTipPosition(ctshift, pos), ct)
--- a/eric6/QScintilla/Exporters/ExporterHTML.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Exporters/ExporterHTML.py Wed Apr 21 19:40:50 2021 +0200 @@ -122,10 +122,11 @@ ) lex = self.editor.getLexer() - if lex: - bgColour = lex.paper(QsciScintilla.STYLE_DEFAULT).name() - else: - bgColour = self.editor.paper().name() + bgColour = ( + lex.paper(QsciScintilla.STYLE_DEFAULT).name() + if lex else + self.editor.paper().name() + ) html += '''<style type="text/css">\n''' if lex: @@ -647,16 +648,13 @@ htmlFormat = Preferences.getEditor("PreviewMarkdownHTMLFormat").lower() body = markdown.markdown(text, extensions=extensions, output_format=htmlFormat) - if useDarkScheme: - style = ( - PreviewerHTMLStyles.css_markdown_dark + - PreviewerHTMLStyles.css_pygments_dark - ) - else: - style = ( - PreviewerHTMLStyles.css_markdown_light + - PreviewerHTMLStyles.css_pygments_light - ) + style = ( + (PreviewerHTMLStyles.css_markdown_dark + + PreviewerHTMLStyles.css_pygments_dark) + if useDarkScheme else + (PreviewerHTMLStyles.css_markdown_light + + PreviewerHTMLStyles.css_pygments_light) + ) if htmlFormat == "xhtml1": head = (
--- a/eric6/QScintilla/Exporters/ExporterTEX.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Exporters/ExporterTEX.py Wed Apr 21 19:40:50 2021 +0200 @@ -216,10 +216,11 @@ QsciScintilla.STYLE_DEFAULT) f.write("\\begin{document}\n\n") - if titleFullPath: - title = self.editor.getFileName() - else: - title = os.path.basename(self.editor.getFileName()) + title = ( + self.editor.getFileName() + if titleFullPath else + os.path.basename(self.editor.getFileName()) + ) f.write( "Source File: {0}\n\n\\noindent\n\\tiny{{\n" .format(title))
--- a/eric6/QScintilla/Lexers/Lexer.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Lexers/Lexer.py Wed Apr 21 19:40:50 2021 +0200 @@ -170,10 +170,11 @@ line, editor.indentation(line) + indentDifference) editor.endUndoAction() - if self.lastIndentedIndex != 0: - indexStart = indexFrom + indentDifference - else: - indexStart = 0 + indexStart = ( + indexFrom + indentDifference + if self.lastIndentedIndex != 0 else + 0 + ) if indexStart < 0: indexStart = 0 indexEnd = indexTo != 0 and (indexTo + indentDifference) or 0
--- a/eric6/QScintilla/Lexers/LexerPython.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Lexers/LexerPython.py Wed Apr 21 19:40:50 2021 +0200 @@ -181,14 +181,13 @@ if m: last -= indent_width - if ( - lead_spaces % indent_width != 0 or - lead_spaces == 0 or - self.lastIndented != line - ): - indentDifference = last - lead_spaces - else: - indentDifference = -indent_width + indentDifference = ( + last - lead_spaces + if (lead_spaces % indent_width != 0 or + lead_spaces == 0 or + self.lastIndented != line) else + -indent_width + ) return indentDifference
--- a/eric6/QScintilla/Lexers/SubstyledLexer.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Lexers/SubstyledLexer.py Wed Apr 21 19:40:50 2021 +0200 @@ -200,30 +200,31 @@ # set the style style = subStyle["Style"] - if "fore" in style: - color = QColor( + color = ( + QColor( style["fore"] >> 16 & 0xff, style["fore"] >> 8 & 0xff, - style["fore"] & 0xff, - ) - else: - color = self.color(baseStyleNo) + style["fore"] & 0xff,) + if "fore" in style else + self.color(baseStyleNo) + ) self.setColor(color, styleNo) - if "paper" in style: - color = QColor( + color = ( + QColor( style["paper"] >> 16 & 0xff, style["paper"] >> 8 & 0xff, - style["paper"] & 0xff, - ) - else: - color = self.paper(baseStyleNo) + style["paper"] & 0xff,) + if "paper" in style else + self.paper(baseStyleNo) + ) self.setPaper(color, styleNo) - if "eolfill" in style: - eolFill = style["eolfill"] - else: - eolFill = self.eolFill(baseStyleNo) + eolFill = ( + style["eolfill"] + if "eolfill" in style else + self.eolFill(baseStyleNo) + ) self.setEolFill(eolFill, styleNo) font = self.font(baseStyleNo) @@ -309,10 +310,11 @@ settings.setValue(substyleKey + "font_bold", bold) italic = style.get("font_italic", font.italic()) settings.setValue(substyleKey + "font_italic", italic) - if "font_underline" in style: - underline = style["font_underline"] - else: - underline = font.underline() + underline = ( + style["font_underline"] + if "font_underline" in style else + font.underline() + ) settings.setValue(substyleKey + "font_underline", underline) def hasSubstyles(self): @@ -374,10 +376,12 @@ @return sub-style description @rtype str """ - if style in self.__subStyles and substyle in self.__subStyles[style]: - desc = self.__subStyles[style][substyle]["Description"].strip() - else: - desc = "" + desc = ( + self.__subStyles[style][substyle]["Description"].strip() + if (style in self.__subStyles and + substyle in self.__subStyles[style]) else + "" + ) return desc @@ -406,10 +410,12 @@ @return white-space separated word list @rtype str """ - if style in self.__subStyles and substyle in self.__subStyles[style]: - words = self.__subStyles[style][substyle]["Words"].strip() - else: - words = "" + words = ( + self.__subStyles[style][substyle]["Words"].strip() + if (style in self.__subStyles and + substyle in self.__subStyles[style]) else + "" + ) return words
--- a/eric6/QScintilla/Lexers/__init__.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/QScintilla/Lexers/__init__.py Wed Apr 21 19:40:50 2021 +0200 @@ -235,10 +235,11 @@ @return icon for the language (QPixmap or QIcon) """ supportedLanguages = getSupportedLanguages() - if language in supportedLanguages: - iconFileName = supportedLanguages[language][2] - else: - iconFileName = "" + iconFileName = ( + supportedLanguages[language][2] + if language in supportedLanguages else + "" + ) if pixmap: return UI.PixmapCache.getPixmap(iconFileName) else:
--- a/eric6/eric6.py Wed Apr 21 17:56:12 2021 +0200 +++ b/eric6/eric6.py Wed Apr 21 19:40:50 2021 +0200 @@ -11,12 +11,6 @@ of the IDE and starts the Qt event loop. """ -# TODO: remove ThirdParty.Chardet -# TODO: remove ThirdParty.asttokens -# TODO: remove ThirdParty.EditorConfig -# TODO: remove ThirdParty.Pygments -# TODO: remove ThirdParty.Send2Trash - import sys import os import contextlib