mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Added new "--warnings" command-line option that generates an exit code of 1 if one or more warnings are emitted. By default, only errors generate an exit code of 1.
This commit is contained in:
parent
d5878534fc
commit
6107de9090
@ -21,6 +21,7 @@ Pyright can be run as either a VS Code extension or as a node-based command-line
|
|||||||
| --verbose | Emit verbose diagnostics |
|
| --verbose | Emit verbose diagnostics |
|
||||||
| --verifytypes `<IMPORT>` | Verify completeness of types in py.typed package |
|
| --verifytypes `<IMPORT>` | Verify completeness of types in py.typed package |
|
||||||
| --version | Print pyright version |
|
| --version | Print pyright version |
|
||||||
|
| --warnings | Use exit code of 1 if warnings are reported |
|
||||||
| -w, --watch | Continue to run and watch for changes (4) |
|
| -w, --watch | Continue to run and watch for changes (4) |
|
||||||
|
|
||||||
(1) If specific files are specified on the command line, the pyrightconfig.json file is ignored.
|
(1) If specific files are specified on the command line, the pyrightconfig.json file is ignored.
|
||||||
|
@ -136,6 +136,7 @@ async function processArgs(): Promise<ExitStatus> {
|
|||||||
{ name: 'verifytypes', type: String },
|
{ name: 'verifytypes', type: String },
|
||||||
{ name: 'verbose', type: Boolean },
|
{ name: 'verbose', type: Boolean },
|
||||||
{ name: 'version', type: Boolean },
|
{ name: 'version', type: Boolean },
|
||||||
|
{ name: 'warnings', type: Boolean },
|
||||||
{ name: 'watch', alias: 'w', type: Boolean },
|
{ name: 'watch', alias: 'w', type: Boolean },
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -249,6 +250,7 @@ async function processArgs(): Promise<ExitStatus> {
|
|||||||
}
|
}
|
||||||
options.checkOnlyOpenFiles = false;
|
options.checkOnlyOpenFiles = false;
|
||||||
|
|
||||||
|
const treatWarningsAsErrors = !!args.warnings;
|
||||||
const output = args.outputjson ? new StderrConsole() : undefined;
|
const output = args.outputjson ? new StderrConsole() : undefined;
|
||||||
const fileSystem = new PyrightFileSystem(createFromRealFileSystem(output));
|
const fileSystem = new PyrightFileSystem(createFromRealFileSystem(output));
|
||||||
|
|
||||||
@ -293,9 +295,15 @@ async function processArgs(): Promise<ExitStatus> {
|
|||||||
results.elapsedTime
|
results.elapsedTime
|
||||||
);
|
);
|
||||||
errorCount += report.errorCount;
|
errorCount += report.errorCount;
|
||||||
|
if (treatWarningsAsErrors) {
|
||||||
|
errorCount += report.warningCount;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const report = reportDiagnosticsAsText(results.diagnostics);
|
const report = reportDiagnosticsAsText(results.diagnostics);
|
||||||
errorCount += report.errorCount;
|
errorCount += report.errorCount;
|
||||||
|
if (treatWarningsAsErrors) {
|
||||||
|
errorCount += report.warningCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,6 +608,7 @@ function printUsage() {
|
|||||||
' --verbose Emit verbose diagnostics\n' +
|
' --verbose Emit verbose diagnostics\n' +
|
||||||
' --verifytypes <PACKAGE> Verify type completeness of a py.typed package\n' +
|
' --verifytypes <PACKAGE> Verify type completeness of a py.typed package\n' +
|
||||||
' --version Print Pyright version\n' +
|
' --version Print Pyright version\n' +
|
||||||
|
' --warnings Use exit code of 1 if warnings are reported\n' +
|
||||||
' -w,--watch Continue to run and watch for changes\n'
|
' -w,--watch Continue to run and watch for changes\n'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user