Thu, 04 Jan 2024 11:42:31 +0100
Adjusted some code for eric7 24.2 and newer.
--- a/PluginPyright.py Sat Dec 23 16:07:18 2023 +0100 +++ b/PluginPyright.py Thu Jan 04 11:42:31 2024 +0100 @@ -24,7 +24,7 @@ "author": "Detlev Offenbach <detlev@die-offenbachs.de>", "autoactivate": True, "deactivateable": True, - "version": "10.0.1", + "version": "10.1.0", "className": "PyrightPlugin", "packageName": "PyrightChecker", "shortDescription": "Plug-in to check Python sources for typing issues.",
--- a/PyrightChecker/PyrightCheckerDialog.py Sat Dec 23 16:07:18 2023 +0100 +++ b/PyrightChecker/PyrightCheckerDialog.py Thu Jan 04 11:42:31 2024 +0100 @@ -21,11 +21,31 @@ from eric7 import Preferences from eric7.EricWidgets import EricMessageBox from eric7.EricWidgets.EricApplication import ericApp -from eric7.QScintilla.Editor import Editor from eric7.SystemUtilities import PythonUtilities from .Ui_PyrightCheckerDialog import Ui_PyrightCheckerDialog +try: + from eric7.QScintilla.Editor import EditorWarningKind + + SeverityForEditor = { + "error": EditorWarningKind.Error, + "information": EditorWarningKind.Info, + "warning": EditorWarningKind.Code, + } +except ImportError: + # backward compatibility for eric < 24.2 + from eric7.QScintilla.Editor import Editor + + SeverityForEditor = {"warning": Editor.WarningCode} + try: + SeverityForEditor["error"] = Editor.WarningError + except AttributeError: + SeverityForEditor["error"] = Editor.WarningCode + try: + SeverityForEditor["information"] = Editor.WarningInfo + except AttributeError: + SeverityForEditor["information"] = Editor.WarningCode class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog): """ @@ -58,16 +78,16 @@ "information": self.tr("Information"), } - self.__severityForEditor = {"warning": Editor.WarningCode} - try: - self.__severityForEditor["error"] = Editor.WarningError - except AttributeError: - self.__severityForEditor["error"] = Editor.WarningCode - try: - self.__severityForEditor["information"] = Editor.WarningInfo - except AttributeError: - self.__severityForEditor["information"] = Editor.WarningCode - + ##self.__severityForEditor = {"warning": Editor.WarningCode} + ##try: + ##self.__severityForEditor["error"] = Editor.WarningError + ##except AttributeError: + ##self.__severityForEditor["error"] = Editor.WarningCode + ##try: + ##self.__severityForEditor["information"] = Editor.WarningInfo + ##except AttributeError: + ##self.__severityForEditor["information"] = Editor.WarningCode +## self.__exitCodeMapping = { 0: self.tr("No issues detected"), 1: self.tr("Issues detected"), @@ -407,7 +427,7 @@ start["character"] + 1, True, item.text(2), - warningType=self.__severityForEditor[severity], + warningType=SeverityForEditor[severity], ) editor.updateVerticalScrollBar() @@ -448,7 +468,7 @@ start["character"] + 1, True, citm.text(2), - warningType=self.__severityForEditor[severity], + warningType=SeverityForEditor[severity], ) @pyqtSlot()