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

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

Đang mở
#25 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Go
Star
0
Fork
0
Merge trung bình
2 giờ 49 phút
Pull request đã merge (30 ngày)
8

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Trước tiên, hãy đọc implementation hiện có của extras.Normalize và các test của nó, sau đó kiểm tra index/name.go của go-pyresolver cùng các ví dụ PEP 503 được issue tham chiếu. Thêm entry point project-name được nêu với một implementation dùng chung duy nhất không dùng regex, cập nhật call site của resolver và xác minh rằng các test extras hiện có cùng các case project-name mới đều pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
72/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.