PyrightChecker/PyrightCheckerDialog.py

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 11
55bc88e0aea0
child 15
e01d64ca960f
permissions
-rw-r--r--

Adjusted some code for eric7 24.2 and newer.

1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
11
55bc88e0aea0 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
3 # Copyright (c) 2023 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the pyright type checker dialog.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import contextlib
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import copy
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import json
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import os
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import tomlkit
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt6.QtCore import QProcess, Qt, pyqtSlot
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from PyQt6.QtGui import QGuiApplication
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from eric7 import Preferences
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from eric7.EricWidgets import EricMessageBox
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 from eric7.EricWidgets.EricApplication import ericApp
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 from eric7.SystemUtilities import PythonUtilities
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from .Ui_PyrightCheckerDialog import Ui_PyrightCheckerDialog
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
13
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
28 try:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
29 from eric7.QScintilla.Editor import EditorWarningKind
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
30
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
31 SeverityForEditor = {
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
32 "error": EditorWarningKind.Error,
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
33 "information": EditorWarningKind.Info,
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
34 "warning": EditorWarningKind.Code,
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
35 }
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
36 except ImportError:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
37 # backward compatibility for eric < 24.2
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
38 from eric7.QScintilla.Editor import Editor
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
39
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
40 SeverityForEditor = {"warning": Editor.WarningCode}
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
41 try:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
42 SeverityForEditor["error"] = Editor.WarningError
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
43 except AttributeError:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
44 SeverityForEditor["error"] = Editor.WarningCode
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
45 try:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
46 SeverityForEditor["information"] = Editor.WarningInfo
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
47 except AttributeError:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
48 SeverityForEditor["information"] = Editor.WarningCode
1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 class PyrightCheckerDialog(QDialog, Ui_PyrightCheckerDialog):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 Class documentation goes here.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 filenameRole = Qt.ItemDataRole.UserRole + 1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 severityRole = Qt.ItemDataRole.UserRole + 2
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 startRole = Qt.ItemDataRole.UserRole + 3
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 endRole = Qt.ItemDataRole.UserRole + 4
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def __init__(self, plugin, parent=None):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Constructor
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @param plugin reference to the plugin object
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @type PyrightPlugin
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param parent reference to the parent widget (defaults to None)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @type QWidget (optional)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 super().__init__(parent)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.setupUi(self)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.setWindowFlags(Qt.WindowType.Window)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__plugin = plugin
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__severityMapping = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 "error": self.tr("Error"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 "warning": self.tr("Warning"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 "information": self.tr("Information"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
13
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
81 ##self.__severityForEditor = {"warning": Editor.WarningCode}
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
82 ##try:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
83 ##self.__severityForEditor["error"] = Editor.WarningError
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
84 ##except AttributeError:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
85 ##self.__severityForEditor["error"] = Editor.WarningCode
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
86 ##try:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
87 ##self.__severityForEditor["information"] = Editor.WarningInfo
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
88 ##except AttributeError:
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
89 ##self.__severityForEditor["information"] = Editor.WarningCode
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
90 ##
1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__exitCodeMapping = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 0: self.tr("No issues detected"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 1: self.tr("Issues detected"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 2: self.tr("Fatal error occurred with no errors or warnings reported"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 3: self.tr("Config file could not be read or parsed"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 4: self.tr("Illegal command-line parameters specified"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.platformComboBox.addItem("", "")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.platformComboBox.addItem("Linux", "Linux")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.platformComboBox.addItem("macOS", "Darwin")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.platformComboBox.addItem("Windows", "Windows")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.versionComboBox.addItems(["", "3.8", "3.9", "3.10", "3.11", "3.12"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__dirOrFileList = []
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__project = None
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__forProject = False
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.__process = None
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__hasResults = False
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.showButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.tomlButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.resultList.headerItem().setText(self.resultList.columnCount(), "")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.resultList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__colors = {}
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.on_loadDefaultButton_clicked()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.mainWidget.setCurrentWidget(self.configureTab)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 def __resort(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 Private method to resort the tree.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.resultList.sortItems(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.resultList.sortColumn(), self.resultList.header().sortIndicatorOrder()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 def __createResultItem(self, result):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 Private method to create an entry in the result list.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @param result dictionary containing check result data
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @type dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 # step 1: search the file entry or create it
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 filePath = (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.__project.getRelativePath(result["file"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 if self.__forProject
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 else result["file"]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 fileItems = self.resultList.findItems(filePath, Qt.MatchFlag.MatchExactly, 0)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 if fileItems:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 fileItem = fileItems[0]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 else:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 fileItem = QTreeWidgetItem(self.resultList, [filePath])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 fileItem.setFirstColumnSpanned(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 fileItem.setExpanded(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 fileItem.setData(0, self.filenameRole, result["file"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 itm = QTreeWidgetItem(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 fileItem,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 [
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 "{0:6}".format(result["range"]["start"]["line"] + 1),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__severityMapping[result["severity"]],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 result["message"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 ],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 itm.setTextAlignment(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 0, Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 itm.setTextAlignment(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 1, Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignVCenter)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 itm.setData(0, self.filenameRole, result["file"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 itm.setData(0, self.severityRole, result["severity"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 itm.setData(0, self.startRole, result["range"]["start"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 itm.setData(0, self.endRole, result["range"]["end"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 with contextlib.suppress(KeyError):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 itm.setData(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 1, Qt.ItemDataRole.ForegroundRole, self.__colors[result["severity"]][0]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 itm.setData(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 1, Qt.ItemDataRole.BackgroundRole, self.__colors[result["severity"]][1]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def __updateSummary(self, summary):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Private method to update the summary data of the dialog.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @param summary dictionary containing the summary data
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 @type dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self.filesLabel.setText(str(summary["filesAnalyzed"]))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.errorLabel.setText(str(summary["errorCount"]))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 self.warningLabel.setText(str(summary["warningCount"]))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.infoLabel.setText(str(summary["informationCount"]))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 def __processResult(self, result):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 Private method to process the pyright result.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @param result dictionary containing the type checking result.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @type dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 # 1. update the severity color mapping
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.__colors = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 # tuple of foreground and background colors
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 "error": (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 Preferences.getEditorColour("AnnotationsErrorForeground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 Preferences.getEditorColour("AnnotationsErrorBackground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 "warning": (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Preferences.getEditorColour("AnnotationsWarningForeground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 Preferences.getEditorColour("AnnotationsWarningBackground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 with contextlib.suppress(KeyError):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 # eric-ide before 23.12 doesn't have this color
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 self.__colors["information"] = (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 Preferences.getEditorColour("AnnotationsInfoForeground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 Preferences.getEditorColour("AnnotationsInfoBackground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 # 2. set pyright version
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.pyrightLabel.setText(result["version"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 except KeyError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.pyrightLabel.setText(self.tr("unknown"))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 # 3. create result items
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 if result["exitCode"] == 1:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.__hasResults = True
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 for diagnostic in result["generalDiagnostics"]:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 self.__createResultItem(diagnostic)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 else:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 itm = QTreeWidgetItem(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.resultList, self.__exitCodeMapping[result["exitCode"]]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 itm.setFirstColumnSpanned(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 for col in range(self.resultList.columnCount()):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 self.resultList.resizeColumnToContents(col)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 self.resultList.header().setStretchLastSection(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.__resort()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 self.resultList.setSortingEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 # 4. set summary information
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.__updateSummary(result["summary"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 self.showButton.setEnabled(self.__hasResults)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.mainWidget.setCurrentWidget(self.resultsTab)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 def getDefaults(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 Public method to get a dictionary containing the default values.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 @return dictionary containing the default values
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 @rtype dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 defaults = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 "PythonPlatform": "",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 "PythonVersion": "",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 "SkipUnannotated": False,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 return defaults
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 def prepare(self, project):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 Public method to prepare the dialog with a list of filenames.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 @param project reference to the project object
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @type Project
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 self.__project = project
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 self.__forProject = True
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 self.__dirOrFileList = [self.__project.getProjectPath()]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 defaultParameters = self.getDefaults()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 self.__data = self.__project.getData("CHECKERSPARMS", "PyrightChecker")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 if self.__data is None:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 # initialize the data structure
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 self.__data = copy.deepcopy(defaultParameters)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 else:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 for key in defaultParameters:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 if key not in self.__data:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.__data[key] = defaultParameters[key]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.platformComboBox.setCurrentIndex(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.platformComboBox.findData(self.__data["PythonPlatform"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 self.versionComboBox.setCurrentText(self.__data["PythonVersion"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 self.skipUnannotatedCheckBox.setChecked(self.__data["SkipUnannotated"])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.tomlButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 self.mainWidget.setCurrentWidget(self.configureTab)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 def start(self, files=None, save=False):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 Public method to start a pyright type checking run.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 @param files list of files to be checked (defaults to None)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @type list of str (optional)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 @param save flag indicating to save the given file/file list/directory
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 @type bool
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 self.startButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 self.restartButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 self.showButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 if not files and not self.__forProject:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 self.tr("pyright Type Checking"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 """pyright type checking has to be performed for individual"""
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 """ files or a project but neither was given. Aborting..."""
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 if files and save:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.__dirOrFileList = files
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 interpreter = PythonUtilities.getPythonExecutable()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 args = ["-m", "pyright", "--outputjson"]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 pythonPlatform = self.platformComboBox.currentData()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 if pythonPlatform:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 args.extend(["--pythonplatform", pythonPlatform])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 pythonVersion = self.versionComboBox.currentText()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 if pythonVersion:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 args.extend(["--pythonversion", pythonVersion])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 if self.skipUnannotatedCheckBox.isChecked():
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 args.append("--skipunannotated")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 if self.__forProject:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 args.extend(["--project", self.__project.getProjectPath()])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 args.extend(files)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 self.__process = QProcess(self)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 self.__process.readyReadStandardError.connect(self.__readError)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 self.__process.finished.connect(self.__pyrightProcessFinished)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.__process.start(interpreter, args)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 def __readError(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 Private slot to get the output of the error channel and show it to the user.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 errorMsg = str(self.__process.readAllStandardError(), encoding="utf-8")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 self.tr("pyright Type Checking"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 "<p>The pyright type checking run failed.</p><p>Reason: {0}</p>"
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 ).format(errorMsg),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 @pyqtSlot(int, QProcess.ExitStatus)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 def __pyrightProcessFinished(self, exitCode, exitStatus):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 Private slot to process the pyright result.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 @param exitCode exit code of the pyright process
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 @type int
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 @param exitStatus exit status
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 @type QProcess.ExitStatus
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 self.showButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 self.startButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 self.restartButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 if exitStatus != QProcess.ExitStatus.NormalExit:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 self.tr("pyright Type Checking"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 "<p>The pyright type checking process did not end normally.</p>"
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 output = str(self.__process.readAllStandardOutput(), encoding="utf-8")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 resultDict = json.loads(output)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 except json.JSONDecodeError as err:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 self.tr("pyright Type Checking"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 "<p>The pyright type checking process did not return valid"
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 " JSON data.</p><p>Issue: {0}</p>"
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 ).format(str(err)),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 resultDict["exitCode"] = exitCode
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 self.__processResult(resultDict)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 @pyqtSlot(QTreeWidgetItem, int)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 def on_resultList_itemActivated(self, item, column):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 Private slot to handle the activation of an item.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 @param item reference to the activated item
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 @type QTreeWidgetItem
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 @param column column the item was activated in
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 @type int
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 if self.__hasResults and item.parent():
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 fn = os.path.abspath(item.data(0, self.filenameRole))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 start = item.data(0, self.startRole)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 severity = item.data(0, self.severityRole)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 vm = ericApp().getObject("ViewManager")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 vm.openSourceFile(fn, lineno=start["line"] + 1, pos=start["character"] + 1)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 editor = vm.getOpenEditor(fn)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 editor.toggleWarning(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 start["line"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 start["character"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 True,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 item.text(2),
13
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
430 warningType=SeverityForEditor[severity],
1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 editor.updateVerticalScrollBar()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 def on_restartButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 Private slot to restart the configured check.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 self.on_startButton_clicked()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 def on_showButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 Private slot to handle the "Show" button press.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 vm = ericApp().getObject("ViewManager")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 selectedIndexes = []
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 for index in range(self.resultList.topLevelItemCount()):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 if self.resultList.topLevelItem(index).isSelected():
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 selectedIndexes.append(index)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 if len(selectedIndexes) == 0:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 selectedIndexes = list(range(self.resultList.topLevelItemCount()))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 for index in selectedIndexes:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 itm = self.resultList.topLevelItem(index)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 fn = os.path.abspath(itm.data(0, self.filenameRole))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 vm.openSourceFile(fn, 1)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 editor = vm.getOpenEditor(fn)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 self.__clearEditorErrors(editor)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 for cindex in range(itm.childCount()):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 citm = itm.child(cindex)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 start = citm.data(0, self.startRole)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 severity = citm.data(0, self.severityRole)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 editor.toggleWarning(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 start["line"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 start["character"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 True,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 citm.text(2),
13
3a1f3fcfaf31 Adjusted some code for eric7 24.2 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
471 warningType=SeverityForEditor[severity],
1
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 def on_startButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 Private slot to start the pyright type checking run.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 if self.__forProject:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 data = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 "PythonPlatform": self.platformComboBox.currentData(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 "PythonVersion": self.versionComboBox.currentText(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 "SkipUnannotated": self.skipUnannotatedCheckBox.isChecked(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 if json.dumps(data, sort_keys=True) != json.dumps(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 self.__data, sort_keys=True
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 ):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 self.__data = data
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 self.__project.setData("CHECKERSPARMS", "PyrightChecker", self.__data)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 self.__clearErrors()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 self.__clear()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 self.start(self.__dirOrFileList)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 def __clear(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 Private method to clear the dialog.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 self.resultList.clear()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.__hasResults = False
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 def __clearErrors(self, files=None):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 Private method to clear all warning markers of open editors to be
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 checked.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 @param files list of files to be checked (defaults to None
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 @type list of str (optional
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 vm = ericApp().getObject("ViewManager")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 openFiles = vm.getOpenFilenames()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 if files is not None:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 # filter out the files checked
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 openFiles = [f for f in openFiles if f in files]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 for file in openFiles:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 editor = vm.getOpenEditor(file)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 editor.clearInfoWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 editor.clearErrorWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 editor.clearCodeWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 except AttributeError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 # eric before 23.12
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 editor.clearFlakesWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 def __clearEditorErrors(self, editor):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 Private method to clear all warning markers of an editor.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 @param editor reference to the editor to be cleared
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 @type Editor
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 editor.clearInfoWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 editor.clearErrorWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 editor.clearCodeWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 except AttributeError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 # eric before 23.12
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 editor.clearFlakesWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 ############################################################################
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 ## Methods for storing, loading and resetting the default values. ##
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 ############################################################################
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 def on_loadDefaultButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 Private slot to load the default configuration values.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 defaultParameters = self.getDefaults()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 settings = Preferences.getSettings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 self.platformComboBox.setCurrentIndex(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 self.platformComboBox.findData(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 settings.value(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 self.__plugin.PreferencesKey + "/PythonPlatform",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 defaultParameters["PythonPlatform"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 self.versionComboBox.setCurrentText(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 settings.value(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 self.__plugin.PreferencesKey + "/PythonVersion",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 defaultParameters["PythonVersion"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 self.skipUnannotatedCheckBox.setChecked(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 Preferences.toBool(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 settings.value(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 self.__plugin.PreferencesKey + "/SkipUnannotated",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 defaultParameters["SkipUnannotated"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 def on_storeDefaultButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 Private slot to store the current configuration values as
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 default values.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 settings = Preferences.getSettings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 self.__plugin.PreferencesKey + "/PythonPlatform",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 self.platformComboBox.currentData(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 self.__plugin.PreferencesKey + "/PythonVersion",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 self.versionComboBox.currentText(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 self.__plugin.PreferencesKey + "/SkipUnannotated",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 self.skipUnannotatedCheckBox.isChecked(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 def on_resetDefaultButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 Private slot to reset the configuration values to their default values.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 defaultParameters = self.getDefaults()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 settings = Preferences.getSettings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 self.__plugin.PreferencesKey + "/PythonPlatform",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 defaultParameters["PythonPlatform"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 self.__plugin.PreferencesKey + "/PythonVersion",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 defaultParameters["PythonVersion"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 self.__plugin.PreferencesKey + "/SkipUnannotated",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 defaultParameters["SkipUnannotated"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 # Update UI with default values
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 self.on_loadDefaultButton_clicked()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 def on_tomlButton_clicked(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 Private slot to generate a TOML snippet of the current configuration.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 Note: Only non-default values are included in this snippet.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 The code snippet is copied to the clipboard and may be placed inside the
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 'pyproject.toml' file.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 if not self.__forProject or self.__project is None:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.tr("Create TOML snippet"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 "The creation of a 'pyproject.toml' snippet is only available"
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 " when in project mode. Aborting..."
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 configDict = self.__getConfigurationDict()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 pyrightTable = tomlkit.table()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 for key, value in configDict.items():
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 pyrightTable[key] = value
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 doc = tomlkit.document()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 doc["tool"] = tomlkit.table(is_super_table=True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 doc["tool"]["pyright"] = pyrightTable
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 QGuiApplication.clipboard().setText(tomlkit.dumps(doc))
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 EricMessageBox.information(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 self.tr("Create TOML snippet"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 self.tr("""The 'pyproject.toml' snippet was copied to the clipboard."""),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 def __getConfigurationDict(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 Private method to assemble and return a dictionary containing the entered
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 non-default configuration parameters.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 The configuration dictionary is amended with some common parameters not
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 accessible via the configuration tab.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 @return dictionary containing the non-default configuration parameters
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 @rtype dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 configDict = {}
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 srcDir = self.__project.getProjectData("SOURCESDIR")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 configDict["include"] = [srcDir] if srcDir else []
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 configDict["exclude"] = [
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 "*/node_modules",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 "**/__pycache__",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 "**/Ui_*.py",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 "**/.*",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 ]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 pythonVersion = self.versionComboBox.currentText()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 if pythonVersion:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 configDict["pythonVersion"] = pythonVersion
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 pythonPlatform = self.platformComboBox.currentData()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 if pythonPlatform:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 configDict["pythonPlatform"] = pythonPlatform
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
689
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 return configDict

eric ide

mercurial