From 909f3e6408f901b5d7b7462f28bb08a376b3aef9 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 1 Mar 2020 16:37:05 -0800 Subject: [PATCH] Added "verboseOutput" config setting, allowing verbose logs to be enabled when used with VS Code extension. --- client/schemas/pyrightconfig.schema.json | 6 ++++++ docs/configuration.md | 2 ++ server/src/common/configOptions.ts | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/schemas/pyrightconfig.schema.json b/client/schemas/pyrightconfig.schema.json index 2a4e9e903..625fc2bbc 100644 --- a/client/schemas/pyrightconfig.schema.json +++ b/client/schemas/pyrightconfig.schema.json @@ -346,6 +346,12 @@ ], "pattern": "^(.*)$" }, + "verboseOutput": { + "$id": "#/properties/verboseOutput", + "type": "boolean", + "title": "Output verbose logging", + "default": "false" + }, "executionEnvironments": { "$id": "#/properties/executionEnvironments", "type": "array", diff --git a/docs/configuration.md b/docs/configuration.md index 300264046..82370dabc 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -22,6 +22,8 @@ Relative paths specified within the config file are relative to the config file **venv** [string, optional]: Used in conjunction with the venvPath, specifies the virtual environment to use. Individual execution environments may override this setting. +**verboseOutput** [boolean]: Specifies whether output logs should be verbose. This is useful when diagnosing certain problems like import resolution issues. + **pythonVersion** [string, optional]: Specifies the version of Python that will be used to execute the source code. The version should be specified as a string in the format "M.m" where M is the major version and m is the minor (e.g. `"3.0"` or `"3.6"`). If a version is provided, pyright will generate errors if the source code makes use of language features that are not supported in that version. It will also tailor its use of type stub files, which conditionalizes type definitions based on the version. **pythonPlatform** [string, optional]: Specifies the target platform that will be used to execute the source code. Should be one of `"Windows"`, `"Darwin"` or `"Linux"`. If specified, pyright will tailor its use of type stub files, which conditionalize type definitions based on the platform. diff --git a/server/src/common/configOptions.ts b/server/src/common/configOptions.ts index 17637046d..844d67608 100644 --- a/server/src/common/configOptions.ts +++ b/server/src/common/configOptions.ts @@ -801,7 +801,7 @@ export class ConfigOptions { } } - // Read the "typeshedPath". + // Read the "typeshedPath" setting. this.typeshedPath = undefined; if (configObj.typeshedPath !== undefined) { if (typeof configObj.typeshedPath !== 'string') { @@ -813,7 +813,7 @@ export class ConfigOptions { } } - // Read the "typingsPath". + // Read the "typingsPath" setting. this.typingsPath = undefined; if (configObj.typingsPath !== undefined) { if (typeof configObj.typingsPath !== 'string') { @@ -823,6 +823,17 @@ export class ConfigOptions { } } + // Read the "verboseOutput" setting. + // Don't initialize to a default value because we want the command-line "verbose" + // switch to apply if this setting isn't specified in the config file. + if (configObj.verboseOutput !== undefined) { + if (typeof configObj.verboseOutput !== 'boolean') { + console.log(`Config "verboseOutput" field must be true or false.`); + } else { + this.verboseOutput = configObj.verboseOutput; + } + } + // Read the "executionEnvironments" array. This should be done at the end // after we've established default values. this.executionEnvironments = [];