From 94c0a336099d2cb42ffa764690c55683e2ef8eba Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 26 Mar 2018 11:48:04 +0100 Subject: [PATCH] tweak email-validator import error message (#145) --- HISTORY.rst | 4 ++++ pydantic/types.py | 4 ++-- pydantic/utils.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e888bf8..826cc83 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,10 @@ History ------- +v0.8.1 (2018-XX-XX) +................... +* tweak email-validator import error message #145 + v0.8.0 (2018-03-25) ................... * fix type annotation for ``inherit_config`` #139 diff --git a/pydantic/types.py b/pydantic/types.py index c027d8c..0351938 100644 --- a/pydantic/types.py +++ b/pydantic/types.py @@ -82,7 +82,7 @@ class EmailStr(str): def get_validators(cls): # included here and below so the error happens straight away if email_validator is None: - raise ImportError('email-validator is not installed, run `pip install email-validator`') + raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') yield str_validator yield cls.validate @@ -101,7 +101,7 @@ class NameEmail: @classmethod def get_validators(cls): if email_validator is None: - raise ImportError('email-validator is not installed, run `pip install email-validator`') + raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') yield str_validator yield cls.validate diff --git a/pydantic/utils.py b/pydantic/utils.py index 1265e33..e330a2a 100644 --- a/pydantic/utils.py +++ b/pydantic/utils.py @@ -22,7 +22,7 @@ def validate_email(value) -> Tuple[str, str]: See RFC 5322 but treat it with suspicion, there seems to exist no universally acknowledged test for a valid email! """ if email_validator is None: - raise ImportError('email-validator is not installed, run `pip install email-validator`') + raise ImportError('email-validator is not installed, run `pip install pydantic[email]`') m = PRETTY_REGEX.fullmatch(value) if m: