bazel-contrib / bazel-contrib/rules_python
[gazelle] `python_ignore_files` directive incorrectly (?) ignores files with the same name in subpackages
- 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ả
# 🐞 bug report
### Affected Rule
+ gazelle
### Is this a regression?
No, I think this is as-built.
### Description
If you set `# gazelle:python_ignore_files foo.py` in your root dir, **all** files named `foo.py` will be ignored.
I'm not sure if this is WAI or not, but either way it's unexpected/undocumented behavior.
Instead, the `python_ignore_files` should do **one** of the following:
1. only act on the current Bazel package
2. only act on non-wildcard paths relative to the Bazel package that the directive is defined in
3. only act on glob expansions relative to the Bazel package that the directive is defined in
(1) is the behavior that _I_[^1] expected based on the limited documentation.
(2) is pretty nice because then you could put all of your ignores in a toplevel BUILD file, but it could mean a lot of duplication if you always want to ignore all "foo.py" that exist
(3) is the most complex to implement but also the most flexible. And even being "most complex", I don't imagine it's all that complicated.
[^1]: I can't say what other people expected, haha
## 🔬 Minimal Reproduction
1. Make this directory structure:
```
.
├── bar
│ ├── baz.py
│ ├── BUILD
│ └── some_other.py
├── foo
│ ├── baz.py
│ └── BUILD
├── __init__.py
└── BUILD
```
2. Set these directives:
```starlark
# ./BUILD
# gazelle:ignore baz.py
```
3. Run Gazelle
### Expected Behavior
There is no `./baz.py` file, so targets are generated for `bar/baz.py`, `bar/some_other.py`, and `foo/baz.py` in their respective BUILD files.
### Actual Behavior
Only `bar/some_other.py` has a target generated.
## 🔥 Exception or Error
N/A
## 🌍 Your Environment
**Operating System:**
gLinux (Debian Bookworm-based)
**Output of `bazel version`:**
7.2.0
**Rules_python version:**
0.33.1
**Anything else relevant?**
Related to #2108.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với tệp BUILD gốc và các tệp BUILD bên dưới bar/ và foo/ trong bản tái hiện tối thiểu, sau đó chạy Gazelle để quan sát cách chỉ thị gốc `gazelle:ignore baz.py` được áp dụng. Xác định hành vi phạm vi nào trong ba hành vi được đề xuất nên được hỗ trợ và xác minh rằng các target cho bar/baz.py và foo/baz.py được tạo, đồng thời hành vi dự kiến của tệp ở cấp gốc vẫn chính xác.
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
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100