in src/dfcx_scrapi/builders/intents.py [0:0]
def remove_label(self, label: Union[Dict[str, str], str]) -> Intent:
"""Remove a single or multiple labels from proto_obj.
Args:
label (Dict[str, str] | str):
A string or a dictionary of lables to remove.
Returns:
An Intent object stored in proto_obj
"""
self._check_proto_obj_attr_exist()
if isinstance(label, str):
if self.proto_obj.labels.get(label) == label:
self.proto_obj.labels.pop(label)
elif isinstance(label, dict):
for key, val in label.items():
if not(isinstance(key, str) and isinstance(val, str)):
raise ValueError(
"Keys and values in label's dictionary"
" should be string."
)
# Check if the keys and values in the `label`
# are the same as labels in proto_obj
if self.proto_obj.labels.get(key) == val:
self.proto_obj.labels.pop(key)
else:
raise ValueError(
"labels should be either a string or a dictionary."
)
return self.proto_obj