argparse - make return type from `add_subparsers` public
オープン
まだ誰も着手していません。
stdlib
topic-typing
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
This issue was brought up and closed as part of issue # 41592.
The add_subparsers method returns a protected _SubParsersAction instance. To add a sub-parser, the public add_parser method of the protected _SubParsersAction instance must be used.
- It is unexpected to require the use of a public method of a protected class instance.
- The protected return type breaks type hinting because
- protected and should not be imported
- it is not available for import
Real world use case example:
sub_parsers_action = parser.add_subparsers(...)
def build_subcmd(sub_parsers_action: _SubParsersAction):
...
The ask is to make the type of whatever is returned from add_subparsers public.
Linked PRs
- gh-157001
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
argparse.ArgumentParser.add_subparsers から開始し、返される _SubParsersAction を、その公開メソッドである add_parser を含めて追跡します。リンク先の PR gh-157001 と、周辺の argparse の typing/API コンテキストを確認します。完了条件は、保護されたクラスをインポートせずに、返される型を型ヒントで公開利用できることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- cli
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100