PyrightChecker/PyrightCheckerDialog.py

branch
eric7
changeset 15
e01d64ca960f
parent 13
3a1f3fcfaf31
child 19
cdde4379ce03
--- a/PyrightChecker/PyrightCheckerDialog.py	Thu Jan 04 11:42:47 2024 +0100
+++ b/PyrightChecker/PyrightCheckerDialog.py	Mon Jan 22 11:55:16 2024 +0100
@@ -47,6 +47,7 @@
     except AttributeError:
         SeverityForEditor["information"] = Editor.WarningCode
 
+
 class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog):
     """
     Class documentation goes here.
@@ -78,16 +79,6 @@
             "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.__exitCodeMapping = {
             0: self.tr("No issues detected"),
             1: self.tr("Issues detected"),
@@ -413,7 +404,11 @@
         @param column column the item was activated in
         @type int
         """
-        if self.__hasResults and item.parent():
+        if (
+            self.__hasResults
+            and item.parent()
+            and item.data(0, self.filenameRole) is not None
+        ):
             fn = os.path.abspath(item.data(0, self.filenameRole))
             start = item.data(0, self.startRole)
             severity = item.data(0, self.severityRole)
@@ -455,21 +450,22 @@
 
         for index in selectedIndexes:
             itm = self.resultList.topLevelItem(index)
-            fn = os.path.abspath(itm.data(0, self.filenameRole))
-            vm.openSourceFile(fn, 1)
-            editor = vm.getOpenEditor(fn)
-            self.__clearEditorErrors(editor)
-            for cindex in range(itm.childCount()):
-                citm = itm.child(cindex)
-                start = citm.data(0, self.startRole)
-                severity = citm.data(0, self.severityRole)
-                editor.toggleWarning(
-                    start["line"] + 1,
-                    start["character"] + 1,
-                    True,
-                    citm.text(2),
-                    warningType=SeverityForEditor[severity],
-                )
+            if itm.data(0, self.filenameRole) is not None:
+                fn = os.path.abspath(itm.data(0, self.filenameRole))
+                vm.openSourceFile(fn, 1)
+                editor = vm.getOpenEditor(fn)
+                self.__clearEditorErrors(editor)
+                for cindex in range(itm.childCount()):
+                    citm = itm.child(cindex)
+                    start = citm.data(0, self.startRole)
+                    severity = citm.data(0, self.severityRole)
+                    editor.toggleWarning(
+                        start["line"] + 1,
+                        start["character"] + 1,
+                        True,
+                        citm.text(2),
+                        warningType=SeverityForEditor[severity],
+                    )
 
     @pyqtSlot()
     def on_startButton_clicked(self):

eric ide

mercurial