Improvements Related to Namespace Package Portions for PathEntryFinders
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
説明
tl;dr there are some oddities we should consider addressing with namespace package portions coming from path entry finders. It probably isn't worth bothering though (except for the docs fixes).
PEP 420 added (implicit) namespace packages. At that time, and since then, namespace packages (and portions) have gotten special-casing throughout the import machinery. Generally, we treat them like normal modules (or specs) even though certain characteristics don't apply. This isn't a problem generally because namespace packages aren't that common (and because, I expect, only builtin importers ever deal with them). However, there are a few things that it might be worth addressing.
PEP 451 introduced ModuleSpec, etc. PathEntryFinder.find_spec() as the replacement for PathEntryFinder.find_loader(), with some notable differences:
find_loader()returns(loader, portion)- the interpretation of this value is clearly documented
- the finder can't provide any other possible information
- if the returned loader is not
Nonethen the portion is ignored (not even a warning is set)
find_spec()returns aModuleSpecwithloaderset toNoneandsubmodule_search_locationsset to the portion- the interpretation of this value for portions is not clearly documented anywhere
- the path entry finder may set addition info on the spec (e.g.
loader_state) but it is all ignored (not even a warning if set)
In both cases, the language reference is not clear about how to identify namespace package portions from a path entry finder.
What to Do?
- update the
PathEntryFinder.find_spec()docs entry - (a weak maybe) add the details to the language reference
- (maybe) be more explicit when returning a namespace package portion
- (maybe) strictly disallow (or warn) for extraneous information tied to a portion
explicitly identify namespace package portions
- do nothing
- use a dedicated singleton instead of None
- use a dedicated ModuleSpec subclass (e.g. NamespacePackagePortionSpec)
- use a dedicated ModuleSpec-compatible class (e.g. NamespacePackagePortionSpec)
explicitly deal with unexpectedly set data
(This is basically just if spec.origin is set.)
- do nothing
- emit a warning
- fail
explicitly deal with spec.loader_state
- do nothing
- emit a warning
- fail
- preserve the info on the spec of the combined namespace package
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
PathEntryFinder.find_spec() のドキュメント項目と、issue でリンクされている language-reference namespace-packages セクションから始めます。PEP 420 と PEP 451 の背景を読み、その後、部分を識別する方法と追加の Spec データを扱う方法について、未解決の選択肢を確認します。プロジェクトが選択した動作が明確に文書化され、関連する動作変更について実装前に合意されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation, tooling
- issue の種類
- ドキュメント
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100