

def __eq__(self, other):
    '\n        Override parent equality because we store only string representation\n        of phone number, so we must compare only this string representation\n        '
    if (isinstance(other, PhoneNumber) or isinstance(other, phonenumbers.PhoneNumber) or isinstance(other, string_types)):
        format_string = getattr(settings, 'PHONENUMBER_DB_FORMAT', 'E164')
        default_region = getattr(settings, 'PHONENUMBER_DEFAULT_REGION', None)
        fmt = self.format_map[format_string]
        if isinstance(other, string_types):
            try:
                other = phonenumbers.parse(other, region=default_region)
            except NumberParseException:
                return False
        other_string = phonenumbers.format_number(other, fmt)
        return (self.format_as(fmt) == other_string)
    else:
        return False

dataset/ETHPy150Open stefanfoulis/django-phonenumber-field/phonenumber_field/phonenumber.py PhoneNumber.__eq__/original