bazel-contrib / bazel-contrib/rules_python

[gazelle] Adjust how `imports` is auto-generated

Đang mở
#2,144 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
gazelle help wanted
Ngôn ngữ chính
Starlark
Star
688
Fork
721
Merge trung bình
15 giờ 7 phút
Pull request đã merge (30 ngày)
76

Mô tả

Discussion moved from an internal doc and discussion with @rickeylev:

> Externally, the Bazel Python rules have an attribute named `imports`. This is a string list of repo-relative paths that should be added to `sys.path`.

@dougthor42 writes in a comment:

> FYI: With gazelle's `python_root` directive, these are autogenerated as package-relative paths, eg `["../../.."]`.
>
> Now that I see [that `imports` is repo-relative], I might submit a PR to change Gazelle to generate repo-relative paths.

@rickeylev replies:

> Hm. Is package-relative better than repo-relative? Quick thought is: they both have pros and cons.
> Which makes me think: is there something that has all pros and no cons?
> To which I think: maybe we can change the logic to more directly express what we're after.
> When src/my_package says "add .. to path", what it really means is: make sure sys.path has a directory with "my_package" as a sub directory.
> So maybe instead we add a top_level_package_name attribute? Under the hood, a quick implementation would be to just do "compute the correct imports attr value automatically". A better impl for the future would be to ensure that some directory with the desired name ends up in sys.path, however that may come to be.
>
> Thanks for the inspiration :)

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

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Issue đề cập đến các quy tắc Python của Gazelle và thuộc tính `imports` được tạo ra, nhưng không cung cấp tệp, bài kiểm thử hoặc điểm bắt đầu nào. Hãy bắt đầu bằng việc xác định logic của Gazelle tạo ra `imports` và các bài kiểm thử liên quan; công việc được xem là hoàn tất khi hành vi đường dẫn dự kiến đã được thống nhất và được bao phủ cho các trường hợp `python_root` liên quan.

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
build-system, 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.