[gazelle] `python_ignore_files` directive incorrectly (?) ignores files with the same name in subpackages
#2,147 opened on 2024幎8æ22æ¥
Repository metrics
- Stars
- Â (679 stars)
- PR merge metrics
- Â (PR metrics pending)
説æ
ð 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:
- only act on the current Bazel package
- only act on non-wildcard paths relative to the Bazel package that the directive is defined in
- only act on glob expansions relative to the Bazel package that the directive is defined in
(1) is the behavior that I1 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.
ð¬ Minimal Reproduction
- Make this directory structure:
.
âââ bar
â  âââ baz.py
â  âââ BUILD
â  âââ some_other.py
âââ foo
â  âââ baz.py
â  âââ BUILD
âââ __init__.py
âââ BUILD
- Set these directives:
# ./BUILD
# gazelle:ignore baz.py
- 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.
Footnotes
-
I can't say what other people expected, haha â©