Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "typeshed"]
path = typeshed
url = https://github.com/python/typeshed.git
branch = master
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 14 additions & 5 deletions src/client/activation/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '';
Expand All @@ -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(';')}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when searchPathsString=''? Is it ok for it to contain a leading ';' when it does equal the empty string?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the LS yes. It always uses ; as separator and drops odd entries.

}
typeshedPaths = settings.autoComplete.typeshedPaths;
}

// tslint:disable-next-line:no-string-literal
Expand All @@ -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();
Expand All @@ -245,6 +252,8 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
trimDocumentationText: false,
maxDocumentationTextLength: 0
},
searchPaths,
typeStubSearchPaths: typeshedPaths,
asyncStartup: true,
excludeFiles: excludeFiles,
testEnvironment: isTestExecution()
Expand Down
3 changes: 2 additions & 1 deletion src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -237,6 +238,7 @@ export interface ITerminalSettings {
}
export interface IPythonAnalysisEngineSettings {
readonly showAdvancedMembers: boolean;
readonly typeshedPaths: string[];
}

export const IConfigurationService = Symbol('IConfigurationService');
Expand Down
1 change: 1 addition & 0 deletions typeshed
Submodule typeshed added at 95eff7