Skip to content

Commit

Permalink
Fixed recent regression in the CLI that caused the --files command-…
Browse files Browse the repository at this point in the history
…line parameters to be overridden by the "include" setting in the config file. This change restores the behavior prior to 1.1.334. This addresses #6311.
  • Loading branch information
erictraut committed Nov 2, 2023
1 parent d95949a commit fc4ec7b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/pyright-internal/src/analyzer/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,14 @@ export class AnalyzerService {
commandLineOptions.analyzeUnannotatedFunctions;
}

// Override the include based on command-line settings.
if (commandLineOptions.includeFileSpecsOverride) {
configOptions.include = [];
commandLineOptions.includeFileSpecsOverride.forEach((include) => {
configOptions.include.push(getFileSpec(this.serviceProvider, include, '.'));
});
}

const reportDuplicateSetting = (settingName: string, configValue: number | string | boolean) => {
const settingSource = commandLineOptions.fromVsCodeExtension
? 'the client settings'
Expand Down
6 changes: 6 additions & 0 deletions packages/pyright-internal/src/common/commandLineOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export class CommandLineOptions {
// are included.
includeFileSpecs: string[] = [];

// If specified, this list of file specs overrides the includeFileSpecs
// above, rendering it as ignored. This is used
// for the CLI "--files" option, which should always override the "include"
// and "exclude" config file settings.
includeFileSpecsOverride?: string[];

// A list of file specs to exclude in the analysis. Can contain
// directories, in which case all "*.py" files within those directories
// are excluded.
Expand Down
6 changes: 2 additions & 4 deletions packages/pyright-internal/src/pyright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,8 @@ async function processArgs(): Promise<ExitStatus> {
}
}

options.includeFileSpecs = fileSpecList;
options.includeFileSpecs = options.includeFileSpecs.map((f) => combinePaths(process.cwd(), f));
} else {
options.includeFileSpecs = [];
options.includeFileSpecsOverride = fileSpecList;
options.includeFileSpecsOverride = options.includeFileSpecsOverride.map((f) => combinePaths(process.cwd(), f));
}

if (args.project) {
Expand Down

0 comments on commit fc4ec7b

Please sign in to comment.