Adjusted some code for eric7 24.2 and newer. eric7 release-10.1.0

Thu, 04 Jan 2024 11:42:31 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 04 Jan 2024 11:42:31 +0100
branch
eric7
changeset 13
3a1f3fcfaf31
parent 12
df04105c5630
child 14
215c4e41b986

Adjusted some code for eric7 24.2 and newer.

PluginPyright.py file | annotate | diff | comparison | revisions
PluginPyright.zip file | annotate | diff | comparison | revisions
PyrightChecker/PyrightCheckerDialog.py file | annotate | diff | comparison | revisions
changelog.md file | annotate | diff | comparison | revisions
--- 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.",
Binary file PluginPyright.zip has changed
--- 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()
--- a/changelog.md	Sat Dec 23 16:07:18 2023 +0100
+++ b/changelog.md	Thu Jan 04 11:42:31 2024 +0100
@@ -1,6 +1,10 @@
 ChangeLog
 ---------
 
+__Version 10.1.0__
+
+- adjusted some code for eric7 24.2 and newer
+
 __Version 10.0.1__
 
 - bug fixes

eric ide

mercurial