So it seems there are 4 cases:
1. attribute is not set
2. attribute is set to None
3. attribute is set to empty list
4. attribute is set to some non-empty list (and the elements are different from the default elements)
For 1 and 2, I'm seeing the default value being used,
for 3 I'm seeing nothing being used,
and for 4 I'm seeing the values from the given list.
Is there some difference in the test setup below? Could the dependency be coming from some other place? Maybe from some dependency further down in the target's dependencies?
== defs.bzl ====================
def _impl(ctx):
print(ctx.attr.deps)
return []
myrule = rule(
implementation = _impl,
attrs = {
"deps": attr.label_list(default = [Label("//:dep")])
}
)
== build
======================
load(":defs.bzl", "myrule")
myrule(
name = "notset",
)
myrule(
name = "none",
deps = None,
)
myrule(
name = "empty_list",
deps = [],
)
myrule(
name = "set_to_other_dep",
deps = ["other_dep"],
)
genrule(
name = "dep",
outs = ["dep.out"],
cmd = "echo dep > $@",
)
genrule(
name = "other_dep",
outs = ["dep2.out"],
cmd = "echo dep2 > $@",
)
== output =================================
$ bazel query "deps(notset)" --notool_deps
//:notset
//:dep
Loading: 0 packages loaded
$ bazel query "deps(none)" --notool_deps
//:none
//:dep
Loading: 0 packages loaded
$ bazel query "deps(empty_list)" --notool_deps
//:empty_list
Loading: 0 packages loaded
$ bazel query "deps(set_to_other_dep)" --notool_deps
//:set_to_other_dep
//:other_dep
Loading: 0 packages loaded