posit-dev / posit-dev/go-python-packaging
Add a PEP 503-named entry point for project-name normalization
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 0
- Forks
- 0
- Merge medio
- 2 h 49 min
- PR fusionados (30 d)
- 8
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Lee primero la implementación existente de extras.Normalize y sus pruebas; después, inspecciona index/name.go de go-pyresolver y los ejemplos de PEP 503 referenciados en el issue. Añade el punto de entrada project-name indicado con una única implementación compartida sin regex, actualiza el sitio de llamada del resolver y verifica que pasen las pruebas existentes de extras, además de los nuevos casos de project-name.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- go
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 72/100