Skip to content

Commit 7a90e86

Browse files
author
Mikhail Arkhipov
authored
Add typeshed submodule and pass it down to LS (microsoft#2043)
* LS symbol providers * Typeshed paths * Typeshed submodule * Add submodule
1 parent 8885912 commit 7a90e86

6 files changed

Lines changed: 32 additions & 6 deletions

File tree

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "typeshed"]
2+
path = typeshed
3+
url = https://github.com/python/typeshed.git
4+
branch = master

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,15 @@
11731173
"description": "Controls appearance of methods with double underscores in the completion list.",
11741174
"scope": "resource"
11751175
},
1176+
"python.autoComplete.typeshedPaths": {
1177+
"type": "array",
1178+
"items": {
1179+
"type": "string"
1180+
},
1181+
"default": [],
1182+
"description": "Specifies paths to local typeshed repository clone(s) for the Python language server.",
1183+
"scope": "resource"
1184+
},
11761185
"python.disableInstallationCheck": {
11771186
"type": "boolean",
11781187
"default": false,

src/client/activation/analysis.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
190190
const interpreterDataService = new InterpreterDataService(this.context, this.services);
191191
interpreterData = await interpreterDataService.getInterpreterData();
192192
} catch (ex) {
193-
this.appShell.showErrorMessage('Unable to determine path to the Python interpreter. IntelliSense will be limited.');
193+
this.appShell.showWarningMessage('Unable to determine path to the Python interpreter. IntelliSense will be limited.');
194194
}
195195

196196
this.interpreterHash = interpreterData ? interpreterData.hash : '';
@@ -204,13 +204,16 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
204204
properties['PrefixPath'] = interpreterData.prefix;
205205
}
206206

207-
let searchPaths = interpreterData ? interpreterData.searchPaths : '';
207+
let searchPathsString = interpreterData ? interpreterData.searchPaths : '';
208+
let typeshedPaths: string[] = [];
209+
208210
const settings = this.configuration.getSettings();
209211
if (settings.autoComplete) {
210212
const extraPaths = settings.autoComplete.extraPaths;
211213
if (extraPaths && extraPaths.length > 0) {
212-
searchPaths = `${searchPaths};${extraPaths.join(';')}`;
214+
searchPathsString = `${searchPathsString};${extraPaths.join(';')}`;
213215
}
216+
typeshedPaths = settings.autoComplete.typeshedPaths;
214217
}
215218

216219
// tslint:disable-next-line:no-string-literal
@@ -219,9 +222,13 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
219222
// Make sure paths do not contain multiple slashes so file URIs
220223
// in VS Code (Node.js) and in the language server (.NET) match.
221224
// Note: for the language server paths separator is always ;
222-
searchPaths = searchPaths.split(path.delimiter).map(p => path.normalize(p)).join(';');
225+
const searchPaths = searchPathsString.split(path.delimiter).map(p => path.normalize(p));
223226
// tslint:disable-next-line:no-string-literal
224-
properties['SearchPaths'] = `${searchPaths};${pythonPath}`;
227+
properties['SearchPaths'] = `${searchPaths.join(';')};${pythonPath}`;
228+
229+
if (!typeshedPaths || typeshedPaths.length === 0) {
230+
typeshedPaths = [path.join(this.context.extensionPath, 'typeshed')];
231+
}
225232

226233
const selector = [{ language: PYTHON, scheme: 'file' }];
227234
const excludeFiles = this.getExcludedFiles();
@@ -245,6 +252,8 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
245252
trimDocumentationText: false,
246253
maxDocumentationTextLength: 0
247254
},
255+
searchPaths,
256+
typeStubSearchPaths: typeshedPaths,
248257
asyncStartup: true,
249258
excludeFiles: excludeFiles,
250259
testEnvironment: isTestExecution()

src/client/common/configSettings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
233233
extraPaths: [],
234234
addBrackets: false,
235235
preloadModules: [],
236-
showAdvancedMembers: false
236+
showAdvancedMembers: false,
237+
typeshedPaths: []
237238
};
238239

239240
// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion

src/client/common/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export interface IAutoCompleteSettings {
221221
readonly extraPaths: string[];
222222
readonly preloadModules: string[];
223223
readonly showAdvancedMembers: boolean;
224+
readonly typeshedPaths: string[];
224225
}
225226
export interface IWorkspaceSymbolSettings {
226227
readonly enabled: boolean;
@@ -237,6 +238,7 @@ export interface ITerminalSettings {
237238
}
238239
export interface IPythonAnalysisEngineSettings {
239240
readonly showAdvancedMembers: boolean;
241+
readonly typeshedPaths: string[];
240242
}
241243

242244
export const IConfigurationService = Symbol('IConfigurationService');

typeshed

Submodule typeshed added at 95eff73

0 commit comments

Comments
 (0)