Semantic and documentation of Interpreter.prepare_main()
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Interpreter.prepare_main() is documented as:
.. method:: prepare_main(ns=None, **kwargs)
Bind objects in the interpreter's :mod:`!__main__` module.
Some objects are actually shared and some are copied efficiently,
but most are copied via :mod:`pickle`. See :ref:`interp-object-sharing`.
But it is not clear what ns is, and how kwargs is related. A module and a class are nemspaces, so can you pass them? Or the SimpleNamespace instance? No. Looking at the code, ns can only be None, a mapping or an iterable of pairs. Is it what was intended? Than it should be documented.
But accepting an iterable of pairs may be not intended. This can hardly be called a namespace. Then the code should be changed from
ns = dict(ns, **kwargs) if ns is not None else kwargs
to
ns = {**ns, **kwargs} if ns is not None else kwargs
And was it necessary to accept None? This is error-prone, as you can accidentally get None instead of a valid value (missing return or missing initialization). {} could be used as a default value, it is fine if it is not mutated. If exclude None, it can be simply written as:
ns = {**ns, **kwargs}
And I suggest to to change the name of the parameter, as it is not a general namespace. "dict" or "mapping" would better reflect its type. "updates" or "changes" could also be used, but then we should also rename "kwargs" to "updates2" or "changes2". Since this is positional-only parameter, changing the name does not break user code.
cc @ericsnowcurrently
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Interpreter.prepare_main() のドキュメントと実装から始め、特に ns と kwargs がどのように組み合わされるかを確認します。想定される受け入れ可能な入力型と、パラメーター名または動作を変更すべきかどうかを判断し、その後、API のセマンティクスが明確になるようにドキュメントまたは関連コードを更新し、関連するテストを追加または調整します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100