From 8f35aa06437f517a03fc68a4ae086ede4e1b6f83 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 28 Dec 2024 14:22:36 -0700 Subject: [PATCH] Fixed bug that results in the `extraPaths` configuration option within an execution extending rather than overriding the `extraPaths` provided in the top-level config. This addresses #9636. (#9639) --- packages/pyright-internal/src/common/configOptions.ts | 4 ++++ packages/pyright-internal/src/tests/config.test.ts | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/pyright-internal/src/common/configOptions.ts b/packages/pyright-internal/src/common/configOptions.ts index c459cbf9b188..9515ecb059fb 100644 --- a/packages/pyright-internal/src/common/configOptions.ts +++ b/packages/pyright-internal/src/common/configOptions.ts @@ -1648,6 +1648,10 @@ export class ConfigOptions { `Config executionEnvironments index ${index}: extraPaths field must contain an array.` ); } else { + // If specified, this overrides the default extra paths inherited + // from the top-level config. + newExecEnv.extraPaths = []; + const pathList = envObj.extraPaths as string[]; pathList.forEach((path, pathIndex) => { if (typeof path !== 'string') { diff --git a/packages/pyright-internal/src/tests/config.test.ts b/packages/pyright-internal/src/tests/config.test.ts index c02e6b18ca7f..5b4da4d29f24 100644 --- a/packages/pyright-internal/src/tests/config.test.ts +++ b/packages/pyright-internal/src/tests/config.test.ts @@ -473,7 +473,6 @@ test('Command line options can override config but only when not using extension commandLineOptions.configSettings.useLibraryCodeForTypes = true; commandLineOptions.configSettings.includeFileSpecs = ['test2']; commandLineOptions.configSettings.excludeFileSpecs = ['test2']; - commandLineOptions.configSettings.extraPaths = ['test2']; commandLineOptions.configSettings.diagnosticSeverityOverrides = { reportMissingImports: DiagnosticSeverityOverrides.Error, }; @@ -485,10 +484,6 @@ test('Command line options can override config but only when not using extension assert.notDeepStrictEqual(defaultOptions.exclude, overriddenOptions.exclude); assert.notDeepStrictEqual(defaultOptions.ignore, overriddenOptions.ignore); assert.notDeepStrictEqual(defaultOptions.diagnosticRuleSet, overriddenOptions.diagnosticRuleSet); - assert.notDeepStrictEqual( - defaultOptions.executionEnvironments[0].extraPaths, - overriddenOptions.executionEnvironments[0].extraPaths - ); assert.notDeepStrictEqual(defaultOptions.venvPath, overriddenOptions.venvPath); // Typeshed and stub path are an exception, it should just be reported as a dupe. assert.deepStrictEqual(defaultOptions.typeshedPath, overriddenOptions.typeshedPath);