Skip to content

Commit

Permalink
make all config validation errors exit with a non-zero exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Jan 26, 2024
1 parent 59c2d97 commit 53ad974
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 145 deletions.
19 changes: 14 additions & 5 deletions packages/pyright-internal/src/analyzer/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,19 @@ export class AnalyzerService {
}

if (configJsonObj) {
configOptions.initializeFromJson(
const errors = configOptions.initializeFromJson(
configJsonObj,
this._typeCheckingMode,
this.serviceProvider,
host,
commandLineOptions.diagnosticSeverityOverrides
);
if (errors.length > 0) {
for (const error of errors) {
this._console.error(error);
}
this._reportConfigParseError();
}

const configFileDir = this._configFileUri!.getDirectory();

Expand Down Expand Up @@ -946,15 +952,18 @@ export class AnalyzerService {
if (configObj && configObj.tool) {
const toml = configObj.tool as TOML.JsonMap;
if (toml.basedpyright && toml.pyright) {
this._console.error(
throw new Error(
'Pyproject file cannot have both `pyright` and `basedpyright` sections. pick one'
);
return undefined;
}
return (toml.basedpyright || toml.pyright) as object;
}
} catch (e: any) {
this._console.error(`Pyproject file parse attempt ${attemptCount} error: ${JSON.stringify(e)}`);
} catch (e) {
this._console.error(
`Pyproject file parse attempt ${attemptCount} ${
e instanceof Error ? e : `error: ${JSON.stringify(e)}`
}`
);
throw e;
}

Expand Down
Loading

0 comments on commit 53ad974

Please sign in to comment.