python / python/importlib_metadata

Revisit relationship between Distribution and PathDistribution

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

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

help wanted
Ngôn ngữ chính
Python
Star
142
Fork
97
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Should Distribution objects expose a method to resolve paths?

Yes, that is one solution. There is already .locate_file() which is not far off, except that its implementation in PathDistribution precisely removes the metadata directory that we need in this case.

More generally, I wonder if there is just a tad too much coupling between the Distribution and PathDistribution classes?

There is a mix of abstract and concrete methods in the Distribution base class, and several of the concrete methods seem fairly tightly bound to the PathDistribution subclass. For example, the at() static method creates and returns a PathDistribution instance outright, and the metadata(), entry_points(), files(), and requires() methods are all implemented with assumptions as to which files should be available and that the organization should resemble a dist-info or egg-info distribution.

Now, there is (AFAICS) only the one (PathDistribution) subclass of Distribution available in this project, and I don't really have enough experience with this project or its users to really imagine what other Distribution subclasses would or could exist in the wild.

Still, I would suspect that a subclass that was sufficiently different from PathDistribution to rather prefer subclassing Distribution directly, would then find itself not merely implementing the read_text() an locate_file() abstract methods, but would probably also need to _re_implement several of metadata(), entry_points(), files(), or requires() as well.

Hence, I would raise the question whether some of these methods would be better off with their concrete implementations moved into the PathDistribution subclass? (Of course leaving abstract methods behind in Distribution where that makes sense.) This would grant these concrete methods direct access to the stuff they need inside PathDistribution, instead of having to add more interfaces to Distribution for stuff that really only makes sense for PathDistribution.

Still, this is a much bigger refactoring than I set out to do, and I would not feel comfortable starting this without consulting you.

Originally posted by @jherland in https://github.com/python/importlib_metadata/pull/437#discussion_r1141220985

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

Bắt đầu bằng cách đọc các lớp Distribution và PathDistribution cùng các phương thức được nêu trong issue: at(), metadata(), entry_points(), files(), requires(), read_text() và locate_file(). Xem lại phần thảo luận của pull request được liên kết để biết bối cảnh ban đầu. Để được xem là hoàn tất, cần có một thiết kế đã được thống nhất nhằm tách biệt hành vi đặc thù của lớp con và một triển khai bảo toàn chức năng liên quan của distribution.

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

Đánh giá

Công nghệ
python
Lĩnh vực
devtools
Loại issue
Tái cấu trúc
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/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.