Skip to content

Commit

Permalink
Fixed bug that affects pyproject.toml files with an emoji character b…
Browse files Browse the repository at this point in the history
…y switching to a different toml parser. This addresses #9412.
  • Loading branch information
erictraut committed Nov 10, 2024
1 parent 0aa0c26 commit 6be5f8c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 102 deletions.
109 changes: 12 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 @@ -24,9 +24,9 @@
"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",
"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,8 +8,8 @@
* Python files.
*/

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

import { BackgroundAnalysisBase, RefreshOptions } from '../backgroundAnalysisBase';
Expand Down Expand Up @@ -1136,7 +1136,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) {
return (configObj.tool as Record<string, object>).pyright as object;
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2019",
"module": "node16",
"module": "preserve",
"lib": [
"es2019"
],
Expand All @@ -10,7 +10,7 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node16",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"sourceMap": true,
"outDir": "./out",
Expand Down

0 comments on commit 6be5f8c

Please sign in to comment.