--- a/AssistantEric/Assistant.py Sat May 02 14:52:03 2020 +0200 +++ b/AssistantEric/Assistant.py Mon Jun 22 19:16:15 2020 +0200 @@ -159,8 +159,11 @@ @rtype str """ filename = editor.getFileName() - if self.__project.isOpen() and filename and \ - self.__project.isProjectFile(filename): + if ( + self.__project.isOpen() and + filename and + self.__project.isProjectFile(filename) + ): projectType = self.__project.getProjectType() else: projectType = "" @@ -223,8 +226,10 @@ completeFromDocumentOnly = False if language in ["", "Guessed"] or language.startswith("Pygments|"): - if self.__plugin.getPreferences("AutoCompletionSource") & \ - AcsDocument: + if ( + self.__plugin.getPreferences("AutoCompletionSource") & + AcsDocument + ): completeFromDocumentOnly = True else: return [] @@ -245,8 +250,10 @@ break depth = 0 - while col > 0 and \ - not pat.match(text[col - 1]): + while ( + col > 0 and + not pat.match(text[col - 1]) + ): ch = text[col - 1] if ch == ')': depth = 1 @@ -297,7 +304,7 @@ if col > 0 and beg[col - 1] != " ": col -= 1 prefix = editor.getWordLeft(line, col) - if editor.isPy2File() or editor.isPy3File(): + if editor.isPyFile(): from Utilities.ModuleParser import Module src = editor.text() fn = editor.getFileName() @@ -307,7 +314,7 @@ mod.scan(src) importCompletion = False - if editor.isPy2File() or editor.isPy3File(): + if editor.isPyFile(): # check, if we are completing a from import statement maxLines = 10 text = editor.text(line).strip() @@ -374,14 +381,19 @@ apiCompletionsList = self.__getApiCompletions( api, word, context, prefix, module, editor) - if self.__plugin.getPreferences("AutoCompletionSource") & \ - AcsProject: + if ( + self.__plugin.getPreferences("AutoCompletionSource") & + AcsProject + ): api = self.__apisManager.getAPIs(ApisNameProject) projectCompletionList = self.__getApiCompletions( api, word, context, prefix, module, editor) - if self.__plugin.getPreferences("AutoCompletionSource") & AcsDocument \ - and not importCompletion: + if ( + self.__plugin.getPreferences("AutoCompletionSource") & + AcsDocument and + not importCompletion + ): docCompletionsList = self.__getDocumentCompletions( editor, word, context, sep, prefix, module) @@ -409,8 +421,10 @@ if prefix and module and prefix == "self": line, col = editor.getCursorPosition() for cl in module.classes.values(): - if line >= cl.lineno and \ - (cl.endlineno == -1 or line <= cl.endlineno): + if ( + line >= cl.lineno and + (cl.endlineno == -1 or line <= cl.endlineno) + ): completions = [] for superClass in cl.super: if prefix == word: @@ -523,8 +537,10 @@ if prefix in ["cls", "self"]: prefixFound = True for cl in module.classes.values(): - if line >= cl.lineno and \ - (cl.endlineno == -1 or line <= cl.endlineno): + if ( + line >= cl.lineno and + (cl.endlineno == -1 or line <= cl.endlineno) + ): comps = [] for method in cl.methods.values(): if method.name == "__init__": @@ -536,9 +552,11 @@ iconID = Editor.MethodProtectedID else: iconID = Editor.MethodID - if (prefix == "cls" and - method.modifier == method.Class) or \ - prefix == "self": + if ( + (prefix == "cls" and + method.modifier == method.Class) or + prefix == "self" + ): comps.append((method.name, cl.name, iconID)) if prefix != "cls": for attribute in cl.attributes.values(): @@ -590,8 +608,10 @@ for method in cl.methods.values(): if method.name == "__init__": continue - if doHierarchy or \ - method.modifier in [method.Class, method.Static]: + if ( + doHierarchy or + method.modifier in [method.Class, method.Static] + ): # determine icon type if method.isPrivate(): if doHierarchy: @@ -655,8 +675,11 @@ line, index = editor.lineIndexFromPosition(pos) curWord = editor.getWord(line, index, useWordChars=False) completion += curWord[len(completion):] - if completion and completion not in completionsList and \ - completion != word: + if ( + completion and + completion not in completionsList and + completion != word + ): completionsList.append( "{0}?{1}".format( completion, self.__fromDocumentID)) @@ -704,8 +727,10 @@ completeFromDocumentOnly = False if language in ["", "Guessed"] or language.startswith("Pygments|"): - if self.__plugin.getPreferences("AutoCompletionSource") & \ - AcsDocument: + if ( + self.__plugin.getPreferences("AutoCompletionSource") & + AcsDocument + ): completeFromDocumentOnly = True else: return [] @@ -716,8 +741,7 @@ wc = re.sub("\w", "", editor.wordCharacters()) pat = re.compile("\w{0}".format(re.escape(wc))) text = editor.text(line) - while col > 0 and \ - not pat.match(text[col - 1]): + while col > 0 and not pat.match(text[col - 1]): col -= 1 word = editor.getWordLeft(line, col) @@ -738,7 +762,7 @@ if col >= 0: col -= 1 prefix = editor.getWordLeft(line, col) - if editor.isPy2File() or editor.isPy3File(): + if editor.isPyFile(): from Utilities.ModuleParser import Module src = editor.text() fn = editor.getFileName() @@ -759,8 +783,10 @@ apiCalltips = self.__getApiCalltips( api, word, commas, prefix, mod, editor) - if self.__plugin.getPreferences("AutoCompletionSource") & \ - AcsProject: + if ( + self.__plugin.getPreferences("AutoCompletionSource") & + AcsProject + ): api = self.__apisManager.getAPIs(ApisNameProject) projectCalltips = self.__getApiCalltips( api, word, commas, prefix, mod, editor) @@ -792,8 +818,10 @@ if prefix and module and prefix == "self": line, col = editor.getCursorPosition() for cl in module.classes.values(): - if line >= cl.lineno and \ - (cl.endlineno == -1 or line <= cl.endlineno): + if ( + line >= cl.lineno and + (cl.endlineno == -1 or line <= cl.endlineno) + ): for superClass in cl.super: calltips.extend(api.getCalltips( word, commas, superClass, None, @@ -829,13 +857,17 @@ if prefix in ["self", "cls"]: line, col = editor.getCursorPosition() for cl in module.classes.values(): - if line >= cl.lineno and \ - (cl.endlineno == -1 or line <= cl.endlineno): + if ( + line >= cl.lineno and + (cl.endlineno == -1 or line <= cl.endlineno) + ): if word in cl.methods: method = cl.methods[word] - if prefix == "self" or \ - (prefix == "cls" and - method.modifier == method.Class): + if ( + prefix == "self" or + (prefix == "cls" and + method.modifier == method.Class) + ): calltips.append( "{0}{1}{2}({3})".format( cl.name, @@ -881,3 +913,6 @@ ', '.join(method.parameters[1:]))) return calltips + +# +# eflag: noqa = M834, W605