compile(): `func_type` mode is not documented
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
In 2019, compile() got a new mode="func_type" used to parse the signature of a function as AST:
- commit dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c
- issue gh-79947
>>> compile('() -> int', '<string>', 'func_type', flags=ast.PyCF_ONLY_AST)
FunctionType(argtypes=[], returns=Name(id='int', ctx=Load()))
>>> import ast; ast.parse('() -> int', '<string>', 'func_type')
FunctionType(argtypes=[], returns=Name(id='int', ctx=Load()))
It's tested by test_type_comments using ast.parse() function.
The 'func_type' mode is documented in ast.parse() documentation:
In addition, if mode is 'func_type', the input syntax is modified to correspond to PEP 484 “signature type comments”, e.g. (str, int) -> List[str].
But it's not documented in the compile() function documentation. Should it be documented there as well? Maybe at least by redirecting to ast.parse()?
Linked PRs
- gh-153542
- gh-153561
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
將 compile() 函式的文件與 issue 中連結的現有 ast.parse() 文件進行比較,重點關注未記錄的 'func_type' 模式。完成的標準是:compile() 文件要麼描述此模式,要麼明確將讀者引導至 ast.parse() 的說明;開始前請檢查已連結的 PR gh-153542 和 gh-153561。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100