PyrightChecker/PyrightCheckerDialog.py

Sat, 23 Dec 2023 15:48:45 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Dec 2023 15:48:45 +0100
branch
eric7
changeset 11
55bc88e0aea0
parent 1
191e9ec72893
child 13
3a1f3fcfaf31
permissions
-rw-r--r--

Updated copyright for 2024.

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.QScintilla.Editor import Editor
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 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
26
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 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
28
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 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
31 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Class documentation goes here.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 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
36 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
37 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
38 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
39
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 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
41 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Constructor
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @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
45 @type PyrightPlugin
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @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
47 @type QWidget (optional)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 super().__init__(parent)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setupUi(self)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 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
52
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__plugin = plugin
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 self.__severityMapping = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 "error": self.tr("Error"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 "warning": self.tr("Warning"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 "information": self.tr("Information"),
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
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__severityForEditor = {"warning": Editor.WarningCode}
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__severityForEditor["error"] = Editor.WarningError
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 except AttributeError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__severityForEditor["error"] = Editor.WarningCode
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__severityForEditor["information"] = Editor.WarningInfo
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 except AttributeError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__severityForEditor["information"] = Editor.WarningCode
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__exitCodeMapping = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 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
73 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
74 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
75 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
76 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
77 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.platformComboBox.addItem("", "")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 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
81 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
82 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
83
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 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
85
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__dirOrFileList = []
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__project = None
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.__forProject = False
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__process = None
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__hasResults = False
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.showButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.tomlButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 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
95
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 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
97 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
98
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.__colors = {}
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.on_loadDefaultButton_clicked()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 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
104
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 def __resort(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 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
108 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.resultList.sortItems(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 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
111 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 def __createResultItem(self, result):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 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
116
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @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
118 @type dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 # 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
121 filePath = (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 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
123 if self.__forProject
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 else result["file"]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 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
127 if fileItems:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 fileItem = fileItems[0]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 else:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 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
131 fileItem.setFirstColumnSpanned(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 fileItem.setExpanded(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 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
134
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 itm = QTreeWidgetItem(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 fileItem,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 [
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 "{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
139 self.__severityMapping[result["severity"]],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 result["message"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 ],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 itm.setTextAlignment(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 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
146 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 itm.setTextAlignment(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 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
149 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 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
151
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 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
153 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
154 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
155 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
156
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 with contextlib.suppress(KeyError):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 itm.setData(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 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
160 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 itm.setData(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 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
163 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 def __updateSummary(self, summary):
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 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
168
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 @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
170 @type dict
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 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
173 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
174 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
175 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
176
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 def __processResult(self, result):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 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
180
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @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
182 @type dict
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 # 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
185 self.__colors = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 # 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
187 "error": (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 Preferences.getEditorColour("AnnotationsErrorForeground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 Preferences.getEditorColour("AnnotationsErrorBackground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 "warning": (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Preferences.getEditorColour("AnnotationsWarningForeground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 Preferences.getEditorColour("AnnotationsWarningBackground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 with contextlib.suppress(KeyError):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 # 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
198 self.__colors["information"] = (
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 Preferences.getEditorColour("AnnotationsInfoForeground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 Preferences.getEditorColour("AnnotationsInfoBackground"),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 # 2. set pyright version
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 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
206 except KeyError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 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
208
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 # 3. create result items
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 if result["exitCode"] == 1:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.__hasResults = True
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 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
213 self.__createResultItem(diagnostic)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 else:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 itm = QTreeWidgetItem(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 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
217 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 itm.setFirstColumnSpanned(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 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
221 self.resultList.resizeColumnToContents(col)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 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
223 self.__resort()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 self.resultList.setSortingEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 # 4. set summary information
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.__updateSummary(result["summary"])
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 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
230 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
231
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def getDefaults(self):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 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
235
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 @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
237 @rtype dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 defaults = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 "PythonPlatform": "",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 "PythonVersion": "",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 "SkipUnannotated": False,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 return defaults
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 def prepare(self, project):
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 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
250
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 @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
252 @type Project
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 self.__project = project
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 self.__forProject = True
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 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
257
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 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
259 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
260
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 defaultParameters = self.getDefaults()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 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
263 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
264 # initialize the data structure
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 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
266 else:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 for key in defaultParameters:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 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
269 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
270
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 self.platformComboBox.setCurrentIndex(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 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
273 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 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
275 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
276
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 self.tomlButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 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
280
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 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
282 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 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
284
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 @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
286 @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
287 @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
288 @type bool
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 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
291 self.startButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.restartButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 self.showButton.setEnabled(False)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 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
296 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 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
299 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """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
301 """ 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
302 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 if files and save:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 self.__dirOrFileList = files
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 interpreter = PythonUtilities.getPythonExecutable()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 args = ["-m", "pyright", "--outputjson"]
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 pythonPlatform = self.platformComboBox.currentData()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 if pythonPlatform:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 args.extend(["--pythonplatform", pythonPlatform])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 pythonVersion = self.versionComboBox.currentText()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 if pythonVersion:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 args.extend(["--pythonversion", pythonVersion])
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 if self.skipUnannotatedCheckBox.isChecked():
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 args.append("--skipunannotated")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 if self.__forProject:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 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
322 args.extend(files)
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 self.__process = QProcess(self)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 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
326 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
327 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
328
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 def __readError(self):
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 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
333 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 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
335 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 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
338 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 "<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
340 ).format(errorMsg),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 @pyqtSlot(int, QProcess.ExitStatus)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 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
345 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 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
347
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 @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
349 @type int
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 @param exitStatus exit status
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 @type QProcess.ExitStatus
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 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
354 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
355 self.showButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 self.startButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 self.restartButton.setEnabled(True)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 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
360 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 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
363 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 "<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
365 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 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
370 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 resultDict = json.loads(output)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 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
373 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 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
376 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 "<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
378 " 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
379 ).format(str(err)),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 resultDict["exitCode"] = exitCode
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 self.__processResult(resultDict)
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 @pyqtSlot(QTreeWidgetItem, int)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 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
388 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 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
390
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 @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
392 @type QTreeWidgetItem
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 @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
394 @type int
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 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
397 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
398 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
399 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
400
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 vm = ericApp().getObject("ViewManager")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 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
403 editor = vm.getOpenEditor(fn)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 editor.toggleWarning(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 start["line"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 start["character"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 True,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 item.text(2),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 warningType=self.__severityForEditor[severity],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 editor.updateVerticalScrollBar()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 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
417 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 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
419 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 self.on_startButton_clicked()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 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
424 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 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
426 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 vm = ericApp().getObject("ViewManager")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 selectedIndexes = []
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 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
431 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
432 selectedIndexes.append(index)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 if len(selectedIndexes) == 0:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 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
435
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 for index in selectedIndexes:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 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
438 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
439 vm.openSourceFile(fn, 1)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 editor = vm.getOpenEditor(fn)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self.__clearEditorErrors(editor)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 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
443 citm = itm.child(cindex)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 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
445 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
446 editor.toggleWarning(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 start["line"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 start["character"] + 1,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 True,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 citm.text(2),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 warningType=self.__severityForEditor[severity],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 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
456 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 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
458 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 if self.__forProject:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 data = {
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 "PythonPlatform": self.platformComboBox.currentData(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 "PythonVersion": self.versionComboBox.currentText(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 "SkipUnannotated": self.skipUnannotatedCheckBox.isChecked(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 }
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 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
466 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
467 ):
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 self.__data = data
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 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
470
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 self.__clearErrors()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 self.__clear()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 self.start(self.__dirOrFileList)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 def __clear(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 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
478 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 self.resultList.clear()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 self.__hasResults = False
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 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
483 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 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
485 checked.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 @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
488 @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
489 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 vm = ericApp().getObject("ViewManager")
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 openFiles = vm.getOpenFilenames()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 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
493 # 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
494 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
495 for file in openFiles:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 editor = vm.getOpenEditor(file)
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 editor.clearInfoWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 editor.clearErrorWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 editor.clearCodeWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 except AttributeError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 # eric before 23.12
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 editor.clearFlakesWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 def __clearEditorErrors(self, editor):
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 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
508
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 @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
510 @type Editor
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 try:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 editor.clearInfoWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 editor.clearErrorWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 editor.clearCodeWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 except AttributeError:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 # eric before 23.12
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 editor.clearFlakesWarnings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 ############################################################################
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 ## 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
522 ############################################################################
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 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
526 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 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
528 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 defaultParameters = self.getDefaults()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 settings = Preferences.getSettings()
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 self.platformComboBox.setCurrentIndex(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.platformComboBox.findData(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 settings.value(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 self.__plugin.PreferencesKey + "/PythonPlatform",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 defaultParameters["PythonPlatform"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 )
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 self.versionComboBox.setCurrentText(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 settings.value(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 self.__plugin.PreferencesKey + "/PythonVersion",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 defaultParameters["PythonVersion"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 self.skipUnannotatedCheckBox.setChecked(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 Preferences.toBool(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 settings.value(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 self.__plugin.PreferencesKey + "/SkipUnannotated",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 defaultParameters["SkipUnannotated"],
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 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 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
557 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 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
559 default values.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 settings = Preferences.getSettings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 self.__plugin.PreferencesKey + "/PythonPlatform",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 self.platformComboBox.currentData(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 self.__plugin.PreferencesKey + "/PythonVersion",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 self.versionComboBox.currentText(),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 self.__plugin.PreferencesKey + "/SkipUnannotated",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 self.skipUnannotatedCheckBox.isChecked(),
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
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 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
578 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 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
580 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 defaultParameters = self.getDefaults()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 settings = Preferences.getSettings()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 self.__plugin.PreferencesKey + "/PythonPlatform",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 defaultParameters["PythonPlatform"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 self.__plugin.PreferencesKey + "/PythonVersion",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 defaultParameters["PythonVersion"],
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 settings.setValue(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 self.__plugin.PreferencesKey + "/SkipUnannotated",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 defaultParameters["SkipUnannotated"],
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
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 # 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
598 self.on_loadDefaultButton_clicked()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 @pyqtSlot()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 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
602 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 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
604
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 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
606
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 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
608 'pyproject.toml' file.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 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
611 EricMessageBox.critical(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 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
614 self.tr(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 "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
616 " 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
617 ),
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 )
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 return
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 configDict = self.__getConfigurationDict()
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 pyrightTable = tomlkit.table()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 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
625 pyrightTable[key] = value
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 doc = tomlkit.document()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 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
629 doc["tool"]["pyright"] = pyrightTable
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 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
632
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 EricMessageBox.information(
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 self,
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 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
636 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
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 def __getConfigurationDict(self):
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 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
642 non-default configuration parameters.
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 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
645 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
646
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 @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
648 @rtype dict
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 """
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 configDict = {}
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 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
653 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
654
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 configDict["exclude"] = [
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 "*/node_modules",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 "**/__pycache__",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 "**/Ui_*.py",
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 "**/.*",
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
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 pythonVersion = self.versionComboBox.currentText()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 if pythonVersion:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 configDict["pythonVersion"] = pythonVersion
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 pythonPlatform = self.platformComboBox.currentData()
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 if pythonPlatform:
191e9ec72893 Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 configDict["pythonPlatform"] = pythonPlatform
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 return configDict

eric ide

mercurial