Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dnspython package is optional #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ This package [is on PyPI](https://pypi.org/project/email-validator/), so:
pip install email-validator
```

If deliverability option will be used:

```sh
pip install email-validator[dns]
```

(You might need to use `pip3` depending on your local environment.)

Quick Start
Expand Down
7 changes: 5 additions & 2 deletions email_validator/deliverability.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

from .exceptions_types import EmailUndeliverableError

import dns.resolver
import dns.exception
try:
import dns.resolver
import dns.exception
except ImportError as e:
raise ImportError('deliverability option requires dnspython, run `pip install email-validator[dns]`') from e


def caching_resolver(*, timeout: Optional[int] = None, cache=None):
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ keywords = email address validator
[options]
packages = find:
install_requires =
dnspython>=2.0.0 # optional if deliverability check isn't needed
idna>=2.0.0
python_requires = >=3.7

[options.extras_require]
# optional if deliverability check isn't needed
dns = dnspython>=2.0.0

[options.package_data]
* = py.typed

Expand Down