Sat, 23 Dec 2023 15:48:45 +0100
Updated copyright for 2024.
1
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
2 | |
11
55bc88e0aea0
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
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:
0
diff
changeset
|
4 | # |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
5 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
6 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
7 | Module implementing the pyright plug-in. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
8 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
9 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
10 | import contextlib |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
11 | import os |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
12 | |
3
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
13 | from PyQt6.QtCore import QCoreApplication, QObject, QTranslator, pyqtSlot |
1
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
14 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
15 | from eric7 import Preferences |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
16 | from eric7.EricGui.EricAction import EricAction |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
17 | from eric7.EricWidgets.EricApplication import ericApp |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
18 | from eric7.Project.ProjectBrowserModel import ProjectBrowserFileItem |
3
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
19 | from eric7.SystemUtilities import PythonUtilities |
1
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
20 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
21 | # Start-Of-Header |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
22 | __header__ = { |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
23 | "name": "Python Typing Checker Plug-in", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
24 | "author": "Detlev Offenbach <detlev@die-offenbachs.de>", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
25 | "autoactivate": True, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
26 | "deactivateable": True, |
9
1ef1797f5f58
Added some forgotten code causing translations not to be loaded.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3
diff
changeset
|
27 | "version": "10.0.1", |
1
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
28 | "className": "PyrightPlugin", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
29 | "packageName": "PyrightChecker", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
30 | "shortDescription": "Plug-in to check Python sources for typing issues.", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
31 | "longDescription": ("""Plug-in to check Python sources for typing issues."""), |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
32 | "needsRestart": False, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
33 | "pyqtApi": 2, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
34 | } |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
35 | # End-Of-Header |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
36 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
37 | error = "" # noqa: U200 |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
38 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
39 | |
3
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
40 | def exeDisplayData(): |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
41 | """ |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
42 | Public method to support the display of some executable info. |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
43 | |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
44 | @return dictionary containing the data to query the presence of |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
45 | the executable |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
46 | @rtype dict |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
47 | """ |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
48 | data = { |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
49 | "programEntry": True, |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
50 | "header": QCoreApplication.translate( |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
51 | "PyrightPlugin", "Checkers - Pyright" |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
52 | ), |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
53 | "exe": PythonUtilities.getPythonExecutable(), |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
54 | "versionCommand": "--version", |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
55 | "versionStartsWith": "pyright", |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
56 | "versionPosition": -1, |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
57 | "version": "", |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
58 | "versionCleanup": None, |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
59 | "exeModule": ["-m", "pyright"] |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
60 | } |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
61 | |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
62 | return data |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
63 | |
109b8e5513d8
Added the plugin function to determine the interfaced executable version information.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
64 | |
1
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
65 | def prepareUninstall(): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
66 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
67 | Module function to prepare for an uninstallation. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
68 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
69 | Preferences.Prefs.settings.remove(PyrightPlugin.PreferencesKey) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
70 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
71 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
72 | class PyrightPlugin(QObject): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
73 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
74 | Class documentation goes here. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
75 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
76 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
77 | PreferencesKey = "Pyright" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
78 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
79 | def __init__(self, ui): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
80 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
81 | Constructor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
82 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
83 | @param ui reference to the user interface object |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
84 | @type UI.UserInterface |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
85 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
86 | super().__init__(ui) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
87 | self.__ui = ui |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
88 | self.__initialize() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
89 | |
9
1ef1797f5f58
Added some forgotten code causing translations not to be loaded.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3
diff
changeset
|
90 | self.__translator = None |
1ef1797f5f58
Added some forgotten code causing translations not to be loaded.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3
diff
changeset
|
91 | self.__loadTranslator() |
1ef1797f5f58
Added some forgotten code causing translations not to be loaded.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3
diff
changeset
|
92 | |
1
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
93 | def __initialize(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
94 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
95 | Private slot to (re)initialize the plug-in. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
96 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
97 | self.__projectAct = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
98 | self.__projectPyrightCheckerDialog = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
99 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
100 | self.__projectBrowserAct = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
101 | self.__projectBrowserMenu = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
102 | self.__projectBrowserPyrightCheckerDialog = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
103 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
104 | self.__editors = [] |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
105 | self.__editorAct = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
106 | self.__editorPyrightCheckerDialog = None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
107 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
108 | def activate(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
109 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
110 | Public method to activate this plug-in. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
111 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
112 | @return tuple of None and activation status |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
113 | @rtype bool |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
114 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
115 | global error |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
116 | error = "" # clear previous error |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
117 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
118 | menu = ericApp().getObject("Project").getMenu("Checks") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
119 | if menu: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
120 | self.__projectAct = EricAction( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
121 | self.tr("Static Type Check"), |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
122 | self.tr("Static &Typing..."), |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
123 | 0, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
124 | 0, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
125 | self, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
126 | "project_check_pyright", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
127 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
128 | self.__projectAct.setStatusTip(self.tr("Check for typing issues")) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
129 | self.__projectAct.setWhatsThis( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
130 | self.tr( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
131 | """<b>Static Type Check...</b>""" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
132 | """<p>This checks a Python project for static typing issues.</p>""" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
133 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
134 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
135 | self.__projectAct.triggered.connect(self.__projectPyrightCheck) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
136 | ericApp().getObject("Project").addEricActions([self.__projectAct]) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
137 | menu.addAction(self.__projectAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
138 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
139 | self.__editorAct = EricAction( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
140 | self.tr("Static Type Check"), self.tr("Static &Typing..."), 0, 0, self, "" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
141 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
142 | self.__editorAct.setWhatsThis( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
143 | self.tr( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
144 | """<b>Static Type Check...</b>""" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
145 | """<p>This checks a Python file for static typing issues.</p>""" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
146 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
147 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
148 | self.__editorAct.triggered.connect(self.__editorPyrightCheck) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
149 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
150 | ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
151 | ericApp().getObject("ProjectBrowser").getProjectBrowser( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
152 | "sources" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
153 | ).showMenu.connect(self.__projectBrowserShowMenu) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
154 | ericApp().getObject("ViewManager").editorOpenedEd.connect(self.__editorOpened) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
155 | ericApp().getObject("ViewManager").editorClosedEd.connect(self.__editorClosed) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
156 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
157 | for editor in ericApp().getObject("ViewManager").getOpenEditors(): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
158 | self.__editorOpened(editor) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
159 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
160 | return None, True |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
161 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
162 | def deactivate(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
163 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
164 | Public method to deactivate this plug-in. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
165 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
166 | ericApp().getObject("Project").showMenu.disconnect(self.__projectShowMenu) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
167 | ericApp().getObject("ProjectBrowser").getProjectBrowser( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
168 | "sources" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
169 | ).showMenu.disconnect(self.__projectBrowserShowMenu) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
170 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
171 | menu = ericApp().getObject("Project").getMenu("Checks") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
172 | if menu is not None and self.__projectAct is not None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
173 | menu.removeAction(self.__projectAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
174 | ericApp().getObject("Project").removeEricActions([self.__projectAct]) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
175 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
176 | if self.__projectBrowserMenu and self.__projectBrowserAct: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
177 | self.__projectBrowserMenu.removeAction(self.__projectBrowserAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
178 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
179 | for editor in self.__editors: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
180 | editor.showMenu.disconnect(self.__editorShowMenu) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
181 | menu = editor.getMenu("Checks") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
182 | if menu is not None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
183 | menu.removeAction(self.__editorAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
184 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
185 | self.__initialize() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
186 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
187 | def __loadTranslator(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
188 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
189 | Private method to load the translation file. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
190 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
191 | if self.__ui is not None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
192 | loc = self.__ui.getLocale() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
193 | if loc and loc != "C": |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
194 | locale_dir = os.path.join( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
195 | os.path.dirname(__file__), "PyrightChecker", "i18n" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
196 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
197 | translation = "pyright_{0}".format(loc) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
198 | translator = QTranslator(None) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
199 | loaded = translator.load(translation, locale_dir) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
200 | if loaded: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
201 | self.__translator = translator |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
202 | ericApp().installTranslator(self.__translator) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
203 | else: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
204 | print( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
205 | "Warning: translation file '{0}' could not be" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
206 | " loaded.".format(translation) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
207 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
208 | print("Using default.") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
209 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
210 | def __projectShowMenu( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
211 | self, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
212 | menuName, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
213 | menu, # noqa: U100 |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
214 | ): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
215 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
216 | Private slot called, when the the project menu or a submenu is |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
217 | about to be shown. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
218 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
219 | @param menuName name of the menu to be shown |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
220 | @type str |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
221 | @param menu reference to the menu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
222 | @type QMenu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
223 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
224 | if menuName == "Check" and self.__projectAct is not None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
225 | self.__projectAct.setEnabled( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
226 | ericApp().getObject("Project").getProjectLanguage() == "Python3" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
227 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
228 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
229 | def __projectBrowserShowMenu(self, menuName, menu): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
230 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
231 | Private slot called, when the the project browser menu or a submenu is |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
232 | about to be shown. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
233 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
234 | @param menuName name of the menu to be shown |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
235 | @type str |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
236 | @param menu reference to the menu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
237 | @type QMenu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
238 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
239 | if ( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
240 | menuName == "Checks" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
241 | and ericApp().getObject("Project").getProjectLanguage() == "Python3" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
242 | ): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
243 | self.__projectBrowserMenu = menu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
244 | if self.__projectBrowserAct is None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
245 | self.__projectBrowserAct = EricAction( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
246 | self.tr("Static Type Check"), |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
247 | self.tr("Static &Typing..."), |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
248 | 0, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
249 | 0, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
250 | self, |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
251 | "", |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
252 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
253 | self.__projectBrowserAct.setWhatsThis( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
254 | self.tr( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
255 | """<b>Static Type Check...</b>""" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
256 | """<p>This checks Python files for static typing issues.</p>""" |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
257 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
258 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
259 | self.__projectBrowserAct.triggered.connect( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
260 | self.__projectBrowserPyrightCheck |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
261 | ) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
262 | if self.__projectBrowserAct not in menu.actions(): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
263 | menu.addAction(self.__projectBrowserAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
264 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
265 | @pyqtSlot() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
266 | def __projectPyrightCheck(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
267 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
268 | Private slot used to check the project for static typing issues. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
269 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
270 | from PyrightChecker.PyrightCheckerDialog import PyrightCheckerDialog |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
271 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
272 | project = ericApp().getObject("Project") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
273 | project.saveAllScripts() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
274 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
275 | if self.__projectPyrightCheckerDialog is None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
276 | self.__projectPyrightCheckerDialog = PyrightCheckerDialog(self) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
277 | self.__projectPyrightCheckerDialog.show() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
278 | self.__projectPyrightCheckerDialog.prepare(project) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
279 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
280 | @pyqtSlot() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
281 | def __projectBrowserPyrightCheck(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
282 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
283 | Private method to handle the static typing check context menu action of |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
284 | the project sources browser. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
285 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
286 | from PyrightChecker.PyrightCheckerDialog import PyrightCheckerDialog |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
287 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
288 | browser = ericApp().getObject("ProjectBrowser").getProjectBrowser("sources") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
289 | if browser.getSelectedItemsCount([ProjectBrowserFileItem]) > 1: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
290 | fn = [] |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
291 | for itm in browser.getSelectedItems([ProjectBrowserFileItem]): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
292 | fn.append(itm.fileName()) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
293 | else: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
294 | itm = browser.model().item(browser.currentIndex()) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
295 | try: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
296 | fn = [itm.fileName()] |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
297 | except AttributeError: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
298 | fn = [itm.dirName()] |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
299 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
300 | self.__projectBrowserPyrightCheckerDialog = PyrightCheckerDialog(self) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
301 | self.__projectBrowserPyrightCheckerDialog.show() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
302 | self.__projectBrowserPyrightCheckerDialog.start(fn, save=True) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
303 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
304 | def __editorOpened(self, editor): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
305 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
306 | Private slot called, when a new editor was opened. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
307 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
308 | @param editor reference to the new editor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
309 | @type QScintilla.Editor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
310 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
311 | menu = editor.getMenu("Checks") |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
312 | if menu is not None: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
313 | menu.addAction(self.__editorAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
314 | editor.showMenu.connect(self.__editorShowMenu) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
315 | self.__editors.append(editor) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
316 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
317 | def __editorClosed(self, editor): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
318 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
319 | Private slot called, when an editor was closed. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
320 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
321 | @param editor reference to the editor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
322 | @type QScintilla.Editor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
323 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
324 | with contextlib.suppress(ValueError): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
325 | self.__editors.remove(editor) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
326 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
327 | def __editorShowMenu(self, menuName, menu, editor): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
328 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
329 | Private slot called, when the the editor context menu or a submenu is |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
330 | about to be shown. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
331 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
332 | @param menuName name of the menu to be shown |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
333 | @type str |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
334 | @param menu reference to the menu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
335 | @type QMenu |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
336 | @param editor reference to the editor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
337 | @type QScintilla.Editor |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
338 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
339 | if menuName == "Checks": |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
340 | if self.__editorAct not in menu.actions(): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
341 | menu.addAction(self.__editorAct) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
342 | self.__editorAct.setEnabled(editor.isPyFile()) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
343 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
344 | def __editorPyrightCheck(self): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
345 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
346 | Private slot to handle the code style check context menu action |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
347 | of the editors. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
348 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
349 | from PyrightChecker.PyrightCheckerDialog import PyrightCheckerDialog |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
350 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
351 | editor = ericApp().getObject("ViewManager").activeWindow() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
352 | if ( |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
353 | editor is not None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
354 | and editor.checkDirty() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
355 | and editor.getFileName() is not None |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
356 | ): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
357 | self.__editorPyrightCheckerDialog = PyrightCheckerDialog(self) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
358 | self.__editorPyrightCheckerDialog.show() |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
359 | self.__editorPyrightCheckerDialog.start([editor.getFileName()], save=True) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
360 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
361 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
362 | def installDependencies(pipInstall): |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
363 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
364 | Function to install dependencies of this plug-in. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
365 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
366 | @param pipInstall function to be called with a list of package names. |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
367 | @type function |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
368 | """ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
369 | try: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
370 | import pyright # __IGNORE_WARNING__ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
371 | except ImportError: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
372 | pipInstall(["pyright"]) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
373 | try: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
374 | import tomlkit # __IGNORE_WARNING__ |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
375 | except ImportError: |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
376 | pipInstall(["tomlkit"]) |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
377 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
378 | |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
379 | # |
191e9ec72893
Implemented the first iteration of the pyright typing checker interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
380 | # eflag: noqa = M801 |