PyrightChecker/PyrightCheckerDialog.py

branch
eric7
changeset 13
3a1f3fcfaf31
parent 11
55bc88e0aea0
child 15
e01d64ca960f
equal deleted inserted replaced
12:df04105c5630 13:3a1f3fcfaf31
19 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem 19 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem
20 20
21 from eric7 import Preferences 21 from eric7 import Preferences
22 from eric7.EricWidgets import EricMessageBox 22 from eric7.EricWidgets import EricMessageBox
23 from eric7.EricWidgets.EricApplication import ericApp 23 from eric7.EricWidgets.EricApplication import ericApp
24 from eric7.QScintilla.Editor import Editor
25 from eric7.SystemUtilities import PythonUtilities 24 from eric7.SystemUtilities import PythonUtilities
26 25
27 from .Ui_PyrightCheckerDialog import Ui_PyrightCheckerDialog 26 from .Ui_PyrightCheckerDialog import Ui_PyrightCheckerDialog
28 27
28 try:
29 from eric7.QScintilla.Editor import EditorWarningKind
30
31 SeverityForEditor = {
32 "error": EditorWarningKind.Error,
33 "information": EditorWarningKind.Info,
34 "warning": EditorWarningKind.Code,
35 }
36 except ImportError:
37 # backward compatibility for eric < 24.2
38 from eric7.QScintilla.Editor import Editor
39
40 SeverityForEditor = {"warning": Editor.WarningCode}
41 try:
42 SeverityForEditor["error"] = Editor.WarningError
43 except AttributeError:
44 SeverityForEditor["error"] = Editor.WarningCode
45 try:
46 SeverityForEditor["information"] = Editor.WarningInfo
47 except AttributeError:
48 SeverityForEditor["information"] = Editor.WarningCode
29 49
30 class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog): 50 class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog):
31 """ 51 """
32 Class documentation goes here. 52 Class documentation goes here.
33 """ 53 """
56 "error": self.tr("Error"), 76 "error": self.tr("Error"),
57 "warning": self.tr("Warning"), 77 "warning": self.tr("Warning"),
58 "information": self.tr("Information"), 78 "information": self.tr("Information"),
59 } 79 }
60 80
61 self.__severityForEditor = {"warning": Editor.WarningCode} 81 ##self.__severityForEditor = {"warning": Editor.WarningCode}
62 try: 82 ##try:
63 self.__severityForEditor["error"] = Editor.WarningError 83 ##self.__severityForEditor["error"] = Editor.WarningError
64 except AttributeError: 84 ##except AttributeError:
65 self.__severityForEditor["error"] = Editor.WarningCode 85 ##self.__severityForEditor["error"] = Editor.WarningCode
66 try: 86 ##try:
67 self.__severityForEditor["information"] = Editor.WarningInfo 87 ##self.__severityForEditor["information"] = Editor.WarningInfo
68 except AttributeError: 88 ##except AttributeError:
69 self.__severityForEditor["information"] = Editor.WarningCode 89 ##self.__severityForEditor["information"] = Editor.WarningCode
70 90 ##
71 self.__exitCodeMapping = { 91 self.__exitCodeMapping = {
72 0: self.tr("No issues detected"), 92 0: self.tr("No issues detected"),
73 1: self.tr("Issues detected"), 93 1: self.tr("Issues detected"),
74 2: self.tr("Fatal error occurred with no errors or warnings reported"), 94 2: self.tr("Fatal error occurred with no errors or warnings reported"),
75 3: self.tr("Config file could not be read or parsed"), 95 3: self.tr("Config file could not be read or parsed"),
405 editor.toggleWarning( 425 editor.toggleWarning(
406 start["line"] + 1, 426 start["line"] + 1,
407 start["character"] + 1, 427 start["character"] + 1,
408 True, 428 True,
409 item.text(2), 429 item.text(2),
410 warningType=self.__severityForEditor[severity], 430 warningType=SeverityForEditor[severity],
411 ) 431 )
412 432
413 editor.updateVerticalScrollBar() 433 editor.updateVerticalScrollBar()
414 434
415 @pyqtSlot() 435 @pyqtSlot()
446 editor.toggleWarning( 466 editor.toggleWarning(
447 start["line"] + 1, 467 start["line"] + 1,
448 start["character"] + 1, 468 start["character"] + 1,
449 True, 469 True,
450 citm.text(2), 470 citm.text(2),
451 warningType=self.__severityForEditor[severity], 471 warningType=SeverityForEditor[severity],
452 ) 472 )
453 473
454 @pyqtSlot() 474 @pyqtSlot()
455 def on_startButton_clicked(self): 475 def on_startButton_clicked(self):
456 """ 476 """

eric ide

mercurial