Skip to main content

bxl.UnconfiguredTargetNode type

Methods for unconfigured target node.

bxl.UnconfiguredTargetNode.attrs

bxl.UnconfiguredTargetNode.attrs: typing.Any

Gets the coerced attributes from the unconfigured target node. Returns a struct.

Sample usage:

def _impl_attributes(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.attrs.my_attr)

bxl.UnconfiguredTargetNode.buildfile_path

bxl.UnconfiguredTargetNode.buildfile_path: bxl.FileNode

Gets the buildfile path from the unconfigured target node.

Sample usage:

def _impl_label(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.buildfile_path)

bxl.UnconfiguredTargetNode.deps

def bxl.UnconfiguredTargetNode.deps() -> list[target_label]

Gets all deps for this target. The result is a list of UnconfiguredTargetLabel.

Sample usage:

def _impl_get_deps(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.deps())

bxl.UnconfiguredTargetNode.get_attr

def bxl.UnconfiguredTargetNode.get_attr(key: str, /)

Gets the attribute from the unconfigured target node. If the attribute is unset, returns the default value. If the attribute is not defined by the rule, returns None. It will not return special attribute (attribute that start with 'buck.' in `buck2 uquery -A`` command).

Sample usage:

def _impl_attributes(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.get_attr('my_attr'))

bxl.UnconfiguredTargetNode.get_attrs

def bxl.UnconfiguredTargetNode.get_attrs() -> dict[str, typing.Any]

Gets the all attributes (not include speical attributes) from the unconfigured target node. For attributes that are not explicitly set, the default value is returned.

Sample usage:

def _impl_attributes(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.get_attrs())

bxl.UnconfiguredTargetNode.has_attr

def bxl.UnconfiguredTargetNode.has_attr(key: str, /) -> bool

Check if rule has the attribute.

Known attribute is always set explicitly or to default value (otherwise target would not be created) For special attributes, it will return False

Sample usage:

def _impl_attributes(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.has_attr('my_attr'))

bxl.UnconfiguredTargetNode.label

bxl.UnconfiguredTargetNode.label: target_label

Gets the label from the unconfigured target node.

Sample usage:

def _impl_label(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.label)

bxl.UnconfiguredTargetNode.oncall

bxl.UnconfiguredTargetNode.oncall: None | str

Gets the target's special attr oncall

Sample usage:

def _impl_get_oncall(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.oncall)

bxl.UnconfiguredTargetNode.rule_kind

bxl.UnconfiguredTargetNode.rule_kind: str

Gets the targets' corresponding rule's kind which is one of - normal (with no special properties) - configured (usable in a configuration context) - toolchain (only usable as a toolchain dep)

Sample usage:

def _impl_rule_kind(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.rule_kind)

bxl.UnconfiguredTargetNode.rule_type

bxl.UnconfiguredTargetNode.rule_type: str

Gets the fully qualified name of the rule for this unconfigured target node as a string. This includes the import path as well.

Sample usage:

def _impl_rule_type(ctx):
target_node = ctx.uquery().eval("//foo:bar")[0]
ctx.output.print(target_node.rule_type)