RustPython / RustPython/Parser

Incorrect f-string parsing

未關閉
#88 1 則留言 4 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug
主要語言
Rust
星號
117
分支
38
平均合併
4 天 7 小時
30 天內合併 PR
1

描述

Originally reported as https://github.com/astral-sh/ruff/issues/5044:

Not the best string ever, but ruff doesn't handle it like Python

λ cat test.py
print(f"$N_{{img}}\in\{{0,1,2\}}$")
λ python test.py
$N_{img}\in\{0,1,2\}$
λ ruff check test.py --select F401
error: Failed to parse test.py:1:25: f-string: unterminated string

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用提供的 test.py 內容重現該報告,並將 Python 的輸出與 ruff check test.py --select F401 進行比較。追蹤此 f-string 的解析方式,並確保解析器接受跳脫的大括號和反斜線,而不是回報字串未終止。範例能夠在不出現所回報錯誤的情況下完成解析,並且與 Python 的行為一致,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python, rust
領域
compilers
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。