posit-dev / posit-dev/go-python-packaging
Add a PEP 503-named entry point for project-name normalization
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 0
- Fork
- 0
- Merge medio
- 2h 49m
- PR unite (30g)
- 8
Descrizione
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:
- A
packagenamepackage withNormalize(string) string, andextras.Normalizedelegating to it (or vice versa) so there is exactly one implementation. - Keep one implementation in an internal package, with
extras.Normalizeandpackagename.Normalizeas 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'sindex/name.goto 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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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.
Direzione di ricerca
Leggi prima l’implementazione esistente di extras.Normalize e i relativi test, quindi esamina index/name.go di go-pyresolver e gli esempi di PEP 503 citati nell’issue. Aggiungi l’entry point project-name indicato con un’unica implementazione condivisa senza regex, aggiorna il punto di chiamata del resolver e verifica che passino i test esistenti di extras e i nuovi casi di project-name.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 72/100