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

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

オープン
#25 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Go
スター
0
フォーク
0
平均マージ
2時間 49分
マージ済み PR(30日)
8

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず既存の extras.Normalize の実装とそのテストを読み、次に go-pyresolver の index/name.go と、issue で参照されている PEP 503 の例を調べます。共有する regex-free 実装を1つ使って、指定された project-name エントリポイントを追加し、resolver の呼び出し箇所を更新して、既存の extras テストと新しい project-name のケースが通ることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
go
領域
tooling
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
72/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。