Skip to content

Commit

Permalink
switch to smol-toml for toml parsing to fix crash when `pyproject.tom…
Browse files Browse the repository at this point in the history
…l` contains emojis
  • Loading branch information
DetachHead committed Oct 28, 2024
1 parent a9ee22f commit c1f0c20
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 100 deletions.
110 changes: 13 additions & 97 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 @@ -26,10 +26,10 @@
"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",
"smol-toml": "^1.3.0",
"source-map-support": "^0.5.21",
"tmp": "^0.2.3",
"vscode-jsonrpc": "^9.0.0-next.5",
Expand Down
4 changes: 2 additions & 2 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 'js-toml';
import { parse } from 'smol-toml';
import * as JSONC from 'jsonc-parser';
import { AbstractCancellationTokenSource, CancellationToken } from 'vscode-languageserver';

Expand Down Expand Up @@ -1172,7 +1172,7 @@ export class AnalyzerService {
private _parsePyprojectTomlFile(pyprojectPath: Uri): object | undefined {
return this._attemptParseFile(pyprojectPath, (fileContents, attemptCount) => {
try {
const configObj = TOML.load(fileContents);
const configObj = parse(fileContents);
if (configObj && 'tool' in configObj) {
const toml = configObj.tool as Record<string, object>;
if (toml.basedpyright && toml.pyright) {
Expand Down

0 comments on commit c1f0c20

Please sign in to comment.