//python/private:attr_builders.bzl

Builders for creating attributes et al.

Added in version 1.3.0.

attrb.Bool(**kwargs)

Creates a builder forattr.bool.

Args:
Returns:

Bool

attrb.Int(**kwargs)

Creates a builder forattr.int.

Args:
Returns:

Int

attrb.IntList(**kwargs)

Creates a builder forattr.int_list.

Args:
Returns:

IntList

attrb.Label(**kwargs)

Creates a builder forattr.label.

Args:
  • kwargs – The same asattr.label().

Returns:

Label

attrb.LabelKeyedStringDict(**kwargs)

Creates a builder forattr.label_keyed_string_dict.

Args:
Returns:

LabelKeyedStringDict

attrb.LabelList(**kwargs)

Creates a builder forattr.label_list.

Args:
Returns:

LabelList

attrb.Output(**kwargs)

Creates a builder forattr.output.

Args:
Returns:

Output

attrb.OutputList(**kwargs)

Creates a builder forattr.output_list.

Args:
Returns:

OutputList

attrb.String(**kwargs)

Creates a builder forattr.string.

Args:
Returns:

String

attrb.StringDict(**kwargs)

Creates a builder forattr.string_dict.

Args:
  • kwargs – The same args as forattr.string_dict.

Returns:

StringDict

attrb.StringKeyedLabelDict(**kwargs)

Creates a builder forattr.string_keyed_label_dict.

Args:
Returns:

StringKeyedLabelDict

attrb.StringList(**kwargs)

Creates a builder forattr.string_list.

Args:
Returns:

StringList

attrb.StringListDict(**kwargs)

Creates a builder forattr.string_list_dict.

Args:
Returns:

StringListDict

typedefattrb.WhichCfg

Values returned byAttrCfg.which_cfg

WhichCfg.TARGET

Indicates the target config is set.

WhichCfg.EXEC

Indicates the exec config is set.

WhichCfg.NONE

Indicates the “none” config is set (seeconfig.none).

WhichCfg.IMPL

Indicates a custom transition is set.

typedefAttrCfg

Builder forcfg arg of label attributes.

AttrCfg.inputs()list[Label]
AttrCfg.outputs()list[Label]
AttrCfg.which_cfg()attrb.WhichCfg

Tells which of the cfg modes is set. Will be one of: target, exec, none,or implementation

AttrCfg.exec_group()

Tells the exec group to use if an exec transition is being used.

Returns:

str|None the name of the exec group to use if any,orNone ifwhich_cfg isn’texec

AttrCfg.implementation()

Tells the custom transition function, if any and applicable.

Returns:

callable|None the custom transition function to use, ifany, orNone if a different config mode is being used.

AttrCfg.new(inputs=None,outputs=None,**kwargs)

Creates a builder for theattr.cfg attribute.

Args:
  • inputs(list[Label]|None)(defaultNone)

    inputs to use for a transition

  • outputs(list[Label]|None)(defaultNone)

    outputs to use for a transition

  • kwargs(dict)

    Three different keyword args are supported.The presence of a keyword arg will mark the respective modereturned bywhich_cfg.

    • cfg: string of either “target” or “exec”

    • exec_group: string of an exec group name to use. None meansto use regular exec config (i.e.config.exec())

    • implementation: callable for a custom transition function.

Returns:

AttrCfg

AttrCfg.none()

Tells if none cfg (config.none()) is set.

Returns:

bool True if none cfg is set, False if not.

AttrCfg.set_exec(exec_group=None)

Sets to use an exec transition.

Args:
  • exec_group(str|None)(defaultNone)

    the exec group name to use, if any.

AttrCfg.set_implementation(impl)

Sets a custom transition function to use.

Args:
AttrCfg.set_none()

Sets to use the “none” transition.

AttrCfg.set_target()

Sets to use the target transition.

AttrCfg.target()

Tells if target cfg is set.

Returns:

bool True if target cfg is set, False if not.

typedefBool

Builder for attr.bool.

Bool.build()attr.bool
Bool.default()->bool)
Bool.doc()str
Bool.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

Bool.mandatory()bool
Bool.set_default(v)
Bool.set_doc(v)
Bool.set_mandatory(v)
Bool.new(**kwargs)

Creates a builder forattr.bool.

Args:
Returns:

Bool

typedefInt

Builder for attr.int.

Int.build()attr.int
Int.default()int
Int.doc()str
Int.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

Int.mandatory()bool
Int.values()list[int]

The returned value is a mutable reference to the underlying list.

Int.set_default(v)
Int.set_doc(v)
Int.set_mandatory(v)
Int.new(**kwargs)

Creates a builder forattr.int.

Args:
Returns:

Int

typedefIntList

Builder for attr.int_list.

IntList.allow_empty()bool
IntList.build()attr.int_list
IntList.default()list[int]
IntList.doc()str
IntList.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

IntList.mandatory()bool
IntList.set_allow_empty(v)
IntList.set_doc(v)
IntList.set_mandatory(v)
IntList.new(**kwargs)

Creates a builder forattr.int_list.

Args:
Returns:

IntList

typedefLabel

Builder forattr.label objects.

Label.allow_files()bool|list[str]|None

Note thatallow_files is mutually exclusive withallow_single_file.Only one of the two can have a value set.

Label.allow_single_file()bool|None

Note thatallow_single_file is mutually exclusive withallow_files.Only one of the two can have a value set.

Label.aspects()list[aspect]

The returned list is a mutable reference to the underlying list.

Label.build()attr.label
Label.cfg:AttrCfg
Label.default()str|label|configuration_field|None
Label.doc()str
Label.executable()bool
Label.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

Label.mandatory()bool
Label.providers()list[list[provider]]

The returned list is a mutable reference to the underlying list.

Label.set_default(v)
Label.set_doc(v)
Label.set_executable(v)
Label.set_mandatory(v)
Label.add_allow_files(*values)

Adds allowed file extensions

NOTE: Add an allowed file extension unsetsallow_single_file

Args:
  • values(str)

    file extensions to allow (including dot)

Label.new(**kwargs)

Creates a builder forattr.label.

Args:
  • kwargs – The same asattr.label().

Returns:

Label

Label.set_allow_files(v)

Set the allow_files arg

NOTE: Settingallow_files unsetsallow_single_file

Args:
  • v(bool|list[str]|None)

    the value to set to.If set toNone, thenallow_files is unset.

Label.set_allow_single_file(v)

Sets the allow_single_file arg.

NOTE: Settingallow_single_file unsetsallow_file

Args:
  • v(bool|None)

    the value to set to.If set toNone, thenallow_single_file is unset.

typedefLabelKeyedStringDict

Builder for attr.label_keyed_string_dict.

LabelKeyedStringDict.aspects()list[aspect]

The returned list is a mutable reference to the underlying list.

LabelKeyedStringDict.allow_files()bool|list[str]
LabelKeyedStringDict.allow_empty()bool
LabelKeyedStringDict.cfg:AttrCfg
LabelKeyedStringDict.default()dict[str|Label,str]|callable
LabelKeyedStringDict.doc()str
LabelKeyedStringDict.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

LabelKeyedStringDict.mandatory()bool
LabelKeyedStringDict.providers()list[provider|list[provider]]

Returns a mutable reference to the underlying list.

LabelKeyedStringDict.set_mandatory(v)
LabelKeyedStringDict.set_allow_empty(v)
LabelKeyedStringDict.set_default(v)
LabelKeyedStringDict.set_doc(v)
LabelKeyedStringDict.set_allow_files(v)
LabelKeyedStringDict.add_allow_files(*values)

Adds allowed file extensions

Args:
  • values(str)

    file extensions to allow (including dot)

LabelKeyedStringDict.new(**kwargs)

Creates a builder forattr.label_keyed_string_dict.

Args:
Returns:

LabelKeyedStringDict

typedefLabelList

Builder forattr.label_list

LabelList.aspects()list[aspect]
LabelList.allow_files()bool|list[str]
LabelList.allow_empty()bool
LabelList.build()attr.label_list
LabelList.cfg:AttrCfg
LabelList.default()list[str|Label]|configuration_field|callable
LabelList.doc()str
LabelList.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

LabelList.mandatory()bool
LabelList.providers()list[provider|list[provider]]
LabelList.set_allow_empty(v)
LabelList.set_allow_files(v)
LabelList.set_default(v)
LabelList.set_doc(v)
LabelList.set_mandatory(v)
LabelList.new(**kwargs)

Creates a builder forattr.label_list.

Args:
Returns:

LabelList

typedefOutput

Builder for attr.output

Output.build()attr.output
Output.doc()str
Output.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

Output.mandatory()bool
Output.set_doc(v)
Output.set_mandatory(v)
Output.new(**kwargs)

Creates a builder forattr.output.

Args:
Returns:

Output

typedefOutputList

Builder for attr.output_list

OutputList.allow_empty()bool
OutputList.build()attr.output
OutputList.doc()str
OutputList.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

OutputList.mandatory()bool
OutputList.set_allow_empty(v)
OutputList.set_doc(v)
OutputList.set_mandatory(v)
OutputList.new(**kwargs)

Creates a builder forattr.output_list.

Args:
Returns:

OutputList

typedefString

Builder forattr.string

String.build()attr.string
String.default()str|configuration_field
String.doc()str
String.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

String.mandatory()bool
String.values()list[str]
String.set_default(v)
String.set_doc(v)
String.set_mandatory(v)
String.new(**kwargs)

Creates a builder forattr.string.

Args:
Returns:

String

typedefStringDict

Builder forattr.string_dict

StringDict.default()dict[str,str]
StringDict.doc()str
StringDict.mandatory()bool
StringDict.allow_empty()bool
StringDict.build()attr.string_dict
StringDict.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

StringDict.set_doc(v)
StringDict.set_mandatory(v)
StringDict.set_allow_empty(v)
StringDict.new(**kwargs)

Creates a builder forattr.string_dict.

Args:
  • kwargs – The same args as forattr.string_dict.

Returns:

StringDict

typedefStringKeyedLabelDict

Builder for attr.string_keyed_label_dict.

StringKeyedLabelDict.allow_empty()bool
StringKeyedLabelDict.allow_files()bool|list[str]
StringKeyedLabelDict.aspects()list[aspect]
StringKeyedLabelDict.build()attr.string_list
StringKeyedLabelDict.cfg:AttrCfg
StringKeyedLabelDict.default()dict[str,Label]|callable
StringKeyedLabelDict.doc()str
StringKeyedLabelDict.mandatory()bool
StringKeyedLabelDict.providers()list[list[provider]]
StringKeyedLabelDict.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

StringKeyedLabelDict.set_allow_empty(v)
StringKeyedLabelDict.set_allow_files(v)
StringKeyedLabelDict.set_doc(v)
StringKeyedLabelDict.set_default(v)
StringKeyedLabelDict.set_mandatory(v)
StringKeyedLabelDict.new(**kwargs)

Creates a builder forattr.string_keyed_label_dict.

Args:
Returns:

StringKeyedLabelDict

typedefStringList

Builder forattr.string_list

StringList.allow_empty()bool
StringList.build()attr.string_list
StringList.default:list[str]|configuration_field
StringList.doc()str
StringList.mandatory()bool
StringList.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

StringList.set_allow_empty(v)
StringList.set_default(v)
StringList.set_doc(v)
StringList.set_mandatory(v)
StringList.new(**kwargs)

Creates a builder forattr.string_list.

Args:
Returns:

StringList

typedefStringListDict

Builder for attr.string_list_dict.

StringListDict.allow_empty()bool
StringListDict.build()attr.string_list
StringListDict.default()dict[str,list[str]]
StringListDict.doc()str
StringListDict.mandatory()bool
StringListDict.kwargs:dict[str,Any]

Additional kwargs to use when building. This is to allow manipulations thataren’t directly supported by the builder’s API. The state of this dictmay or may not reflect prior API calls, and subsequent API calls maymodify this dict. The general contract is that modifications to this willbe respected whenbuild() is called, assuming there were no API callsin between.

StringListDict.set_allow_empty(v)
StringListDict.set_doc(v)
StringListDict.set_mandatory(v)
StringListDict.new(**kwargs)

Creates a builder forattr.string_list_dict.

Args:
Returns:

StringListDict