I have a long code looks like this:
def to_representation(self, instance):
res = super().to_representation(instance)
res['receiver_phone_num'] = get_encryption_phone_num(instance.receiver_phone_num) if instance.receiver_phone_num else None
return res
The 3rd line is too much long, and I am struggling where to make a break and start a new line that can make code more readable and clear.
I have tried this:
res['receiver_phone_num'] = get_encryption_phone_num(
instance.receiver_phone_num
) if instance.receiver_phone_num else None
and
res['receiver_phone_num'] = get_encryption_phone_num(instance.receiver_phone_num)\
if instance.receiver_phone_num else None
and
res['receiver_phone_num'] = get_encryption_phone_num(
instance.receiver_phone_num) if instance.receiver_phone_num else None
I prefer the first line breaking style. Which one do you prefer or do you have any other line breaking styles that looks clear and beautiful, please show me.