Skip to content

Commit 3ea1308

Browse files
committed
Add an exception if timeout and dns_resolver are both passed
1 parent beef710 commit 3ea1308

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

email_validator/deliverability.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def validate_email_deliverability(domain: str, domain_i18n: str, timeout: Option
3131
timeout = DEFAULT_TIMEOUT
3232
dns_resolver = dns.resolver.get_default_resolver()
3333
dns_resolver.lifetime = timeout
34+
elif timeout is not None:
35+
raise ValueError("It's not valid to pass both timeout and dns_resolver.")
3436

3537
deliverability_info: Dict[str, Any] = {}
3638

email_validator/validate_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def validate_email(
4040
test_environment = TEST_ENVIRONMENT
4141
if globally_deliverable is None:
4242
globally_deliverable = GLOBALLY_DELIVERABLE
43-
if timeout is None:
43+
if timeout is None and dns_resolver is None:
4444
timeout = DEFAULT_TIMEOUT
4545

4646
# Allow email to be a str or bytes instance. If bytes,

0 commit comments

Comments
 (0)