Skip to content

feat(extras): PEP 685 extra-name normalization (#18638) - #5

Merged
jonyoder merged 1 commit into
mainfrom
impl-extras
Jul 9, 2026
Merged

jonyoder merged 1 commit into
mainfrom
impl-extras

Conversation

@jonyoder

@jonyoder jonyoder commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Implements extras/ — PEP 685 extra-name normalization — the first of three PRs building the PEP 508 core (extras → marker → requirement) for the native Go PyPI resolver (RFD 0001, epic rstudio/package-manager#18625).

Closes rstudio/package-manager#18638.

What

func extras.Normalize(name string) string returns the PEP 685 / PEP 503 canonical form of an extra name: lowercase, with any run of -, _, or . collapsed to a single -. Lenient (does not reject legacy/invalid names), per PEP 685 consumer guidance.

Notes

  • Single-pass strings.Builder implementation (no regexp) — this is a per-dependency/per-extra resolver hot path, mirroring packaging's hand-optimized canonicalize_name.
  • Attribution to pypa/packaging packaging/utils.py canonicalize_name (Apache-2.0) added to NOTICE and the function doc comment.
  • Table-driven tests cover the separator-collapsing edge cases (all-separator, leading, trailing, mixed runs), empty string, and idempotency.

Verification

go build, go vet, go test ./extras/... all pass; gofmt -l empty; golangci-lint run ./... (v2) reports 0 issues.

@jonyoder
jonyoder merged commit 7efab0b into main Jul 9, 2026
2 checks passed
@jonyoder
jonyoder deleted the impl-extras branch July 9, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant