Hi, is it possible, that `__defaults__` gets ignor...
# general
h
Hi, is it possible, that
__defaults__
gets ignored somehow by BUILD files inside a subdirectory? Maybe this is a bug, because I have a top level
django/BUILD
file which contains:
Copy code
__defaults__({
    (python_tests): dict(dependencies=["django/django_core/settings.py"])
})
And a BUILD file under
django/sub/tests/classes/BUILD
which just defines:
Copy code
python_tests(
    name="tests",
)
The dependencies goal in the subdirectory does not reference
django/django_core/settings.py
If I extend the contents of
django/sub/tests/classes/BUILD
the dependency
django/django_core/settings.py
gets shown correctly:
Copy code
__defaults__({
    (python_tests): dict(dependencies=["django/django_core/settings.py"])
})
python_tests(
    name="tests",
)
I just found out, that every subdirectory seems to need a BUILD file in order for the deepest BUILD file to inherit the toplevel
__default__
argument. Is this behavior expected? I need to manually create empty BUILD files for:
django/sub/BUILD
django/sub/tests/BUILD
just to make
django/sub/tests/classes/BUILD
inherit the defaults from
django/BUILD
c
That is unexpected.
Hmm, well, that is a bug you’ve found (thank you!) That is an oversight on my part, that if there is not an unbroken sequence of BUILD files, the higher level defaults will not propagate properly. https://github.com/pantsbuild/pants/blob/0a3367a239987359a7cb791bc6b3f51d736e4b51/src/python/pants/engine/internals/build_files.py#L158-L159 shows that when there is no BUILD file in a directory, the chain of defaults are broken.
h
Great that I could help! Thanks for the fast fix!
🙌 1