--- 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)