Skip to content

Commit 08d9254

Browse files
committed
Emit a DeprecationWarning for the old dict-like access to the return value of validate_email and remove some internal uses of it
1 parent c1c7924 commit 08d9254

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ There are no significant changes to which email addresses are considered valid/i
1515
* The tests have been reorganized and expanded. Deliverability tests now mostly use captured DNS responses so they can be run off-line.
1616
* The __main__ tool now reads options to validate_email from environment variables.
1717
* Type annotations have been added to the exported methods and the ValidatedEmail class and some internal methods.
18+
* The old dict-like pattern for the return value of validate_email is deprecated.
1819

1920
Version 1.3.1 (January 21, 2023)
2021
--------------------------------

email_validator/exceptions_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from typing import Optional
23

34

@@ -72,6 +73,7 @@ def __repr__(self):
7273
"""For backwards compatibility, some fields are also exposed through a dict-like interface. Note
7374
that some of the names changed when they became attributes."""
7475
def __getitem__(self, key):
76+
warnings.warn("dict-like access to the return value of validate_email is deprecated and may not be supported in the future.", DeprecationWarning, stacklevel=2)
7577
if key == "email":
7678
return self.email
7779
if key == "email_ascii":

email_validator/validate_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def validate_email(
173173
# Lazy load `deliverability` as it is slow to import (due to dns.resolver)
174174
from .deliverability import validate_email_deliverability
175175
deliverability_info = validate_email_deliverability(
176-
ret["domain"], ret["domain_i18n"], timeout, dns_resolver
176+
ret.ascii_domain, ret.domain, timeout, dns_resolver
177177
)
178178
for key, value in deliverability_info.items():
179179
setattr(ret, key, value)

0 commit comments

Comments
 (0)