python / python/cpython

compile(): `func_type` mode is not documented

オープン
#153,528 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

docs
主要言語
Python
スター
77.2k
フォーク
35.9k
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

compile() 関数のドキュメントを、issue にリンクされている既存の ast.parse() ドキュメントと比較し、ドキュメント化されていない 'func_type' モードに重点を置いてください。compile() のドキュメントがこのモードを説明するか、ast.parse() の説明へ読者を明確に誘導すれば完了です。開始前に、リンクされている PR gh-153542 と gh-153561 を確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1時間未満
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。