diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..a57bae098756 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "typeshed"] + path = typeshed + url = https://github.com/python/typeshed.git + branch = master \ No newline at end of file diff --git a/package.json b/package.json index 854b86447122..4bd7fa61c640 100644 --- a/package.json +++ b/package.json @@ -1173,6 +1173,15 @@ "description": "Controls appearance of methods with double underscores in the completion list.", "scope": "resource" }, + "python.autoComplete.typeshedPaths": { + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "description": "Specifies paths to local typeshed repository clone(s) for the Python language server.", + "scope": "resource" + }, "python.disableInstallationCheck": { "type": "boolean", "default": false, diff --git a/src/client/activation/analysis.ts b/src/client/activation/analysis.ts index 536530d74050..01d2e911e902 100644 --- a/src/client/activation/analysis.ts +++ b/src/client/activation/analysis.ts @@ -190,7 +190,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { const interpreterDataService = new InterpreterDataService(this.context, this.services); interpreterData = await interpreterDataService.getInterpreterData(); } catch (ex) { - this.appShell.showErrorMessage('Unable to determine path to the Python interpreter. IntelliSense will be limited.'); + this.appShell.showWarningMessage('Unable to determine path to the Python interpreter. IntelliSense will be limited.'); } this.interpreterHash = interpreterData ? interpreterData.hash : ''; @@ -204,13 +204,16 @@ export class AnalysisExtensionActivator implements IExtensionActivator { properties['PrefixPath'] = interpreterData.prefix; } - let searchPaths = interpreterData ? interpreterData.searchPaths : ''; + let searchPathsString = interpreterData ? interpreterData.searchPaths : ''; + let typeshedPaths: string[] = []; + const settings = this.configuration.getSettings(); if (settings.autoComplete) { const extraPaths = settings.autoComplete.extraPaths; if (extraPaths && extraPaths.length > 0) { - searchPaths = `${searchPaths};${extraPaths.join(';')}`; + searchPathsString = `${searchPathsString};${extraPaths.join(';')}`; } + typeshedPaths = settings.autoComplete.typeshedPaths; } // tslint:disable-next-line:no-string-literal @@ -219,9 +222,13 @@ export class AnalysisExtensionActivator implements IExtensionActivator { // Make sure paths do not contain multiple slashes so file URIs // in VS Code (Node.js) and in the language server (.NET) match. // Note: for the language server paths separator is always ; - searchPaths = searchPaths.split(path.delimiter).map(p => path.normalize(p)).join(';'); + const searchPaths = searchPathsString.split(path.delimiter).map(p => path.normalize(p)); // tslint:disable-next-line:no-string-literal - properties['SearchPaths'] = `${searchPaths};${pythonPath}`; + properties['SearchPaths'] = `${searchPaths.join(';')};${pythonPath}`; + + if (!typeshedPaths || typeshedPaths.length === 0) { + typeshedPaths = [path.join(this.context.extensionPath, 'typeshed')]; + } const selector = [{ language: PYTHON, scheme: 'file' }]; const excludeFiles = this.getExcludedFiles(); @@ -245,6 +252,8 @@ export class AnalysisExtensionActivator implements IExtensionActivator { trimDocumentationText: false, maxDocumentationTextLength: 0 }, + searchPaths, + typeStubSearchPaths: typeshedPaths, asyncStartup: true, excludeFiles: excludeFiles, testEnvironment: isTestExecution() diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index d15bfefee183..4c55c4a2b3a3 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -233,7 +233,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { extraPaths: [], addBrackets: false, preloadModules: [], - showAdvancedMembers: false + showAdvancedMembers: false, + typeshedPaths: [] }; // tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 733f0ffbee84..c671ae4e3bd5 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -221,6 +221,7 @@ export interface IAutoCompleteSettings { readonly extraPaths: string[]; readonly preloadModules: string[]; readonly showAdvancedMembers: boolean; + readonly typeshedPaths: string[]; } export interface IWorkspaceSymbolSettings { readonly enabled: boolean; @@ -237,6 +238,7 @@ export interface ITerminalSettings { } export interface IPythonAnalysisEngineSettings { readonly showAdvancedMembers: boolean; + readonly typeshedPaths: string[]; } export const IConfigurationService = Symbol('IConfigurationService'); diff --git a/typeshed b/typeshed new file mode 160000 index 000000000000..95eff73ab209 --- /dev/null +++ b/typeshed @@ -0,0 +1 @@ +Subproject commit 95eff73ab2092f2c3158198d404a921447172418