--- a/AssistantEric/Assistant.py Sun May 28 14:34:08 2023 +0200 +++ b/AssistantEric/Assistant.py Wed Aug 30 11:38:43 2023 +0200 @@ -8,12 +8,13 @@ calltips system. """ -import imp import re from PyQt6.QtCore import QObject from eric7.EricWidgets.EricApplication import ericApp +from eric7.QScintilla.Editor import Editor +from eric7.Utilities.ModuleParser import PY_SOURCE, Module from .APIsManager import APIsManager, ApisNameProject @@ -50,8 +51,6 @@ self.__lastContext = None self.__lastFullContext = None - from eric7.QScintilla.Editor import Editor - self.__fromDocumentID = Editor.FromDocumentID def activate(self): @@ -93,7 +92,11 @@ self.__apisManager.deactivate() - def setEnabled(self, key, enabled): + def setEnabled( + self, + key, # noqa: U100 + enabled, # noqa: U100 + ): """ Public method to enable or disable a feature. @@ -241,8 +244,8 @@ line, col = editor.getCursorPosition() sep = "" if language and context: - wc = re.sub("\w", "", editor.wordCharacters()) - pat = re.compile("\w{0}".format(re.escape(wc))) + wc = re.sub(r"\w", "", editor.wordCharacters()) + pat = re.compile(r"\w{0}".format(re.escape(wc))) text = editor.text(line) beg = text[:col] @@ -298,13 +301,11 @@ col -= 1 prefix = editor.getWordLeft(line, col) if editor.isPyFile(): - from eric7.Utilities.ModuleParser import Module - src = editor.text() fn = editor.getFileName() if fn is None: fn = "" - mod = Module("", fn, imp.PY_SOURCE) + mod = Module("", fn, PY_SOURCE) mod.scan(src) importCompletion = False @@ -534,7 +535,7 @@ entry += "?{0}".format(completion["pictureId"]) else: cont = False - regexp = re.compile(re.escape(entry) + "\?\d{,2}") + regexp = re.compile(re.escape(entry) + r"\?\d{,2}") for comp in completionsList: if regexp.fullmatch(comp): cont = True @@ -572,8 +573,6 @@ prefixFound = False if prefix and module: - from eric7.QScintilla.Editor import Editor - line, col = editor.getCursorPosition() if prefix in ["cls", "self"]: prefixFound = True @@ -804,8 +803,8 @@ projectType = self.__getProjectType(editor) line, col = editor.lineIndexFromPosition(pos) - wc = re.sub("\w", "", editor.wordCharacters()) - pat = re.compile("\w{0}".format(re.escape(wc))) + wc = re.sub(r"\w", "", editor.wordCharacters()) + pat = re.compile(r"\w{0}".format(re.escape(wc))) text = editor.text(line) while col > 0 and not pat.match(text[col - 1]): col -= 1 @@ -826,13 +825,11 @@ col -= 1 prefix = editor.getWordLeft(line, col) if editor.isPyFile(): - from eric7.Utilities.ModuleParser import Module - src = editor.text() fn = editor.getFileName() if fn is None: fn = "" - mod = Module("", fn, imp.PY_SOURCE) + mod = Module("", fn, PY_SOURCE) mod.scan(src) apiCalltips = []