From 921de3097ee4cade7e0f394d3a73b0e24217695c Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 25 Apr 2020 14:26:46 -0700 Subject: [PATCH] Added support for "python.analysis.autoSearchPaths" setting. If enabled (as it is by default), it automatically adds "src" to the import search paths. It is common for workspaces to contain a directory by this name. --- client/package.json | 6 ++++++ docs/settings.md | 2 ++ server/src/server.ts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index eeb1af0c9..89cb84534 100644 --- a/client/package.json +++ b/client/package.json @@ -75,6 +75,12 @@ "description": "Paths to look for typeshed modules.", "scope": "resource" }, + "python.analysis.autoSearchPaths": { + "type": "boolean", + "default": true, + "description": "Automatically add common search paths like 'src'?", + "scope": "resource" + }, "python.pythonPath": { "type": "string", "default": "python", diff --git a/docs/settings.md b/docs/settings.md index c6e286112..f2d5e2dbf 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -14,6 +14,8 @@ The Pyright VS Code extension honors the following settings. **python.analysis.typeshedPaths** [array of paths]: Paths to look for typeshed modules. Pyright currently honors only the first path in the array. +**python.analysis.autoSearchPaths** [boolean]: Determines whether pyright automatically adds common search paths like "src" if there are no execution environments defined in the config file. + **python.pythonPath** [path]: Path to Python interpreter. **python.venvPath** [path]: Path to folder with subdirectories that contain virtual environments. diff --git a/server/src/server.ts b/server/src/server.ts index 1b954c0ca..ed597e226 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -45,7 +45,7 @@ class PyrightServer extends LanguageServerBase { } serverSettings.autoSearchPaths = !!pythonAnalysisSection.autoSearchPaths; } else { - serverSettings.autoSearchPaths = false; + serverSettings.autoSearchPaths = true; } const pyrightSection = await this.getConfiguration(workspace, 'pyright');