Make "perhaps you missed a comma?" hint in syntax warnings less cryptic
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Feature or enhancement
Proposal:
Syntax warnings for code like [][""], [](), and 1[2] finish with the hint "perhaps you missed a comma?"
>>> lambda: 1[2]
<python-input-23>:1: SyntaxWarning: 'int' object is not subscriptable; perhaps you missed a comma?
<function <lambda> at 0x705dfb04b920>
When this came up in a review of currently emitted syntax warnings, it took me a moment to realise that it was suggesting the two subexpressions might have been supposed to be separate items in a sequence definition.
While I expect this would be clearer in the context of an actual warning, in isolation it felt very cryptic. Perhaps it would make sense to expand the hint to "did you miss a comma to separate sequence elements?"
Edit: Amended proposed text as @hugovk suggested
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-140893
- gh-143278
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先查看連結的 PR gh-140893 和 gh-143278,然後檢查 [][""]、[]() 和 1[2] 等範例的語法警告行為。完成的標準是:警告提示清楚說明序列元素之間可能缺少逗號,同時相關警告範例仍會如預期運作。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- compilers
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100