posit-dev / posit-dev/go-python-packaging

Add a PEP 503-named entry point for project-name normalization

Offen
#25 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Go
Sterne
0
Forks
0
Ø Merge
2 Std. 49 Min.
Gemergte PRs (30 T.)
8

Beschreibung

Describe the feature

Add a PEP 503-named entry point for project-name normalization, so callers normalizing a package name don't have to reach for extras.Normalize.

Why

PEP 503 project-name normalization and PEP 685 extra-name normalization are the same transformation — lowercase, then collapse any run of -, _, . into a single -. extras.Normalize already implements it, and its own doc comment says it mirrors pypa/packaging's canonicalize_name for PEP 503/685 both.

So the behavior is right and there is no duplication to remove. The problem is purely discoverability and call-site legibility: go-pyresolver's index.NewPackageName currently calls extras.Normalize to normalize a project name, which reads like a bug at the call site even though it is correct. The alternative — a second copy of the algorithm in go-pyresolver — would be worse, since two copies can drift.

Suggested shape

Either is fine; the second is probably cleaner:

  1. A packagename package with Normalize(string) string, and extras.Normalize delegating to it (or vice versa) so there is exactly one implementation.
  2. Keep one implementation in an internal package, with extras.Normalize and packagename.Normalize as thin named wrappers, each documenting its PEP.

Whichever way, one implementation. The current function is on a per-dependency, per-extra hot path during resolution and is deliberately regex-free, so keep that property.

Testing notes

The existing extras tests cover the transformation. A new entry point needs only enough to prove delegation, plus the PEP 503 examples from pypa/packaging's own test suite for the project-name framing.

Additional notes

  • Once this lands, update go-pyresolver's index/name.go to call the new entry point and drop the apologetic comment pointing here.
  • Not urgent and not blocking: today's arrangement is correct, just awkward to read.

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

Lies zuerst die bestehende Implementierung von extras.Normalize und ihre Tests, und untersuche anschließend go-pyresolver's index/name.go sowie die im Issue referenzierten PEP 503-Beispiele. Füge den benannten project-name-Einstiegspunkt mit einer einzigen gemeinsam genutzten regex-freien Implementierung hinzu, aktualisiere die Resolver-Aufrufstelle und verifiziere, dass die bestehenden extras-Tests sowie die neuen project-name-Fälle erfolgreich durchlaufen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
72/100

Neue Issues direkt in Ihr Postfach

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