PyrightChecker/PyrightCheckerDialog.py

branch
eric7
changeset 13
3a1f3fcfaf31
parent 11
55bc88e0aea0
child 15
e01d64ca960f
--- 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()

eric ide

mercurial