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