Improvements Related to Namespace Package Portions for PathEntryFinders
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- documentation, tooling
Hướng nghiên cứu
Bắt đầu với mục tài liệu về PathEntryFinder.find_spec() và phần language-reference namespace-packages được liên kết trong issue. Đọc bối cảnh của PEP 420 và PEP 451, sau đó xem xét các phương án chưa được giải quyết để xác định các phần và xử lý dữ liệu Spec bổ sung. Công việc được xem là hoàn tất khi hành vi do dự án lựa chọn được ghi chép rõ ràng và mọi thay đổi hành vi liên quan đã được thống nhất trước khi triển khai.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
tl;dr there are some oddities we should consider addressing with namespace package portions coming from path entry finders. It probably isn't worth bothering though (except for the docs fixes).
PEP 420 added (implicit) namespace packages. At that time, and since then, namespace packages (and portions) have gotten special-casing throughout the import machinery. Generally, we treat them like normal modules (or specs) even though certain characteristics don't apply. This isn't a problem generally because namespace packages aren't that common (and because, I expect, only builtin importers ever deal with them). However, there are a few things that it might be worth addressing.
PEP 451 introduced ModuleSpec, etc. PathEntryFinder.find_spec() as the replacement for PathEntryFinder.find_loader(), with some notable differences:
find_loader()returns(loader, portion)- the interpretation of this value is clearly documented
- the finder can't provide any other possible information
- if the returned loader is not
Nonethen the portion is ignored (not even a warning is set)
find_spec()returns aModuleSpecwithloaderset toNoneandsubmodule_search_locationsset to the portion- the interpretation of this value for portions is not clearly documented anywhere
- the path entry finder may set addition info on the spec (e.g.
loader_state) but it is all ignored (not even a warning if set)
In both cases, the language reference is not clear about how to identify namespace package portions from a path entry finder.
What to Do?
- update the
PathEntryFinder.find_spec()docs entry - (a weak maybe) add the details to the language reference
- (maybe) be more explicit when returning a namespace package portion
- (maybe) strictly disallow (or warn) for extraneous information tied to a portion
explicitly identify namespace package portions
- do nothing
- use a dedicated singleton instead of None
- use a dedicated ModuleSpec subclass (e.g. NamespacePackagePortionSpec)
- use a dedicated ModuleSpec-compatible class (e.g. NamespacePackagePortionSpec)
explicitly deal with unexpectedly set data
(This is basically just if spec.origin is set.)
- do nothing
- emit a warning
- fail
explicitly deal with spec.loader_state
- do nothing
- emit a warning
- fail
- preserve the info on the spec of the combined namespace package
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
docs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
stdlib topic-email type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Tất cả issue của python/cpython
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
bancolombia/sentinel#23 ·
-
test md Đang mởCI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100