@zzzen/pyright-internal 1.2.0-dev.20250112 → 1.2.0-dev.20250126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -0
- package/dist/analyzer/backgroundAnalysisProgram.js +3 -0
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +7 -1
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -1
- package/dist/analyzer/checker.js +34 -42
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructors.js +1 -1
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/enums.js +140 -126
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +3 -2
- package/dist/analyzer/importResolver.js +80 -79
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.d.ts +2 -0
- package/dist/analyzer/pythonPathUtils.js +20 -11
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.js +2 -5
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +1 -1
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +72 -44
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +3 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +24 -17
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/backgroundAnalysis.js +2 -0
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +1 -0
- package/dist/backgroundThreadBase.js +5 -8
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/fullAccessHost.d.ts +1 -1
- package/dist/common/fullAccessHost.js +1 -1
- package/dist/common/languageServerInterface.d.ts +1 -1
- package/dist/common/realFileSystem.d.ts +1 -1
- package/dist/common/realFileSystem.js +10 -2
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.d.ts +1 -0
- package/dist/common/serviceProvider.js +8 -0
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/languageServerBase.d.ts +3 -3
- package/dist/languageServerBase.js +7 -4
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +4 -1
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/hoverProvider.js +5 -3
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +1 -1
- package/dist/languageService/tooltipUtils.js +14 -1
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +9 -7
- package/dist/localization/localize.js +6 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +8 -7
- package/dist/localization/package.nls.de.json +8 -7
- package/dist/localization/package.nls.en-us.json +21 -5
- package/dist/localization/package.nls.es.json +8 -7
- package/dist/localization/package.nls.fr.json +8 -7
- package/dist/localization/package.nls.it.json +8 -7
- package/dist/localization/package.nls.ja.json +8 -7
- package/dist/localization/package.nls.ko.json +8 -7
- package/dist/localization/package.nls.pl.json +6 -5
- package/dist/localization/package.nls.pt-br.json +8 -7
- package/dist/localization/package.nls.qps-ploc.json +4 -3
- package/dist/localization/package.nls.ru.json +8 -7
- package/dist/localization/package.nls.tr.json +6 -5
- package/dist/localization/package.nls.zh-cn.json +8 -7
- package/dist/localization/package.nls.zh-tw.json +8 -7
- package/dist/pyright.js +11 -4
- package/dist/pyright.js.map +1 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/config.test.js +451 -427
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +3 -1
- package/dist/tests/harness/fourslash/testState.js +23 -23
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/hoverProvider.test.js +51 -0
- package/dist/tests/hoverProvider.test.js.map +1 -1
- package/dist/tests/importResolver.test.js +537 -527
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +1 -0
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/testUtils.js +1 -0
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator3.test.js +5 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typeEvaluator6.test.js +8 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +4 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/uri.test.js +3 -0
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +2 -0
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +2 -1
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
@@ -26,433 +26,457 @@ const uri_1 = require("../common/uri/uri");
|
|
26
26
|
const uriUtils_1 = require("../common/uri/uriUtils");
|
27
27
|
const testAccessHost_1 = require("./harness/testAccessHost");
|
28
28
|
const filesystem_1 = require("./harness/vfs/filesystem");
|
29
|
-
|
29
|
+
describe(`config test'}`, () => {
|
30
30
|
const tempFile = new realFileSystem_1.RealTempFile();
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
31
|
+
afterAll(() => tempFile.dispose());
|
32
|
+
test('FindFilesWithConfigFile', () => {
|
33
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
34
|
+
const service = createAnalyzer();
|
35
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
36
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project1';
|
37
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
38
|
+
service.setOptions(commandLineOptions);
|
39
|
+
// The config file specifies a single file spec (a directory).
|
40
|
+
assert_1.default.strictEqual(configOptions.include.length, 1, `failed creating options from ${cwd}`);
|
41
|
+
assert_1.default.strictEqual(configOptions.projectRoot.key, service.fs.realCasePath(uri_1.Uri.file((0, pathUtils_1.combinePaths)(cwd, commandLineOptions.configFilePath), service.serviceProvider)).key);
|
42
|
+
const fileList = service.test_getFileNamesFromFileSpecs();
|
43
|
+
// The config file specifies a subdirectory, so we should find
|
44
|
+
// only two of the three "*.py" files present in the project
|
45
|
+
// directory.
|
46
|
+
assert_1.default.strictEqual(fileList.length, 2);
|
47
|
+
});
|
48
|
+
test('FindFilesVirtualEnvAutoDetectExclude', () => {
|
49
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
50
|
+
const service = createAnalyzer();
|
51
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
52
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project_with_venv_auto_detect_exclude';
|
53
|
+
service.setOptions(commandLineOptions);
|
54
|
+
// The config file is empty, so no 'exclude' are specified
|
55
|
+
// The myVenv directory is detected as a venv and will be automatically excluded
|
56
|
+
const fileList = service.test_getFileNamesFromFileSpecs();
|
57
|
+
// There are 3 python files in the workspace, outside of myVenv
|
58
|
+
// There is 1 python file in myVenv, which should be excluded
|
59
|
+
const fileNames = fileList.map((p) => p.fileName).sort();
|
60
|
+
assert_1.default.deepStrictEqual(fileNames, ['sample1.py', 'sample2.py', 'sample3.py']);
|
61
|
+
});
|
62
|
+
test('FindFilesVirtualEnvAutoDetectInclude', () => {
|
63
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
64
|
+
const service = createAnalyzer();
|
65
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
66
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project_with_venv_auto_detect_include';
|
67
|
+
service.setOptions(commandLineOptions);
|
68
|
+
// Config file defines 'exclude' folder so virtual env will be included
|
69
|
+
const fileList = service.test_getFileNamesFromFileSpecs();
|
70
|
+
// There are 3 python files in the workspace, outside of myVenv
|
71
|
+
// There is 1 more python file in excluded folder
|
72
|
+
// There is 1 python file in myVenv, which should be included
|
73
|
+
const fileNames = fileList.map((p) => p.fileName).sort();
|
74
|
+
assert_1.default.deepStrictEqual(fileNames, ['library1.py', 'sample1.py', 'sample2.py', 'sample3.py']);
|
75
|
+
});
|
76
|
+
test('FileSpecNotAnArray', () => {
|
77
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
78
|
+
const nullConsole = new console_1.NullConsole();
|
79
|
+
const service = createAnalyzer(nullConsole);
|
80
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
81
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project2';
|
82
|
+
service.setOptions(commandLineOptions);
|
83
|
+
service.test_getConfigOptions(commandLineOptions);
|
84
|
+
// The method should return a default config and log an error.
|
85
|
+
(0, assert_1.default)(nullConsole.infoCount > 0);
|
86
|
+
});
|
87
|
+
test('FileSpecNotAString', () => {
|
88
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
89
|
+
const nullConsole = new console_1.NullConsole();
|
90
|
+
const service = createAnalyzer(nullConsole);
|
91
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
92
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project3';
|
93
|
+
service.setOptions(commandLineOptions);
|
94
|
+
service.test_getConfigOptions(commandLineOptions);
|
95
|
+
// The method should return a default config and log an error.
|
96
|
+
(0, assert_1.default)(nullConsole.infoCount > 0);
|
97
|
+
});
|
98
|
+
test('SomeFileSpecsAreInvalid', () => {
|
99
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
100
|
+
const nullConsole = new console_1.NullConsole();
|
101
|
+
const service = createAnalyzer(nullConsole);
|
102
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
103
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project4';
|
104
|
+
service.setOptions(commandLineOptions);
|
105
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
106
|
+
// The config file specifies four file specs in the include array
|
107
|
+
// and one in the exclude array.
|
108
|
+
assert_1.default.strictEqual(configOptions.include.length, 4, `failed creating options from ${cwd}`);
|
109
|
+
assert_1.default.strictEqual(configOptions.exclude.length, 1);
|
110
|
+
assert_1.default.strictEqual(configOptions.projectRoot.getFilePath(), service.fs
|
111
|
+
.realCasePath(uri_1.Uri.file((0, pathUtils_1.combinePaths)(cwd, commandLineOptions.configFilePath), service.serviceProvider))
|
112
|
+
.getFilePath());
|
113
|
+
const fileList = service.test_getFileNamesFromFileSpecs();
|
114
|
+
// We should receive two final files that match the include/exclude rules.
|
115
|
+
assert_1.default.strictEqual(fileList.length, 2);
|
116
|
+
});
|
117
|
+
test('ConfigBadJson', () => {
|
118
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
119
|
+
const nullConsole = new console_1.NullConsole();
|
120
|
+
const service = createAnalyzer(nullConsole);
|
121
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
122
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project5';
|
123
|
+
service.setOptions(commandLineOptions);
|
124
|
+
service.test_getConfigOptions(commandLineOptions);
|
125
|
+
// The method should return a default config and log an error.
|
126
|
+
(0, assert_1.default)(nullConsole.infoCount > 0);
|
127
|
+
});
|
128
|
+
test('FindExecEnv1', () => {
|
129
|
+
const cwd = uriUtils_1.UriEx.file((0, pathUtils_1.normalizePath)(process.cwd()));
|
130
|
+
const configOptions = new configOptions_1.ConfigOptions(cwd);
|
131
|
+
// Build a config option with three execution environments.
|
132
|
+
const execEnv1 = new configOptions_1.ExecutionEnvironment('python', cwd.resolvePaths('src/foo'), (0, configOptions_1.getStandardDiagnosticRuleSet)(),
|
133
|
+
/* defaultPythonVersion */ undefined,
|
134
|
+
/* defaultPythonPlatform */ undefined,
|
135
|
+
/* defaultExtraPaths */ undefined);
|
136
|
+
configOptions.executionEnvironments.push(execEnv1);
|
137
|
+
const execEnv2 = new configOptions_1.ExecutionEnvironment('python', cwd.resolvePaths('src'), (0, configOptions_1.getStandardDiagnosticRuleSet)(),
|
138
|
+
/* defaultPythonVersion */ undefined,
|
139
|
+
/* defaultPythonPlatform */ undefined,
|
140
|
+
/* defaultExtraPaths */ undefined);
|
141
|
+
configOptions.executionEnvironments.push(execEnv2);
|
142
|
+
const file1 = cwd.resolvePaths('src/foo/bar.py');
|
143
|
+
assert_1.default.strictEqual(configOptions.findExecEnvironment(file1), execEnv1);
|
144
|
+
const file2 = cwd.resolvePaths('src/foo2/bar.py');
|
145
|
+
assert_1.default.strictEqual(configOptions.findExecEnvironment(file2), execEnv2);
|
146
|
+
// If none of the execution environments matched, we should get
|
147
|
+
// a default environment with the root equal to that of the config.
|
148
|
+
const file4 = uriUtils_1.UriEx.file('/nothing/bar.py');
|
149
|
+
const defaultExecEnv = configOptions.findExecEnvironment(file4);
|
150
|
+
(0, assert_1.default)(defaultExecEnv.root);
|
151
|
+
const rootFilePath = uri_1.Uri.is(defaultExecEnv.root) ? defaultExecEnv.root.getFilePath() : defaultExecEnv.root;
|
152
|
+
assert_1.default.strictEqual((0, pathUtils_1.normalizeSlashes)(rootFilePath), (0, pathUtils_1.normalizeSlashes)(configOptions.projectRoot.getFilePath()));
|
153
|
+
});
|
154
|
+
test('PythonPlatform', () => {
|
155
|
+
const nullConsole = new console_1.NullConsole();
|
156
|
+
const service = createAnalyzer(nullConsole);
|
157
|
+
const cwd = uri_1.Uri.file((0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_pyproject_toml_platform')), service.serviceProvider);
|
158
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd.getFilePath(), /* fromLanguageServer */ false);
|
159
|
+
service.setOptions(commandLineOptions);
|
160
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
161
|
+
assert_1.default.ok(configOptions.executionEnvironments[0]);
|
162
|
+
assert_1.default.equal(configOptions.executionEnvironments[0].pythonPlatform, 'platform');
|
163
|
+
});
|
164
|
+
test('AutoSearchPathsOn', () => {
|
165
|
+
const nullConsole = new console_1.NullConsole();
|
166
|
+
const service = createAnalyzer(nullConsole);
|
167
|
+
const cwd = uri_1.Uri.file((0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_src')), service.serviceProvider);
|
168
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd.getFilePath(), /* fromLanguageServer */ false);
|
169
|
+
commandLineOptions.configSettings.autoSearchPaths = true;
|
170
|
+
service.setOptions(commandLineOptions);
|
171
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
172
|
+
const expectedExtraPaths = [service.fs.realCasePath(cwd.combinePaths('src'))];
|
173
|
+
assert_1.default.deepStrictEqual(configOptions.defaultExtraPaths, expectedExtraPaths);
|
174
|
+
});
|
175
|
+
test('AutoSearchPathsOff', () => {
|
176
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_src'));
|
177
|
+
const nullConsole = new console_1.NullConsole();
|
178
|
+
const service = createAnalyzer(nullConsole);
|
179
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
180
|
+
commandLineOptions.configSettings.autoSearchPaths = false;
|
181
|
+
service.setOptions(commandLineOptions);
|
182
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
183
|
+
assert_1.default.deepStrictEqual(configOptions.executionEnvironments, []);
|
184
|
+
});
|
185
|
+
test('AutoSearchPathsOnSrcIsPkg', () => {
|
186
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_src_is_pkg'));
|
187
|
+
const nullConsole = new console_1.NullConsole();
|
188
|
+
const service = createAnalyzer(nullConsole);
|
189
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
190
|
+
commandLineOptions.configSettings.autoSearchPaths = true;
|
191
|
+
service.setOptions(commandLineOptions);
|
192
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
193
|
+
// The src folder is a package (has __init__.py) and so should not be automatically added as extra path
|
194
|
+
assert_1.default.deepStrictEqual(configOptions.executionEnvironments, []);
|
195
|
+
});
|
196
|
+
test('AutoSearchPathsOnWithConfigExecEnv', () => {
|
197
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_src_with_config_extra_paths'));
|
198
|
+
const nullConsole = new console_1.NullConsole();
|
199
|
+
const service = createAnalyzer(nullConsole);
|
200
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
201
|
+
commandLineOptions.configFilePath = (0, pathUtils_1.combinePaths)(cwd, 'pyrightconfig.json');
|
202
|
+
commandLineOptions.configSettings.autoSearchPaths = true;
|
203
|
+
service.setOptions(commandLineOptions);
|
204
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
205
|
+
// The extraPaths in the config file should override the setting.
|
206
|
+
const expectedExtraPaths = [];
|
207
|
+
assert_1.default.deepStrictEqual(configOptions.defaultExtraPaths, expectedExtraPaths);
|
208
|
+
});
|
209
|
+
test('AutoSearchPathsOnAndExtraPaths', () => {
|
210
|
+
const nullConsole = new console_1.NullConsole();
|
211
|
+
const service = createAnalyzer(nullConsole);
|
212
|
+
const cwd = uri_1.Uri.file((0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_src_with_config_no_extra_paths')), service.serviceProvider);
|
213
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd.getFilePath(), /* fromLanguageServer */ false);
|
214
|
+
commandLineOptions.configSettings.autoSearchPaths = true;
|
215
|
+
commandLineOptions.configSettings.extraPaths = ['src/_vendored'];
|
216
|
+
service.setOptions(commandLineOptions);
|
217
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
218
|
+
const expectedExtraPaths = [
|
219
|
+
service.fs.realCasePath(cwd.combinePaths('src')),
|
220
|
+
service.fs.realCasePath(cwd.combinePaths('src', '_vendored')),
|
221
|
+
];
|
222
|
+
assert_1.default.deepStrictEqual(configOptions.defaultExtraPaths, expectedExtraPaths);
|
223
|
+
});
|
224
|
+
test('BasicPyprojectTomlParsing', () => {
|
225
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_pyproject_toml'));
|
226
|
+
const service = createAnalyzer();
|
227
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
228
|
+
service.setOptions(commandLineOptions);
|
229
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
230
|
+
assert_1.default.strictEqual(configOptions.defaultPythonVersion.toString(), pythonVersion_1.pythonVersion3_9.toString());
|
231
|
+
assert_1.default.strictEqual(configOptions.diagnosticRuleSet.reportMissingImports, 'error');
|
232
|
+
assert_1.default.strictEqual(configOptions.diagnosticRuleSet.reportUnusedClass, 'warning');
|
233
|
+
});
|
234
|
+
test('FindFilesInMemoryOnly', () => {
|
235
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
236
|
+
const service = createAnalyzer();
|
237
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(undefined, /* fromLanguageServer */ true);
|
238
|
+
// Force a lookup of the typeshed path. This causes us to try and generate a module path for the untitled file.
|
239
|
+
commandLineOptions.configSettings.typeshedPath = (0, pathUtils_1.combinePaths)(cwd, 'src', 'tests', 'samples');
|
240
|
+
service.setOptions(commandLineOptions);
|
241
|
+
// Open a file that is not backed by the file system.
|
242
|
+
const untitled = uri_1.Uri.parse('untitled:Untitled-1.py', service.serviceProvider);
|
243
|
+
service.setFileOpened(untitled, 1, '# empty');
|
244
|
+
const fileList = service.test_getFileNamesFromFileSpecs();
|
245
|
+
(0, assert_1.default)(fileList.filter((f) => f.equals(untitled)));
|
246
|
+
});
|
247
|
+
test('verify config fileSpecs after cloning', () => {
|
248
|
+
const fs = new filesystem_1.TestFileSystem(/* ignoreCase */ true);
|
249
|
+
const configFile = {
|
250
|
+
ignore: ['**/node_modules/**'],
|
251
|
+
};
|
252
|
+
const rootUri = uri_1.Uri.file(process.cwd(), fs);
|
253
|
+
const config = new configOptions_1.ConfigOptions(rootUri);
|
254
|
+
const sp = (0, serviceProviderExtensions_1.createServiceProvider)(fs, new console_1.NullConsole());
|
255
|
+
config.initializeFromJson(configFile, rootUri, sp, new testAccessHost_1.TestAccessHost());
|
256
|
+
const cloned = (0, backgroundThreadBase_1.deserialize)((0, backgroundThreadBase_1.serialize)(config));
|
257
|
+
assert_1.default.deepEqual(config.ignore, cloned.ignore);
|
258
|
+
});
|
259
|
+
test('verify can serialize config options', () => {
|
260
|
+
const config = new configOptions_1.ConfigOptions(uriUtils_1.UriEx.file(process.cwd()));
|
261
|
+
const serialized = (0, backgroundThreadBase_1.serialize)(config);
|
262
|
+
const deserialized = (0, backgroundThreadBase_1.deserialize)(serialized);
|
263
|
+
assert_1.default.deepEqual(config, deserialized);
|
264
|
+
assert_1.default.ok(deserialized.findExecEnvironment(uriUtils_1.UriEx.file('foo/bar.py')));
|
265
|
+
});
|
266
|
+
test('extra paths on undefined execution root/default workspace', () => {
|
267
|
+
const nullConsole = new console_1.NullConsole();
|
268
|
+
const service = createAnalyzer(nullConsole);
|
269
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(undefined, /* fromLanguageServer */ false);
|
270
|
+
commandLineOptions.configSettings.extraPaths = ['/extraPaths'];
|
271
|
+
service.setOptions(commandLineOptions);
|
272
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
273
|
+
const expectedExtraPaths = [uri_1.Uri.file('/extraPaths', service.serviceProvider)];
|
274
|
+
assert_1.default.deepStrictEqual(configOptions.defaultExtraPaths?.map((u) => u.getFilePath()), expectedExtraPaths.map((u) => u.getFilePath()));
|
275
|
+
});
|
276
|
+
test('Extended config files', () => {
|
277
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_extended_config'));
|
278
|
+
const service = createAnalyzer();
|
279
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
280
|
+
service.setOptions(commandLineOptions);
|
281
|
+
const fileList = service.test_getFileNamesFromFileSpecs();
|
282
|
+
const fileNames = fileList.map((p) => p.fileName).sort();
|
283
|
+
assert_1.default.deepStrictEqual(fileNames, ['sample.pyi', 'test.py']);
|
284
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
285
|
+
assert_1.default.equal(configOptions.diagnosticRuleSet.strictListInference, true);
|
286
|
+
});
|
287
|
+
test('Typechecking mode is standard when just config file is present', () => {
|
288
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_pyproject_toml'));
|
289
|
+
const service = createAnalyzer();
|
290
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
291
|
+
commandLineOptions.configSettings.typeCheckingMode = 'off';
|
292
|
+
service.setOptions(commandLineOptions);
|
293
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
294
|
+
assert_1.default.equal(configOptions.diagnosticRuleSet.reportPossiblyUnboundVariable, 'error');
|
295
|
+
});
|
296
|
+
test('Typechecking mode depends upon if vscode extension or not', () => {
|
297
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/package1'));
|
298
|
+
let service = createAnalyzer();
|
299
|
+
let commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
300
|
+
service.setOptions(commandLineOptions);
|
301
|
+
let configOptions = service.test_getConfigOptions(commandLineOptions);
|
302
|
+
assert_1.default.equal(configOptions.diagnosticRuleSet.reportPossiblyUnboundVariable, 'none');
|
303
|
+
service = createAnalyzer();
|
304
|
+
commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
305
|
+
service.setOptions(commandLineOptions);
|
306
|
+
configOptions = service.test_getConfigOptions(commandLineOptions);
|
307
|
+
assert_1.default.equal(configOptions.diagnosticRuleSet.reportPossiblyUnboundVariable, 'error');
|
308
|
+
commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
309
|
+
commandLineOptions.configSettings.typeCheckingMode = 'strict';
|
310
|
+
service = createAnalyzer();
|
311
|
+
service.setOptions(commandLineOptions);
|
312
|
+
configOptions = service.test_getConfigOptions(commandLineOptions);
|
313
|
+
assert_1.default.equal(configOptions.diagnosticRuleSet.reportPossiblyUnboundVariable, 'error');
|
314
|
+
});
|
315
|
+
test('Include file paths are only set in the config file when using extension', () => {
|
316
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project1'));
|
317
|
+
const service = createAnalyzer();
|
318
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
319
|
+
commandLineOptions.configSettings.includeFileSpecs = ['test'];
|
320
|
+
service.setOptions(commandLineOptions);
|
321
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
322
|
+
assert_1.default.equal(configOptions.include.length, 1);
|
323
|
+
assert_1.default.ok(configOptions.include[0].regExp.source.includes('/subfolder1)'));
|
324
|
+
});
|
325
|
+
test('Include file paths can be added to on the command line with a config', () => {
|
326
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project1'));
|
327
|
+
const service = createAnalyzer();
|
328
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
329
|
+
commandLineOptions.configSettings.includeFileSpecs = ['test'];
|
330
|
+
service.setOptions(commandLineOptions);
|
331
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
332
|
+
assert_1.default.equal(configOptions.include.length, 2);
|
333
|
+
assert_1.default.ok(configOptions.include[1].regExp.source.includes('/test)'));
|
334
|
+
});
|
335
|
+
test('Include file paths can be added to by an extension without a config', () => {
|
336
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/package1'));
|
337
|
+
const service = createAnalyzer();
|
338
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
339
|
+
commandLineOptions.configSettings.includeFileSpecs = ['test'];
|
340
|
+
service.setOptions(commandLineOptions);
|
341
|
+
const configOptions = service.test_getConfigOptions(commandLineOptions);
|
342
|
+
assert_1.default.equal(configOptions.include.length, 1);
|
343
|
+
assert_1.default.ok(configOptions.include[0].regExp.source.includes('/test)'));
|
344
|
+
});
|
345
|
+
test('Command line options can override config but only when not using extension', () => {
|
346
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_all_config'));
|
347
|
+
const service = createAnalyzer();
|
348
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
349
|
+
service.setOptions(commandLineOptions);
|
350
|
+
// First get the default.
|
351
|
+
const defaultOptions = service.test_getConfigOptions(commandLineOptions);
|
352
|
+
// Now set all of the different options and make sure the command line options override.
|
353
|
+
commandLineOptions.configSettings.typeCheckingMode = 'strict';
|
354
|
+
commandLineOptions.configSettings.venvPath = 'test2';
|
355
|
+
commandLineOptions.configSettings.typeshedPath = 'test2';
|
356
|
+
commandLineOptions.configSettings.stubPath = 'test2';
|
357
|
+
commandLineOptions.configSettings.useLibraryCodeForTypes = true;
|
358
|
+
commandLineOptions.configSettings.includeFileSpecs = ['test2'];
|
359
|
+
commandLineOptions.configSettings.excludeFileSpecs = ['test2'];
|
360
|
+
commandLineOptions.configSettings.diagnosticSeverityOverrides = {
|
361
|
+
reportMissingImports: "error" /* DiagnosticSeverityOverrides.Error */,
|
362
|
+
};
|
363
|
+
commandLineOptions.configSettings.ignoreFileSpecs = ['test2'];
|
364
|
+
service.setOptions(commandLineOptions);
|
365
|
+
const overriddenOptions = service.test_getConfigOptions(commandLineOptions);
|
366
|
+
assert_1.default.notDeepStrictEqual(defaultOptions.include, overriddenOptions.include);
|
367
|
+
assert_1.default.notDeepStrictEqual(defaultOptions.exclude, overriddenOptions.exclude);
|
368
|
+
assert_1.default.notDeepStrictEqual(defaultOptions.ignore, overriddenOptions.ignore);
|
369
|
+
assert_1.default.notDeepStrictEqual(defaultOptions.diagnosticRuleSet, overriddenOptions.diagnosticRuleSet);
|
370
|
+
assert_1.default.notDeepStrictEqual(defaultOptions.venvPath, overriddenOptions.venvPath);
|
371
|
+
// Typeshed and stub path are an exception, it should just be reported as a dupe.
|
372
|
+
assert_1.default.deepStrictEqual(defaultOptions.typeshedPath, overriddenOptions.typeshedPath);
|
373
|
+
assert_1.default.deepStrictEqual(defaultOptions.stubPath, overriddenOptions.stubPath);
|
374
|
+
// Do the same with an extension based config, but make sure we get the default back.
|
375
|
+
const commandLineOptions2 = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
376
|
+
service.setOptions(commandLineOptions2);
|
377
|
+
const overriddenOptions2 = service.test_getConfigOptions(commandLineOptions2);
|
378
|
+
assert_1.default.deepStrictEqual(defaultOptions, overriddenOptions2);
|
379
|
+
});
|
380
|
+
test('Config venvPath take precedences over language server settings', () => {
|
381
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_all_config'));
|
382
|
+
const service = createAnalyzer();
|
383
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
384
|
+
commandLineOptions.languageServerSettings.venvPath = 'test_from_language_server';
|
385
|
+
service.setOptions(commandLineOptions);
|
386
|
+
// Verify language server options don't override
|
387
|
+
const options = service.test_getConfigOptions(commandLineOptions);
|
388
|
+
assert_1.default.equal(options.venvPath?.pathIncludes('from_language_server'), false);
|
389
|
+
});
|
390
|
+
test('Command line venvPath take precedences over everything else', () => {
|
391
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_all_config'));
|
392
|
+
const service = createAnalyzer();
|
393
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
394
|
+
commandLineOptions.configSettings.venvPath = 'test_from_command_line';
|
395
|
+
commandLineOptions.languageServerSettings.venvPath = 'test_from_language_server';
|
396
|
+
service.setOptions(commandLineOptions);
|
397
|
+
// Verify command line overrides everything
|
398
|
+
const options = service.test_getConfigOptions(commandLineOptions);
|
399
|
+
assert_1.default.ok(options.venvPath?.pathIncludes('test_from_command_line'));
|
400
|
+
});
|
401
|
+
test('Config empty venvPath does not take precedences over language server settings', () => {
|
402
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_src_with_config_extra_paths'));
|
403
|
+
const service = createAnalyzer();
|
404
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ true);
|
405
|
+
commandLineOptions.languageServerSettings.venvPath = 'test_from_language_server';
|
406
|
+
service.setOptions(commandLineOptions);
|
407
|
+
// Verify language server options don't override
|
408
|
+
const options = service.test_getConfigOptions(commandLineOptions);
|
409
|
+
assert_1.default.ok(options.venvPath?.pathIncludes('from_language_server'));
|
410
|
+
});
|
411
|
+
test('Language server specific settings are set whether or not there is a pyproject.toml', () => {
|
412
|
+
const cwd = (0, pathUtils_1.normalizePath)((0, pathUtils_1.combinePaths)(process.cwd(), 'src/tests/samples/project_with_all_config'));
|
413
|
+
const service = createAnalyzer();
|
414
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
415
|
+
commandLineOptions.languageServerSettings.autoImportCompletions = true;
|
416
|
+
commandLineOptions.languageServerSettings.indexing = true;
|
417
|
+
commandLineOptions.languageServerSettings.taskListTokens = [{ priority: diagnostic_1.TaskListPriority.High, text: 'test' }];
|
418
|
+
commandLineOptions.languageServerSettings.logTypeEvaluationTime = true;
|
419
|
+
commandLineOptions.languageServerSettings.typeEvaluationTimeThreshold = 1;
|
420
|
+
commandLineOptions.languageServerSettings.enableAmbientAnalysis = false;
|
421
|
+
commandLineOptions.languageServerSettings.disableTaggedHints = true;
|
422
|
+
commandLineOptions.languageServerSettings.watchForSourceChanges = true;
|
423
|
+
commandLineOptions.languageServerSettings.watchForLibraryChanges = true;
|
424
|
+
commandLineOptions.languageServerSettings.watchForConfigChanges = true;
|
425
|
+
commandLineOptions.languageServerSettings.typeStubTargetImportName = 'test';
|
426
|
+
commandLineOptions.languageServerSettings.checkOnlyOpenFiles = true;
|
427
|
+
commandLineOptions.languageServerSettings.disableTaggedHints = true;
|
428
|
+
commandLineOptions.languageServerSettings.pythonPath = 'test_python_path';
|
429
|
+
service.setOptions(commandLineOptions);
|
430
|
+
let options = service.test_getConfigOptions(commandLineOptions);
|
431
|
+
assert_1.default.strictEqual(options.autoImportCompletions, true);
|
432
|
+
assert_1.default.strictEqual(options.indexing, true);
|
433
|
+
assert_1.default.strictEqual(options.taskListTokens?.length, 1);
|
434
|
+
assert_1.default.strictEqual(options.logTypeEvaluationTime, true);
|
435
|
+
assert_1.default.strictEqual(options.typeEvaluationTimeThreshold, 1);
|
436
|
+
assert_1.default.strictEqual(options.disableTaggedHints, true);
|
437
|
+
assert_1.default.ok(options.pythonPath?.pathIncludes('test_python_path'));
|
438
|
+
// Test with language server set to true to make sure they are still set.
|
439
|
+
commandLineOptions.fromLanguageServer = true;
|
440
|
+
commandLineOptions.languageServerSettings.venvPath = 'test_venv_path';
|
441
|
+
service.setOptions(commandLineOptions);
|
442
|
+
options = service.test_getConfigOptions(commandLineOptions);
|
443
|
+
assert_1.default.strictEqual(options.autoImportCompletions, true);
|
444
|
+
assert_1.default.strictEqual(options.indexing, true);
|
445
|
+
assert_1.default.strictEqual(options.taskListTokens?.length, 1);
|
446
|
+
assert_1.default.strictEqual(options.logTypeEvaluationTime, true);
|
447
|
+
assert_1.default.strictEqual(options.typeEvaluationTimeThreshold, 1);
|
448
|
+
assert_1.default.strictEqual(options.disableTaggedHints, true);
|
449
|
+
assert_1.default.ok(options.pythonPath?.pathIncludes('test_python_path'));
|
450
|
+
// Verify language server options don't override the config setting. Only command line should
|
451
|
+
assert_1.default.equal(options.venvPath?.pathIncludes('test_venv_path'), false);
|
452
|
+
});
|
453
|
+
test('DefaultPythonVersion no config', () => {
|
454
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
455
|
+
const nullConsole = new console_1.NullConsole();
|
456
|
+
const service = createAnalyzer(nullConsole);
|
457
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
458
|
+
commandLineOptions.configFilePath = 'src/tests/samples/package1';
|
459
|
+
service.setOptions(commandLineOptions);
|
460
|
+
const config = service.test_getConfigOptions(commandLineOptions);
|
461
|
+
assert_1.default.deepStrictEqual(config.defaultPythonVersion, pythonVersion_1.pythonVersion3_13);
|
462
|
+
});
|
463
|
+
test('DefaultPythonVersion with config', () => {
|
464
|
+
const cwd = (0, pathUtils_1.normalizePath)(process.cwd());
|
465
|
+
const nullConsole = new console_1.NullConsole();
|
466
|
+
const service = createAnalyzer(nullConsole);
|
467
|
+
const commandLineOptions = new commandLineOptions_1.CommandLineOptions(cwd, /* fromLanguageServer */ false);
|
468
|
+
commandLineOptions.configFilePath = 'src/tests/samples/project1';
|
469
|
+
service.setOptions(commandLineOptions);
|
470
|
+
const config = service.test_getConfigOptions(commandLineOptions);
|
471
|
+
assert_1.default.deepStrictEqual(config.defaultPythonVersion, pythonVersion_1.pythonVersion3_13);
|
472
|
+
});
|
473
|
+
function createAnalyzer(console) {
|
474
|
+
const cons = console ?? new console_1.NullConsole();
|
475
|
+
const fs = (0, realFileSystem_1.createFromRealFileSystem)(tempFile, cons);
|
476
|
+
const serviceProvider = (0, serviceProviderExtensions_1.createServiceProvider)(fs, cons, tempFile);
|
477
|
+
const host = new testAccessHost_1.TestAccessHost();
|
478
|
+
host.getPythonVersion = () => pythonVersion_1.pythonVersion3_13;
|
479
|
+
return new service_1.AnalyzerService('<default>', serviceProvider, { console: cons, hostFactory: () => host });
|
480
|
+
}
|
457
481
|
});
|
458
482
|
//# sourceMappingURL=config.test.js.map
|