Repository navigation
Fix ValidatedEmail.mx being missing (not None) when the deliverability check times out - #200
Merged
Conversation
On the DNS timeout / no-nameservers path, validate_email_deliverability returns no "mx" key, and validate_email only assigned ret.mx when a value was present. The returned ValidatedEmail then had no mx attribute at all, so result.mx raised AttributeError instead of returning None as documented in the README. Assign mx unconditionally (as was already done for mx_fallback_type) and widen its annotation to Optional. Fixes JoshData#190
Owner
|
Ugh somehow I merged without checking that tests pass. Tests are now failing on the main branch. Please open a new PR to fix it as soon as possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #190
When the DNS deliverability check cannot be completed — a timeout or no answering nameserver —
validate_email_deliverability()returns{"unknown-deliverability": ...}with nomxentry.validate_email()only assignedret.mxwhen a value was present, so on that path the returnedValidatedEmailhad nomxattribute at all: readingresult.mxraisedAttributeErrorinstead of returningNone, which is what the README documents for this case (and whatmx_fallback_typealready does).This assigns
mxunconditionally, the same waymx_fallback_typeis already assigned, and widens themxannotation onValidatedEmailtoOptional[list[tuple[int, str]]].A regression test next to the existing
test_deliverability_dns_timeoutruns the fullvalidate_email()path against the mocked resolver's timeout domain and asserts that bothmxandmx_fallback_typecome back asNone. Full test suite: 344 passed (the network-markedtest_caching_dns_resolverexcluded; it requires live DNS).