Improvements Related to Namespace Package Portions for PathEntryFinders
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- documentation, tooling
Direzione di ricerca
Inizia dalla voce di documentazione di PathEntryFinder.find_spec() e dalla sezione language-reference namespace-packages collegata nell’issue. Leggi il contesto di PEP 420 e PEP 451, quindi esamina le alternative ancora irrisolte per identificare le porzioni e gestire i dati Spec aggiuntivi. Il lavoro è completo quando il comportamento scelto dal progetto è documentato chiaramente e ogni modifica comportamentale correlata è stata concordata prima dell’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 36k
- Merge medio
- 1g 9h
- PR unite (30g)
- 558
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python/cpython
-
docs pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
stdlib type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
stdlib type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
build type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
stdlib topic-email type-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Tutte le issue di python/cpython
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
zostera/django-bootstrap4#894 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
use-agent-os/agent-os#3276 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·