Improve syntax error when brackets (parentheses) are mismatched
まだ誰も着手していません。
評価
調査の方向性
まず、不一致の括弧を処理する parser または構文エラーの診断コードを見つけ、次に報告された例に対する既存のテストを探します。診断が開き括弧と閉じ括弧の両方を指すように動作を更新し、混在した括弧に対して表示されるキャレット位置を確認します。
索引モデルが issue の本文から書いたものです。
説明
The syntax error for mismatched brackets uses a caret to point to the closing bracket. But sometimes it is the opening bracket which is wrong. We should point a caret at both.
For example, this simple expression points to the closing square bracket:
>>> obj{"some long expression"]
File "<stdin>", line 1
obj{"some long expression"]
^
SyntaxError: closing parenthesis ']' does not match opening parenthesis '{'
But the real cause of the issue is the opening brace. It would be helpful to point at that as well:
obj{"some long expression"]
^ ^
SyntaxError: closing parenthesis ']' does not match opening parenthesis '{'
This is especially helpful in complex expressions with many mixed parentheses:
>>> obj[func(x[store[arg, a[i], b[j])])[y]]
File "<stdin>", line 1
obj[func(x[store[arg, a[i], b[j])])[y]]
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
The reader has to carefully match up brackets by hand to see where the opening bracket is. A second caret would make that instantaneous:
obj[func(x[store[arg, a[i], b[j])])[y]]
^ ^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
docs pending
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
build type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
stdlib topic-email type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
似ている issue
-
🐛 Bug 🔔 Pending processing
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
jumpserver/jumpserver#17584 ·
-
link-check link-check:sphinx-theme
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
modelscope/DiffSynth-Studio#1702 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·