python / python/importlib_metadata

Using entry-point `value` for non-object references

Offen
#523 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
142
Forks
97
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

napari uses the entry-point value for non-object references, i.e. a file path to load metadata from (i.e. as module:file_path).

This pattern seemed like a good idea for certain use cases. The main idea is that only reading metadata effectively ensures that we do no costly imports until we actually need to (which may be never).

Now, I noticed that since gh-518 such (ab)use is more heavily policed, since loading will fail immediately and not just when EntryPoint.load() is actually called.

So I suppose I have to comments/questions:

  1. The idea of (ab)using the entry-point for a metadata file seems neat to me. Would it be OK to accept it as use (even if not common or advertised) or is there a reason against it?
  2. Raising an error at EntryPoint construction itself fails already at importlib_metadata.entry_points(group="my_group"), which means that a bad entry-point cannot be skipped (unlike if it fails for EntryPoint.load() which may be guarded with a try/except).
    EDIT: I just noticed that group= seems to be applied after EntryPoint creation. So a single bad entry-point will break any project loading entry-points.

Neither of these are big issues, in practice a filename usually conforms (or can be made to conform) to a Python object reference, so there is nothing stopping us from just keeping to use it. But it seemed like a good thing to check in, if just for awareness that this pattern exists in the wild.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Lesen der im Issue beschriebenen Konstruktion von EntryPoint und des Verhaltens von entry_points(group=...), und untersuche anschließend die Änderungen aus gh-518. Bestimme, ob Entry-Point-Werte, die keine Objekte sind, akzeptiert werden sollten und ob ungültige Einträge bei der Gruppenauswahl übersprungen werden können; abgeschlossen ist die Aufgabe, wenn eine dokumentierte Entscheidung und das entsprechende Verhalten oder Tests vorliegen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.