diff -r d001bc703c29 -r aedc309827c7 eric6/QScintilla/TypingCompleters/CompleterPython.py --- a/eric6/QScintilla/TypingCompleters/CompleterPython.py Wed Sep 25 18:25:43 2019 +0200 +++ b/eric6/QScintilla/TypingCompleters/CompleterPython.py Wed Sep 25 18:37:35 2019 +0200 @@ -61,30 +61,30 @@ """ self.setEnabled( Preferences.getEditorTyping("Python/EnabledTypingAids")) - self.__insertClosingBrace = \ - Preferences.getEditorTyping("Python/InsertClosingBrace") - self.__indentBrace = \ - Preferences.getEditorTyping("Python/IndentBrace") - self.__skipBrace = \ - Preferences.getEditorTyping("Python/SkipBrace") - self.__insertQuote = \ - Preferences.getEditorTyping("Python/InsertQuote") - self.__dedentElse = \ - Preferences.getEditorTyping("Python/DedentElse") - self.__dedentExcept = \ - Preferences.getEditorTyping("Python/DedentExcept") - self.__insertImport = \ - Preferences.getEditorTyping("Python/InsertImport") - self.__importBraceType = \ - Preferences.getEditorTyping("Python/ImportBraceType") - self.__insertSelf = \ - Preferences.getEditorTyping("Python/InsertSelf") - self.__insertBlank = \ - Preferences.getEditorTyping("Python/InsertBlank") - self.__colonDetection = \ - Preferences.getEditorTyping("Python/ColonDetection") - self.__dedentDef = \ - Preferences.getEditorTyping("Python/DedentDef") + self.__insertClosingBrace = Preferences.getEditorTyping( + "Python/InsertClosingBrace") + self.__indentBrace = Preferences.getEditorTyping( + "Python/IndentBrace") + self.__skipBrace = Preferences.getEditorTyping( + "Python/SkipBrace") + self.__insertQuote = Preferences.getEditorTyping( + "Python/InsertQuote") + self.__dedentElse = Preferences.getEditorTyping( + "Python/DedentElse") + self.__dedentExcept = Preferences.getEditorTyping( + "Python/DedentExcept") + self.__insertImport = Preferences.getEditorTyping( + "Python/InsertImport") + self.__importBraceType = Preferences.getEditorTyping( + "Python/ImportBraceType") + self.__insertSelf = Preferences.getEditorTyping( + "Python/InsertSelf") + self.__insertBlank = Preferences.getEditorTyping( + "Python/InsertBlank") + self.__colonDetection = Preferences.getEditorTyping( + "Python/ColonDetection") + self.__dedentDef = Preferences.getEditorTyping( + "Python/DedentDef") def charAdded(self, charNumber): """ @@ -99,19 +99,23 @@ line, col = self.editor.getCursorPosition() - if self.__inComment(line, col) or \ - (char != '"' and self.__inDoubleQuotedString()) or \ - (char != '"' and self.__inTripleDoubleQuotedString()) or \ - (char != "'" and self.__inSingleQuotedString()) or \ - (char != "'" and self.__inTripleSingleQuotedString()): + if ( + self.__inComment(line, col) or + (char != '"' and self.__inDoubleQuotedString()) or + (char != '"' and self.__inTripleDoubleQuotedString()) or + (char != "'" and self.__inSingleQuotedString()) or + (char != "'" and self.__inTripleSingleQuotedString()) + ): return # open parenthesis # insert closing parenthesis and self if char == '(': txt = self.editor.text(line)[:col] - if self.__insertSelf and \ - self.__defRX.exactMatch(txt): + if ( + self.__insertSelf and + self.__defRX.exactMatch(txt) + ): if self.__isClassMethodDef(): self.editor.insert('cls') self.editor.setCursorPosition(line, col + 3) @@ -122,8 +126,10 @@ self.editor.insert('self') self.editor.setCursorPosition(line, col + 4) if self.__insertClosingBrace: - if self.__defRX.exactMatch(txt) or \ - self.__classRX.exactMatch(txt): + if ( + self.__defRX.exactMatch(txt) or + self.__classRX.exactMatch(txt) + ): self.editor.insert('):') else: self.editor.insert(')') @@ -271,15 +277,19 @@ edInd = self.editor.indentation(ifLine) if self.__elseRX.indexIn(txt) == 0 and edInd <= indentation: indentation = edInd - 1 - elif self.__elifRX.indexIn(txt) == 0 and \ - edInd == indentation and \ - edInd == prevInd: + elif ( + self.__elifRX.indexIn(txt) == 0 and + edInd == indentation and + edInd == prevInd + ): indentation = edInd - 1 - elif (self.__ifRX.indexIn(txt) == 0 or - self.__whileRX.indexIn(txt) == 0 or - self.__forRX.indexIn(txt) == 0 or - self.__tryRX.indexIn(txt) == 0) and \ - edInd <= indentation: + elif ( + (self.__ifRX.indexIn(txt) == 0 or + self.__whileRX.indexIn(txt) == 0 or + self.__forRX.indexIn(txt) == 0 or + self.__tryRX.indexIn(txt) == 0) and + edInd <= indentation + ): self.editor.cancelList() self.editor.setIndentation(line, edInd) break @@ -298,9 +308,11 @@ while tryLine >= 0: txt = self.editor.text(tryLine) edInd = self.editor.indentation(tryLine) - if (self.__exceptcRX.indexIn(txt) == 0 or - self.__finallyRX.indexIn(txt) == 0) and \ - edInd <= indentation: + if ( + (self.__exceptcRX.indexIn(txt) == 0 or + self.__finallyRX.indexIn(txt) == 0) and + edInd <= indentation + ): indentation = edInd - 1 elif (self.__exceptRX.indexIn(txt) == 0 or self.__tryRX.indexIn(txt) == 0) and edInd <= indentation: @@ -322,10 +334,12 @@ edInd = self.editor.indentation(tryLine) if self.__finallyRX.indexIn(txt) == 0 and edInd <= indentation: indentation = edInd - 1 - elif (self.__tryRX.indexIn(txt) == 0 or - self.__exceptcRX.indexIn(txt) == 0 or - self.__exceptRX.indexIn(txt) == 0) and \ - edInd <= indentation: + elif ( + (self.__tryRX.indexIn(txt) == 0 or + self.__exceptcRX.indexIn(txt) == 0 or + self.__exceptRX.indexIn(txt) == 0) and + edInd <= indentation + ): self.editor.cancelList() self.editor.setIndentation(line, edInd) break @@ -346,8 +360,9 @@ if self.__defRX.indexIn(txt) == 0 and edInd < indentation: newInd = edInd elif self.__classRX.indexIn(txt) == 0 and edInd < indentation: - newInd = edInd + \ - (self.editor.indentationWidth() or self.editor.tabWidth()) + newInd = edInd + ( + self.editor.indentationWidth() or self.editor.tabWidth() + ) if newInd >= 0: self.editor.cancelList() self.editor.setIndentation(line, newInd) @@ -365,15 +380,21 @@ curLine = line - 1 while curLine >= 0: txt = self.editor.text(curLine) - if (self.__defSelfRX.indexIn(txt) == 0 or - self.__defClsRX.indexIn(txt) == 0) and \ - self.editor.indentation(curLine) == indentation: + if ( + (self.__defSelfRX.indexIn(txt) == 0 or + self.__defClsRX.indexIn(txt) == 0) and + self.editor.indentation(curLine) == indentation + ): return True - elif self.__classRX.indexIn(txt) == 0 and \ - self.editor.indentation(curLine) < indentation: + elif ( + self.__classRX.indexIn(txt) == 0 and + self.editor.indentation(curLine) < indentation + ): return True - elif self.__defRX.indexIn(txt) == 0 and \ - self.editor.indentation(curLine) <= indentation: + elif ( + self.__defRX.indexIn(txt) == 0 and + self.editor.indentation(curLine) <= indentation + ): return False curLine -= 1 return False @@ -388,8 +409,10 @@ line, col = self.editor.getCursorPosition() indentation = self.editor.indentation(line) curLine = line - 1 - if self.__classmethodRX.indexIn(self.editor.text(curLine)) == 0 and \ - self.editor.indentation(curLine) == indentation: + if ( + self.__classmethodRX.indexIn(self.editor.text(curLine)) == 0 and + self.editor.indentation(curLine) == indentation + ): return True return False @@ -403,8 +426,10 @@ line, col = self.editor.getCursorPosition() indentation = self.editor.indentation(line) curLine = line - 1 - if self.__staticmethodRX.indexIn(self.editor.text(curLine)) == 0 and \ - self.editor.indentation(curLine) == indentation: + if ( + self.__staticmethodRX.indexIn(self.editor.text(curLine)) == 0 and + self.editor.indentation(curLine) == indentation + ): return True return False @@ -443,8 +468,10 @@ @return flag indicating, if the cursor is inside a triple double quoted string (boolean) """ - return self.editor.currentStyle() == \ + return ( + self.editor.currentStyle() == QsciLexerPython.TripleDoubleQuotedString + ) def __inSingleQuotedString(self): """ @@ -464,5 +491,7 @@ @return flag indicating, if the cursor is inside a triple single quoted string (boolean) """ - return self.editor.currentStyle() == \ + return ( + self.editor.currentStyle() == QsciLexerPython.TripleSingleQuotedString + )