You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hypothesis’ emails() strategy generated an email address 0@a.arpa which was rejected by the email-validator package:
>>>importemail_validator>>>email_validator.validate_email('0@a.arpa')
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/.../.venv/lib/python3.9/site-packages/email_validator/__init__.py", line319, invalidate_emaildomain_part_info=validate_email_domain_part(parts[1], test_environment=test_environment, globally_deliverable=globally_deliverable)
File"/.../.venv/lib/python3.9/site-packages/email_validator/__init__.py", line580, invalidate_email_domain_partraiseEmailSyntaxError("The domain name %s is a special-use or reserved name that cannot be used with email."%domain_i18n)
email_validator.EmailSyntaxError: Thedomainnamea.arpaisaspecial-useorreservednamethatcannotbeusedwithemail.
The email-validator package defines “special-use or reserved names” here.
Now, Hypothesis builds email addresses using the internal domains() strategy:
which doesn’t have explicit support to filter out or use these special-use domain names.
I think adding an optional kwarg allow_special_use=True to the emails() strategy which then propagates to the DomainNameStrategy class would be useful. Happy to supply a PR?
The text was updated successfully, but these errors were encountered:
A PR would be great, thanks! Let's add allow_special_use: bool = True to provisional.domains(), and *, domains: st.SearchStrategy[str] = domains() to st.emails()1 - that way people can also pass e.g. domains=st.just("employer.com"), so it's a more general upgrade 🙂
Footnotes
My reading of RFC-5322 is that special domains are fine according to the standard so IMO Hypothesis should include them by default, and the email-validator docs describes how to enable them in testing, noting that they're off by default as an anti-footgun. ↩
Hypothesis’
emails()
strategy generated an email address0@a.arpa
which was rejected by the email-validator package:The email-validator package defines “special-use or reserved names” here.
Now, Hypothesis builds email addresses using the internal
domains()
strategy:hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/core.py
Lines 2029 to 2031 in 48165d9
which doesn’t have explicit support to filter out or use these special-use domain names.
I think adding an optional kwarg
allow_special_use=True
to theemails()
strategy which then propagates to theDomainNameStrategy
class would be useful. Happy to supply a PR?The text was updated successfully, but these errors were encountered: