protected update()

in src/client/common/configSettings.ts [231:505]


    protected update(pythonSettings: WorkspaceConfiguration): void {
        const workspaceRoot = this.workspaceRoot?.fsPath;
        const systemVariables: SystemVariables = new SystemVariables(undefined, workspaceRoot, this.workspace);

        this.pythonPath = this.getPythonPath(systemVariables, workspaceRoot);

        const defaultInterpreterPath = systemVariables.resolveAny(pythonSettings.get<string>('defaultInterpreterPath'));
        this.defaultInterpreterPath = defaultInterpreterPath || DEFAULT_INTERPRETER_SETTING;
        if (this.defaultInterpreterPath === DEFAULT_INTERPRETER_SETTING) {
            const autoSelectedPythonInterpreter = this.interpreterAutoSelectionService.getAutoSelectedInterpreter(
                this.workspaceRoot,
            );
            this.defaultInterpreterPath = autoSelectedPythonInterpreter?.path ?? this.defaultInterpreterPath;
        }
        this.defaultInterpreterPath = getAbsolutePath(this.defaultInterpreterPath, workspaceRoot);

        this.venvPath = systemVariables.resolveAny(pythonSettings.get<string>('venvPath'))!;
        this.venvFolders = systemVariables.resolveAny(pythonSettings.get<string[]>('venvFolders'))!;
        const condaPath = systemVariables.resolveAny(pythonSettings.get<string>('condaPath'))!;
        this.condaPath = condaPath && condaPath.length > 0 ? getAbsolutePath(condaPath, workspaceRoot) : condaPath;
        const pipenvPath = systemVariables.resolveAny(pythonSettings.get<string>('pipenvPath'))!;
        this.pipenvPath = pipenvPath && pipenvPath.length > 0 ? getAbsolutePath(pipenvPath, workspaceRoot) : pipenvPath;
        const poetryPath = systemVariables.resolveAny(pythonSettings.get<string>('poetryPath'))!;
        this.poetryPath = poetryPath && poetryPath.length > 0 ? getAbsolutePath(poetryPath, workspaceRoot) : poetryPath;

        this.downloadLanguageServer = systemVariables.resolveAny(
            pythonSettings.get<boolean>('downloadLanguageServer', true),
        )!;
        this.autoUpdateLanguageServer = systemVariables.resolveAny(
            pythonSettings.get<boolean>('autoUpdateLanguageServer', true),
        )!;

        // Get as a string and verify; don't just accept.
        let userLS = pythonSettings.get<string>('languageServer');
        userLS = systemVariables.resolveAny(userLS);

        // Validate the user's input; if invalid, set it to the default.
        if (
            !userLS ||
            userLS === 'Default' ||
            userLS === 'Microsoft' ||
            !Object.values(LanguageServerType).includes(userLS as LanguageServerType)
        ) {
            this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None;
            this.languageServerIsDefault = true;
        } else if (userLS === 'JediLSP') {
            // Switch JediLSP option to Jedi.
            this.languageServer = LanguageServerType.Jedi;
            this.languageServerIsDefault = false;
        } else {
            this.languageServer = userLS as LanguageServerType;
            this.languageServerIsDefault = false;
        }

        const autoCompleteSettings = systemVariables.resolveAny(
            pythonSettings.get<IAutoCompleteSettings>('autoComplete'),
        )!;
        if (this.autoComplete) {
            Object.assign<IAutoCompleteSettings, IAutoCompleteSettings>(this.autoComplete, autoCompleteSettings);
        } else {
            this.autoComplete = autoCompleteSettings;
        }

        const envFileSetting = pythonSettings.get<string>('envFile');
        this.envFile = systemVariables.resolveAny(envFileSetting)!;
        sendSettingTelemetry(this.workspace, envFileSetting);

        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        this.devOptions = systemVariables.resolveAny(pythonSettings.get<any[]>('devOptions'))!;
        this.devOptions = Array.isArray(this.devOptions) ? this.devOptions : [];

        const lintingSettings = systemVariables.resolveAny(pythonSettings.get<ILintingSettings>('linting'))!;
        if (this.linting) {
            Object.assign<ILintingSettings, ILintingSettings>(this.linting, lintingSettings);
        } else {
            this.linting = lintingSettings;
        }

        this.disableInstallationChecks = pythonSettings.get<boolean>('disableInstallationCheck') === true;
        this.globalModuleInstallation = pythonSettings.get<boolean>('globalModuleInstallation') === true;

        const sortImportSettings = systemVariables.resolveAny(pythonSettings.get<ISortImportSettings>('sortImports'))!;
        if (this.sortImports) {
            Object.assign<ISortImportSettings, ISortImportSettings>(this.sortImports, sortImportSettings);
        } else {
            this.sortImports = sortImportSettings;
        }
        // Support for travis.
        this.sortImports = this.sortImports ? this.sortImports : { path: '', args: [] };
        // Support for travis.
        this.linting = this.linting
            ? this.linting
            : {
                  enabled: false,
                  cwd: undefined,
                  ignorePatterns: [],
                  flake8Args: [],
                  flake8Enabled: false,
                  flake8Path: 'flake8',
                  lintOnSave: false,
                  maxNumberOfProblems: 100,
                  mypyArgs: [],
                  mypyEnabled: false,
                  mypyPath: 'mypy',
                  banditArgs: [],
                  banditEnabled: false,
                  banditPath: 'bandit',
                  pycodestyleArgs: [],
                  pycodestyleEnabled: false,
                  pycodestylePath: 'pycodestyle',
                  pylamaArgs: [],
                  pylamaEnabled: false,
                  pylamaPath: 'pylama',
                  prospectorArgs: [],
                  prospectorEnabled: false,
                  prospectorPath: 'prospector',
                  pydocstyleArgs: [],
                  pydocstyleEnabled: false,
                  pydocstylePath: 'pydocstyle',
                  pylintArgs: [],
                  pylintEnabled: false,
                  pylintPath: 'pylint',
                  pylintCategorySeverity: {
                      convention: DiagnosticSeverity.Hint,
                      error: DiagnosticSeverity.Error,
                      fatal: DiagnosticSeverity.Error,
                      refactor: DiagnosticSeverity.Hint,
                      warning: DiagnosticSeverity.Warning,
                  },
                  pycodestyleCategorySeverity: {
                      E: DiagnosticSeverity.Error,
                      W: DiagnosticSeverity.Warning,
                  },
                  flake8CategorySeverity: {
                      E: DiagnosticSeverity.Error,
                      W: DiagnosticSeverity.Warning,
                      // Per http://flake8.pycqa.org/en/latest/glossary.html#term-error-code
                      // 'F' does not mean 'fatal as in PyLint but rather 'pyflakes' such as
                      // unused imports, variables, etc.
                      F: DiagnosticSeverity.Warning,
                  },
                  mypyCategorySeverity: {
                      error: DiagnosticSeverity.Error,
                      note: DiagnosticSeverity.Hint,
                  },
              };
        this.linting.pylintPath = getAbsolutePath(systemVariables.resolveAny(this.linting.pylintPath), workspaceRoot);
        this.linting.flake8Path = getAbsolutePath(systemVariables.resolveAny(this.linting.flake8Path), workspaceRoot);
        this.linting.pycodestylePath = getAbsolutePath(
            systemVariables.resolveAny(this.linting.pycodestylePath),
            workspaceRoot,
        );
        this.linting.pylamaPath = getAbsolutePath(systemVariables.resolveAny(this.linting.pylamaPath), workspaceRoot);
        this.linting.prospectorPath = getAbsolutePath(
            systemVariables.resolveAny(this.linting.prospectorPath),
            workspaceRoot,
        );
        this.linting.pydocstylePath = getAbsolutePath(
            systemVariables.resolveAny(this.linting.pydocstylePath),
            workspaceRoot,
        );
        this.linting.mypyPath = getAbsolutePath(systemVariables.resolveAny(this.linting.mypyPath), workspaceRoot);
        this.linting.banditPath = getAbsolutePath(systemVariables.resolveAny(this.linting.banditPath), workspaceRoot);

        if (this.linting.cwd) {
            this.linting.cwd = getAbsolutePath(systemVariables.resolveAny(this.linting.cwd), workspaceRoot);
        }

        const formattingSettings = systemVariables.resolveAny(pythonSettings.get<IFormattingSettings>('formatting'))!;
        if (this.formatting) {
            Object.assign<IFormattingSettings, IFormattingSettings>(this.formatting, formattingSettings);
        } else {
            this.formatting = formattingSettings;
        }
        // Support for travis.
        this.formatting = this.formatting
            ? this.formatting
            : {
                  autopep8Args: [],
                  autopep8Path: 'autopep8',
                  provider: 'autopep8',
                  blackArgs: [],
                  blackPath: 'black',
                  yapfArgs: [],
                  yapfPath: 'yapf',
              };
        this.formatting.autopep8Path = getAbsolutePath(
            systemVariables.resolveAny(this.formatting.autopep8Path),
            workspaceRoot,
        );
        this.formatting.yapfPath = getAbsolutePath(systemVariables.resolveAny(this.formatting.yapfPath), workspaceRoot);
        this.formatting.blackPath = getAbsolutePath(
            systemVariables.resolveAny(this.formatting.blackPath),
            workspaceRoot,
        );

        const testSettings = systemVariables.resolveAny(pythonSettings.get<ITestingSettings>('testing'))!;
        if (this.testing) {
            Object.assign<ITestingSettings, ITestingSettings>(this.testing, testSettings);
        } else {
            this.testing = testSettings;
            if (isTestExecution() && !this.testing) {
                this.testing = {
                    pytestArgs: [],
                    unittestArgs: [],
                    promptToConfigure: true,
                    debugPort: 3000,
                    pytestEnabled: false,
                    unittestEnabled: false,
                    pytestPath: 'pytest',
                    autoTestDiscoverOnSaveEnabled: true,
                } as ITestingSettings;
            }
        }

        // Support for travis.
        this.testing = this.testing
            ? this.testing
            : {
                  promptToConfigure: true,
                  debugPort: 3000,
                  pytestArgs: [],
                  pytestEnabled: false,
                  pytestPath: 'pytest',
                  unittestArgs: [],
                  unittestEnabled: false,
                  autoTestDiscoverOnSaveEnabled: true,
              };
        this.testing.pytestPath = getAbsolutePath(systemVariables.resolveAny(this.testing.pytestPath), workspaceRoot);
        if (this.testing.cwd) {
            this.testing.cwd = getAbsolutePath(systemVariables.resolveAny(this.testing.cwd), workspaceRoot);
        }

        // Resolve any variables found in the test arguments.
        this.testing.pytestArgs = this.testing.pytestArgs.map((arg) => systemVariables.resolveAny(arg));
        this.testing.unittestArgs = this.testing.unittestArgs.map((arg) => systemVariables.resolveAny(arg));

        const terminalSettings = systemVariables.resolveAny(pythonSettings.get<ITerminalSettings>('terminal'))!;
        if (this.terminal) {
            Object.assign<ITerminalSettings, ITerminalSettings>(this.terminal, terminalSettings);
        } else {
            this.terminal = terminalSettings;
            if (isTestExecution() && !this.terminal) {
                this.terminal = {} as ITerminalSettings;
            }
        }
        // Support for travis.
        this.terminal = this.terminal
            ? this.terminal
            : {
                  executeInFileDir: true,
                  launchArgs: [],
                  activateEnvironment: true,
                  activateEnvInCurrentTerminal: false,
              };

        const experiments = systemVariables.resolveAny(pythonSettings.get<IExperiments>('experiments'))!;
        if (this.experiments) {
            Object.assign<IExperiments, IExperiments>(this.experiments, experiments);
        } else {
            this.experiments = experiments;
        }
        // Note we directly access experiment settings using workspace service in ExperimentService class.
        // Any changes here specific to these settings should propogate their as well.
        this.experiments = this.experiments
            ? this.experiments
            : {
                  enabled: true,
                  optInto: [],
                  optOutFrom: [],
              };

        this.insidersChannel = pythonSettings.get<ExtensionChannels>('insidersChannel')!;
        this.tensorBoard = pythonSettings.get<ITensorBoardSettings>('tensorBoard');
    }