//python/private:attr_builders.bzl
Builders for creating attributes et al.
Added in version 1.3.0.
- attrb.Bool(**kwargs)
Creates a builder for
attr.bool.
- attrb.IntList(**kwargs)
Creates a builder for
attr.int_list.- Args:
kwargs– Same asattr.int_list.
- Returns:
- attrb.Label(**kwargs)
Creates a builder for
attr.label.
- attrb.LabelKeyedStringDict(**kwargs)
Creates a builder for
attr.label_keyed_string_dict.- Args:
kwargs– Same asattr.label_keyed_string_dict.
- Returns:
- attrb.LabelList(**kwargs)
Creates a builder for
attr.label_list.- Args:
kwargs– Same asattr.label_list.
- Returns:
- attrb.Output(**kwargs)
Creates a builder for
attr.output.- Args:
kwargs– Same asattr.output.
- Returns:
- attrb.OutputList(**kwargs)
Creates a builder for
attr.output_list.- Args:
kwargs– Same asattr.output_list.
- Returns:
- attrb.String(**kwargs)
Creates a builder for
attr.string.- Args:
kwargs– Same asattr.string.
- Returns:
- attrb.StringDict(**kwargs)
Creates a builder for
attr.string_dict.- Args:
kwargs– The same args as forattr.string_dict.
- Returns:
- attrb.StringKeyedLabelDict(**kwargs)
Creates a builder for
attr.string_keyed_label_dict.- Args:
kwargs– Same asattr.string_keyed_label_dict.
- Returns:
- attrb.StringList(**kwargs)
Creates a builder for
attr.string_list.- Args:
kwargs– Same asattr.string_list.
- Returns:
- attrb.StringListDict(**kwargs)
Creates a builder for
attr.string_list_dict.- Args:
kwargs– Same asattr.string_list_dict.
- Returns:
- typedefattrb.WhichCfg
Values returned by
AttrCfg.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 (see
config.none).
- WhichCfg.IMPL
Indicates a custom transition is set.
- typedefAttrCfg
Builder for
cfgarg 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|Nonethe name of the exec group to use if any,orNoneifwhich_cfgisn’texec
- AttrCfg.implementation()
Tells the custom transition function, if any and applicable.
- Returns:
callable|Nonethe custom transition function to use, ifany, orNoneif a different config mode is being used.
- AttrCfg.new(inputs=None,outputs=None,**kwargs)
Creates a builder for the
attr.cfgattribute.- Args:
inputs–(list[Label]|None)(defaultNone)inputs to use for a transition
outputs–(list[Label]|None)(defaultNone)outputs to use for a transition
Three different keyword args are supported.The presence of a keyword arg will mark the respective modereturned by
which_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.none()
Tells if none cfg (
config.none()) is set.- Returns:
boolTrue 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.
- AttrCfg.set_none()
Sets to use the “none” transition.
- AttrCfg.set_target()
Sets to use the target transition.
- 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 when
build()is called, assuming there were no API callsin between.
- Bool.mandatory()→bool
- Bool.set_default(v)
- Bool.set_doc(v)
- Bool.set_mandatory(v)
- 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 when
build()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)
- 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 when
build()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 for
attr.int_list.- Args:
kwargs– Same asattr.int_list.
- Returns:
- typedefLabel
Builder for
attr.labelobjects.- Label.allow_files()→bool|list[str]|None
Note that
allow_filesis mutually exclusive withallow_single_file.Only one of the two can have a value set.
- Label.allow_single_file()→bool|None
Note that
allow_single_fileis 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.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 when
build()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 unsets
allow_single_file
- Label.new(**kwargs)
Creates a builder for
attr.label.
- Label.set_allow_files(v)
Set the allow_files arg
NOTE: Setting
allow_filesunsetsallow_single_file
- 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.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 when
build()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
- LabelKeyedStringDict.new(**kwargs)
Creates a builder for
attr.label_keyed_string_dict.- Args:
kwargs– Same asattr.label_keyed_string_dict.
- Returns:
- typedefLabelList
Builder for
attr.label_list- LabelList.aspects()→list[aspect]
- LabelList.allow_files()→bool|list[str]
- LabelList.allow_empty()→bool
- LabelList.build()→attr.label_list
- 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 when
build()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 for
attr.label_list.- Args:
kwargs– Same asattr.label_list.
- Returns:
- 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 when
build()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 for
attr.output.- Args:
kwargs– Same asattr.output.
- Returns:
- 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 when
build()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 for
attr.output_list.- Args:
kwargs– Same asattr.output_list.
- Returns:
- typedefString
Builder for
attr.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 when
build()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 for
attr.string.- Args:
kwargs– Same asattr.string.
- Returns:
- typedefStringDict
Builder for
attr.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 when
build()is called, assuming there were no API callsin between.
- StringDict.set_doc(v)
- StringDict.set_mandatory(v)
- StringDict.set_allow_empty(v)
- 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.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 when
build()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 for
attr.string_keyed_label_dict.- Args:
kwargs– Same asattr.string_keyed_label_dict.
- Returns:
- typedefStringList
Builder for
attr.string_list- StringList.allow_empty()→bool
- StringList.build()→attr.string_list
- 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 when
build()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 for
attr.string_list.- Args:
kwargs– Same asattr.string_list.
- Returns:
- 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 when
build()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 for
attr.string_list_dict.- Args:
kwargs– Same asattr.string_list_dict.
- Returns: