Include the opening brace's line in multiline f-string errors
オープン
まだ誰も着手していません。
interpreter-core
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
An unclosed f-string replacement field can report an error on a later line, making the opening brace hard to find:
var = "abc"
a = f""" {var} extern "C" { """
b = """ string """
File "script.py", line 3
b = """ string """
^
SyntaxError: f-string: expecting '}'
The quotes after the second { start a string inside the replacement field. That string ends on line 3, and the final quotes start another string that is never closed.
The error should include the line number of the opening brace:
SyntaxError: f-string: expecting '}' to close '{' on line 2
The same problem affects t-strings. Valid strings inside replacement fields should continue to work.
Linked PRs
- gh-157779
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された複数行 f-string の再現コードから始め、その診断結果を期待されるメッセージと比較します。対応する t-string のケースを確認し、置換フィールド内の有効な文字列が引き続き機能することを確認します。影響を受ける両方のエラーメッセージが開き波括弧の行を示し、有効な文字列を壊さないことが完了の条件です。リンクされた pull request はすでに一覧にあります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100