Skip to content

Commit

Permalink
Switched to a different toml parser to avoid incompatibility with the…
Browse files Browse the repository at this point in the history
… latest toml standard. This addresses #9296.
  • Loading branch information
erictraut committed Oct 25, 2024
1 parent 5537ec9 commit 662ebf5
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 11 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 @@ -19,12 +19,12 @@
"test:imports": "jest importResolver.test --forceExit --runInBand"
},
"dependencies": {
"@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",
"js-toml": "^1.0.0",
"jsonc-parser": "^3.3.1",
"leven": "3.1.0",
"source-map-support": "^0.5.21",
Expand Down
8 changes: 4 additions & 4 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 @@ -1137,9 +1137,9 @@ 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 && (configObj.tool as TOML.JsonMap).pyright) {
return (configObj.tool as TOML.JsonMap).pyright as object;
const configObj = TOML.load(fileContents);
if (configObj && 'tool' in configObj) {
return (configObj.tool as Record<string, object>).pyright as object;
}
} catch (e: any) {
this._console.error(`Pyproject file parse attempt ${attemptCount} error: ${JSON.stringify(e)}`);
Expand Down

0 comments on commit 662ebf5

Please sign in to comment.