Skip to content

Commit 86c761c

Browse files
committed
Remove outdated Python syntax using pyupgrade
1 parent fd655c0 commit 86c761c

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

email_validator/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
# Export the main method, helper methods, and the public data types.
42
from .exceptions_types import ValidatedEmail, EmailNotValidError, \
53
EmailSyntaxError, EmailUndeliverableError

email_validator/exceptions_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EmailUndeliverableError(EmailNotValidError):
1717
pass
1818

1919

20-
class ValidatedEmail(object):
20+
class ValidatedEmail:
2121
"""The validate_email function returns objects of this type holding the normalized form of the email address
2222
and other information."""
2323

email_validator/rfc_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# addresses to also include three specific ranges of UTF8 defined in
1313
# RFC 3629 section 4, which appear to be the Unicode code points from
1414
# U+0080 to U+10FFFF.
15-
ATEXT_INTL = ATEXT + u"\u0080-\U0010FFFF"
15+
ATEXT_INTL = ATEXT + "\u0080-\U0010FFFF"
1616
ATEXT_INTL_RE = re.compile('[.' + ATEXT_INTL + ']') # ATEXT_INTL plus dots
1717
DOT_ATOM_TEXT_INTL = re.compile('[' + ATEXT_INTL + ']+(?:\\.[' + ATEXT_INTL + r']+)*\Z')
1818

email_validator/syntax.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ def validate_email_local_part(local: str, allow_smtputf8: bool = True, allow_emp
124124
# Check for invalid characters against the non-internationalized
125125
# permitted character set.
126126
# (RFC 5322 3.2.3)
127-
bad_chars = set(
127+
bad_chars = {
128128
safe_character_display(c)
129129
for c in local
130130
if not ATEXT_RE.match(c)
131-
)
131+
}
132132
if bad_chars:
133133
raise EmailSyntaxError("Internationalized characters before the @-sign are not supported: " + ", ".join(sorted(bad_chars)) + ".")
134134

@@ -148,20 +148,20 @@ def validate_email_local_part(local: str, allow_smtputf8: bool = True, allow_emp
148148
# (RFC 5321 4.1.2. RFC 5322 lists additional permitted *obsolete*
149149
# characters which are *not* allowed here. RFC 6531 section 3.3
150150
# extends the range to UTF8 strings.)
151-
bad_chars = set(
151+
bad_chars = {
152152
safe_character_display(c)
153153
for c in local
154154
if not QTEXT_INTL.match(c)
155-
)
155+
}
156156
if bad_chars:
157157
raise EmailSyntaxError("The email address contains invalid characters in quotes before the @-sign: " + ", ".join(sorted(bad_chars)) + ".")
158158

159159
# See if any characters are outside of the ASCII range.
160-
bad_chars = set(
160+
bad_chars = {
161161
safe_character_display(c)
162162
for c in local
163163
if not (32 <= ord(c) <= 126)
164-
)
164+
}
165165
if bad_chars:
166166
requires_smtputf8 = True
167167

@@ -213,11 +213,11 @@ def validate_email_local_part(local: str, allow_smtputf8: bool = True, allow_emp
213213

214214
# Check for invalid characters.
215215
# (RFC 5322 3.2.3, plus RFC 6531 3.3)
216-
bad_chars = set(
216+
bad_chars = {
217217
safe_character_display(c)
218218
for c in local
219219
if not ATEXT_INTL_RE.match(c)
220-
)
220+
}
221221
if bad_chars:
222222
raise EmailSyntaxError("The email address contains invalid characters before the @-sign: " + ", ".join(sorted(bad_chars)) + ".")
223223

@@ -306,11 +306,11 @@ def validate_email_domain_name(domain, test_environment=False, globally_delivera
306306

307307
# Check for invalid characters before normalization.
308308
# (RFC 952 plus RFC 6531 section 3.3 for internationalized addresses)
309-
bad_chars = set(
309+
bad_chars = {
310310
safe_character_display(c)
311311
for c in domain
312312
if not ATEXT_HOSTNAME_INTL.match(c)
313-
)
313+
}
314314
if bad_chars:
315315
raise EmailSyntaxError("The part after the @-sign contains invalid characters: " + ", ".join(sorted(bad_chars)) + ".")
316316

@@ -437,11 +437,11 @@ def validate_email_domain_name(domain, test_environment=False, globally_delivera
437437

438438
# Check for invalid characters after normalization. These
439439
# should never arise. See the similar checks above.
440-
bad_chars = set(
440+
bad_chars = {
441441
safe_character_display(c)
442442
for c in domain
443443
if not ATEXT_HOSTNAME_INTL.match(c)
444-
)
444+
}
445445
if bad_chars:
446446
raise EmailSyntaxError("The part after the @-sign contains invalid characters: " + ", ".join(sorted(bad_chars)) + ".")
447447
check_unsafe_chars(domain)
@@ -544,11 +544,11 @@ def validate_email_domain_literal(domain_literal):
544544

545545
# Check for permitted ASCII characters. This actually doesn't matter
546546
# since there will be an exception after anyway.
547-
bad_chars = set(
547+
bad_chars = {
548548
safe_character_display(c)
549549
for c in domain_literal
550550
if not DOMAIN_LITERAL_CHARS.match(c)
551-
)
551+
}
552552
if bad_chars:
553553
raise EmailSyntaxError("The part after the @-sign contains invalid characters in brackets: " + ", ".join(sorted(bad_chars)) + ".")
554554

0 commit comments

Comments
 (0)