Skip to content

Commit

Permalink
Simplify email equality check into return statement (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdade committed Aug 7, 2020
1 parent 7428eeb commit 893aae5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
.PHONY: lint
lint:
#python setup.py check -rms
flake8 --ignore=E501,E126 email_validator tests
flake8 --ignore=E501,E126,W503 email_validator tests

.PHONY: test
test:
Expand Down
20 changes: 12 additions & 8 deletions email_validator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,18 @@ def __getitem__(self, key):

"""Tests use this."""
def __eq__(self, other):
if self.email == other.email and self.local_part == other.local_part and self.domain == other.domain \
and self.ascii_email == other.ascii_email and self.ascii_local_part == other.ascii_local_part \
and self.ascii_domain == other.ascii_domain \
and self.smtputf8 == other.smtputf8 \
and repr(sorted(self.mx) if self.mx else self.mx) == repr(sorted(other.mx) if other.mx else other.mx) \
and self.mx_fallback_type == other.mx_fallback_type:
return True
return False
return (
self.email == other.email
and self.local_part == other.local_part
and self.domain == other.domain
and self.ascii_email == other.ascii_email
and self.ascii_local_part == other.ascii_local_part
and self.ascii_domain == other.ascii_domain
and self.smtputf8 == other.smtputf8
and repr(sorted(self.mx) if self.mx else self.mx)
== repr(sorted(other.mx) if other.mx else other.mx)
and self.mx_fallback_type == other.mx_fallback_type
)

"""This helps producing the README."""
def as_constructor(self):
Expand Down

0 comments on commit 893aae5

Please sign in to comment.