python / python/importlib_metadata

Using entry-point `value` for non-object references

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

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

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ả

napari uses the entry-point value for non-object references, i.e. a file path to load metadata from (i.e. as module:file_path).

This pattern seemed like a good idea for certain use cases. The main idea is that only reading metadata effectively ensures that we do no costly imports until we actually need to (which may be never).

Now, I noticed that since gh-518 such (ab)use is more heavily policed, since loading will fail immediately and not just when EntryPoint.load() is actually called.

So I suppose I have to comments/questions:

  1. The idea of (ab)using the entry-point for a metadata file seems neat to me. Would it be OK to accept it as use (even if not common or advertised) or is there a reason against it?
  2. Raising an error at EntryPoint construction itself fails already at importlib_metadata.entry_points(group="my_group"), which means that a bad entry-point cannot be skipped (unlike if it fails for EntryPoint.load() which may be guarded with a try/except).
    EDIT: I just noticed that group= seems to be applied after EntryPoint creation. So a single bad entry-point will break any project loading entry-points.

Neither of these are big issues, in practice a filename usually conforms (or can be made to conform) to a Python object reference, so there is nothing stopping us from just keeping to use it. But it seemed like a good thing to check in, if just for awareness that this pattern exists in the wild.

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 phần mô tả về việc xây dựng EntryPoint và hành vi của entry_points(group=...) trong issue, sau đó kiểm tra các thay đổi từ gh-518. Xác định xem có nên chấp nhận các giá trị entry-point không phải là đối tượng hay không, và liệu có thể bỏ qua các mục không hợp lệ trong quá trình chọn nhóm hay không; công việc được hoàn tất khi có quyết định được ghi lại và hành vi hoặc các bài kiểm thử tương ứng.

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
tooling
Loại issue
Tính năng
Độ 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.