Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __add__(self, other: Any):
result = Message(self)
try:
if isinstance(other, Message):
result.extend(other)
elif isinstance(other, MessageSegment):
result.append(other)
elif isinstance(other, list):
result.extend(map(lambda d: MessageSegment(d), other))
elif isinstance(other, dict):
result.append(MessageSegment(other))
elif isinstance(other, str):
result.extend(Message._split_iter(other))
return result
except:
pass
raise ValueError('the addend is not a valid message')
def __add__(self, other: Any):
result = Message(self)
try:
if isinstance(other, Message):
result.extend(other)
elif isinstance(other, MessageSegment):
result.append(other)
elif isinstance(other, list):
result.extend(map(lambda d: MessageSegment(d), other))
elif isinstance(other, dict):
result.append(MessageSegment(other))
elif isinstance(other, str):
result.extend(Message._split_iter(other))
return result
except:
pass
raise ValueError('the addend is not a valid message')