diff -r f45fd45cb11d -r c18ca679259d src/eric7/QScintilla/Editor.py --- a/src/eric7/QScintilla/Editor.py Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/QScintilla/Editor.py Wed Jan 03 17:36:30 2024 +0100 @@ -92,6 +92,18 @@ TemplateImage = 100 +class EditorWarningKind(enum.Enum): + """ + Class defining the kind of warnings supported by the Editor class. + """ + + Code = 1 + Python = 2 + Style = 3 + Info = 4 + Error = 5 + + class Editor(QsciScintillaCompat): """ Class implementing the editor component of the eric IDE. @@ -169,13 +181,6 @@ settingsRead = pyqtSignal() mouseDoubleClick = pyqtSignal(QPoint, Qt.MouseButton) - # TODO: convert to an enum.Enum - WarningCode = 1 - WarningPython = 2 - WarningStyle = 3 - WarningInfo = 4 - WarningError = 5 - # Cooperation related definitions Separator = "@@@" @@ -6764,10 +6769,14 @@ self.toggleSyntaxError(lineno, col, True, msg) for _fn, lineno, col, _code, msg in problems.get("py_warnings", []): - self.toggleWarning(lineno, col, True, msg, warningType=Editor.WarningPython) + self.toggleWarning( + lineno, col, True, msg, warningType=EditorWarningKind.Python + ) for _fn, lineno, col, _code, msg in problems.get("warnings", []): - self.toggleWarning(lineno, col, True, msg, warningType=Editor.WarningCode) + self.toggleWarning( + lineno, col, True, msg, warningType=EditorWarningKind.Code + ) self.updateVerticalScrollBar() @@ -7222,7 +7231,12 @@ ########################################################################### def toggleWarning( - self, line, col, setWarning, msg="", warningType=WarningCode # noqa: U100 + self, + line, + col, # noqa: U100 + setWarning, + msg="", + warningType=EditorWarningKind.Code, ): """ Public method to toggle a warning indicator. @@ -7239,7 +7253,7 @@ @param msg warning message @type str @param warningType type of warning message - @type int + @type EditorWarningKind """ if line == 0: line = 1 @@ -7343,44 +7357,43 @@ """ Public slot to clear all pyflakes warnings. """ - self.__clearTypedWarning(Editor.WarningCode) - self.__clearTypedWarning(Editor.WarningPython) + self.__clearTypedWarning(EditorWarningKind.Code) + self.__clearTypedWarning(EditorWarningKind.Python) @pyqtSlot() def clearStyleWarnings(self): """ Public slot to clear all style warnings. """ - self.__clearTypedWarning(Editor.WarningStyle) + self.__clearTypedWarning(EditorWarningKind.Style) @pyqtSlot() def clearInfoWarnings(self): """ Public slot to clear all info warnings. """ - self.__clearTypedWarning(Editor.WarningInfo) + self.__clearTypedWarning(EditorWarningKind.Info) @pyqtSlot() def clearErrorWarnings(self): """ Public slot to clear all error warnings. """ - self.__clearTypedWarning(Editor.WarningError) + self.__clearTypedWarning(EditorWarningKind.Error) @pyqtSlot() def clearCodeWarnings(self): """ Public slot to clear all code warnings. """ - self.__clearTypedWarning(Editor.WarningCode) + self.__clearTypedWarning(EditorWarningKind.Code) def __clearTypedWarning(self, warningKind): """ Private method to clear warnings of a specific kind. - @param warningKind kind of warning to clear (Editor.WarningCode, - Editor.WarningPython, Editor.WarningStyle) - @type int + @param warningKind kind of warning to clear + @type EditorWarningKind """ for handle in list(self._warnings): issues = [] @@ -7512,13 +7525,13 @@ for handle in self._warnings: if self.markerLine(handle) == line: for msg, warningType in self._warnings[handle]: - if warningType == Editor.WarningInfo: + if warningType == EditorWarningKind.Info: infoAnnotations.append(self.tr("Info: {0}").format(msg)) - elif warningType == Editor.WarningError: + elif warningType == EditorWarningKind.Error: errorAnnotations.append(self.tr("Error: {0}").format(msg)) - elif warningType == Editor.WarningStyle: + elif warningType == EditorWarningKind.Style: styleAnnotations.append(self.tr("Style: {0}").format(msg)) - elif warningType == Editor.WarningPython: + elif warningType == EditorWarningKind.Python: warningAnnotations.append(msg) else: warningAnnotations.append(