Skip to content

Commit 893aae5

Browse files
authored
Simplify email equality check into return statement (#51)
1 parent 7428eeb commit 893aae5

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ install:
99
.PHONY: lint
1010
lint:
1111
#python setup.py check -rms
12-
flake8 --ignore=E501,E126 email_validator tests
12+
flake8 --ignore=E501,E126,W503 email_validator tests
1313

1414
.PHONY: test
1515
test:

email_validator/__init__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,18 @@ def __getitem__(self, key):
142142

143143
"""Tests use this."""
144144
def __eq__(self, other):
145-
if self.email == other.email and self.local_part == other.local_part and self.domain == other.domain \
146-
and self.ascii_email == other.ascii_email and self.ascii_local_part == other.ascii_local_part \
147-
and self.ascii_domain == other.ascii_domain \
148-
and self.smtputf8 == other.smtputf8 \
149-
and repr(sorted(self.mx) if self.mx else self.mx) == repr(sorted(other.mx) if other.mx else other.mx) \
150-
and self.mx_fallback_type == other.mx_fallback_type:
151-
return True
152-
return False
145+
return (
146+
self.email == other.email
147+
and self.local_part == other.local_part
148+
and self.domain == other.domain
149+
and self.ascii_email == other.ascii_email
150+
and self.ascii_local_part == other.ascii_local_part
151+
and self.ascii_domain == other.ascii_domain
152+
and self.smtputf8 == other.smtputf8
153+
and repr(sorted(self.mx) if self.mx else self.mx)
154+
== repr(sorted(other.mx) if other.mx else other.mx)
155+
and self.mx_fallback_type == other.mx_fallback_type
156+
)
153157

154158
"""This helps producing the README."""
155159
def as_constructor(self):

0 commit comments

Comments
 (0)