From 006f5d60d1fdf0e1d2e0acc94f0f3c2cb4d8a5fd Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 14 Sep 2020 14:44:18 -0700 Subject: [PATCH] Changed python.analysis.logLevel to use "Information" rather than "Info" for consistency with Python extension. --- docs/settings.md | 2 +- packages/pyright-internal/src/analyzer/binder.ts | 4 ++++ packages/pyright-internal/src/analyzer/commentUtils.ts | 4 ++++ packages/pyright-internal/src/common/diagnostic.ts | 3 +++ packages/pyright-internal/src/languageServerBase.ts | 8 ++++---- packages/vscode-pyright/package.json | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index 3f52ae51d..34a3741e0 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -20,7 +20,7 @@ The Pyright VS Code extension honors the following settings. **python.analysis.extraPaths** [array of paths]: Paths to add to the default execution environment extra paths if there are no execution environments defined in the config file. -**python.analysis.logLevel** ["Error", "Warning", "Info", or "Trace"]: Level of logging for Output panel. The default value for this option is "Info". +**python.analysis.logLevel** ["Error", "Warning", "Information", or "Trace"]: Level of logging for Output panel. The default value for this option is "Information". **python.analysis.stubPath** [path]: Path to directory containing custom type stub files. diff --git a/packages/pyright-internal/src/analyzer/binder.ts b/packages/pyright-internal/src/analyzer/binder.ts index 5d30de1ef..f8e327401 100644 --- a/packages/pyright-internal/src/analyzer/binder.ts +++ b/packages/pyright-internal/src/analyzer/binder.ts @@ -2672,14 +2672,18 @@ export class Binder extends ParseTreeWalker { case 'error': diagnostic = this._addError(message, textRange); break; + case 'warning': diagnostic = this._addWarning(message, textRange); break; + case 'information': diagnostic = this._addInformation(message, textRange); break; + case 'none': break; + default: return assertNever(diagLevel, `${diagLevel} is not expected`); } diff --git a/packages/pyright-internal/src/analyzer/commentUtils.ts b/packages/pyright-internal/src/analyzer/commentUtils.ts index f047c1d1c..3e0fab5cf 100644 --- a/packages/pyright-internal/src/analyzer/commentUtils.ts +++ b/packages/pyright-internal/src/analyzer/commentUtils.ts @@ -132,13 +132,17 @@ function _parseDiagLevel(value: string): DiagnosticLevel | undefined { case 'false': case 'none': return 'none'; + case 'true': case 'error': return 'error'; + case 'warning': return 'warning'; + case 'information': return 'information'; + default: return undefined; } diff --git a/packages/pyright-internal/src/common/diagnostic.ts b/packages/pyright-internal/src/common/diagnostic.ts index bbbcba533..5035e959a 100644 --- a/packages/pyright-internal/src/common/diagnostic.ts +++ b/packages/pyright-internal/src/common/diagnostic.ts @@ -25,10 +25,13 @@ export function convertLevelToCategory(level: DiagnosticLevel) { switch (level) { case 'error': return DiagnosticCategory.Error; + case 'warning': return DiagnosticCategory.Warning; + case 'information': return DiagnosticCategory.Information; + default: throw new Error(`${level} is not expected`); } diff --git a/packages/pyright-internal/src/languageServerBase.ts b/packages/pyright-internal/src/languageServerBase.ts index 669c9cc0d..40b640433 100644 --- a/packages/pyright-internal/src/languageServerBase.ts +++ b/packages/pyright-internal/src/languageServerBase.ts @@ -1049,19 +1049,19 @@ export abstract class LanguageServerBase implements LanguageServerInterface { return completions?.completionList; } - protected convertLogLevel(logLevel?: string): LogLevel { - if (!logLevel) { + protected convertLogLevel(logLevelValue?: string): LogLevel { + if (!logLevelValue) { return LogLevel.Info; } - switch (logLevel.toLowerCase()) { + switch (logLevelValue.toLowerCase()) { case 'error': return LogLevel.Error; case 'warning': return LogLevel.Warn; - case 'info': + case 'information': return LogLevel.Info; case 'trace': diff --git a/packages/vscode-pyright/package.json b/packages/vscode-pyright/package.json index 581f94c18..e7aaaac15 100644 --- a/packages/vscode-pyright/package.json +++ b/packages/vscode-pyright/package.json @@ -576,7 +576,7 @@ "enum": [ "Error", "Warning", - "Info", + "Information", "Trace" ] },