Skip to content

Commit

Permalink
switch to a different toml parsing library because the new version of…
Browse files Browse the repository at this point in the history
… @iarna/toml was causing the ci to crash on windows with out of memory errors
  • Loading branch information
DetachHead committed Oct 23, 2024
1 parent 2cd2940 commit a0f0352
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 12 deletions.
103 changes: 97 additions & 6 deletions packages/pyright-internal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/pyright-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"@iarna/toml": "3.0.0",
"@yarnpkg/fslib": "2.10.4",
"@yarnpkg/libzip": "2.3.0",
"chalk": "^4.1.2",
"chokidar": "^3.6.0",
"command-line-args": "^5.2.1",
"diff": "^7.0.0",
"js-toml": "^1.0.0",
"jsonc-parser": "^3.3.1",
"leven": "3.1.0",
"pyright-to-gitlab-ci": "^0.1.3",
Expand Down
10 changes: 5 additions & 5 deletions packages/pyright-internal/src/analyzer/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Python files.
*/

import * as TOML from '@iarna/toml';
import * as TOML from 'js-toml';
import * as JSONC from 'jsonc-parser';
import { AbstractCancellationTokenSource, CancellationToken } from 'vscode-languageserver';

Expand Down Expand Up @@ -1172,15 +1172,15 @@ export class AnalyzerService {
private _parsePyprojectTomlFile(pyprojectPath: Uri): object | undefined {
return this._attemptParseFile(pyprojectPath, (fileContents, attemptCount) => {
try {
const configObj = TOML.parse(fileContents);
if (configObj && configObj.tool) {
const toml = configObj.tool as TOML.JsonMap;
const configObj = TOML.load(fileContents);
if (configObj && 'tool' in configObj) {
const toml = configObj.tool as Record<string, object>;
if (toml.basedpyright && toml.pyright) {
throw new Error(
'Pyproject file cannot have both `pyright` and `basedpyright` sections. pick one'
);
}
return (toml.basedpyright || toml.pyright) as object;
return toml.basedpyright || toml.pyright;
}
} catch (e) {
(this._console as ConsoleInterface).error(
Expand Down

0 comments on commit a0f0352

Please sign in to comment.