From fb9d58cad4fb7176f4dd9cbb0fb5d3a36ee8f449 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 18 Sep 2019 13:09:04 +0100 Subject: [PATCH] more tweaks --- pydantic/errors.py | 1 + pydantic/main.py | 2 +- pydantic/validators.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pydantic/errors.py b/pydantic/errors.py index d091285790..ca4f5998ae 100644 --- a/pydantic/errors.py +++ b/pydantic/errors.py @@ -4,6 +4,7 @@ from .typing import AnyType, display_as_type +# explicitly state exports to avoid "from .errors import *" also importing Decimal, Path etc. __all__ = ( 'PydanticTypeError', 'PydanticValueError', diff --git a/pydantic/main.py b/pydantic/main.py index fb470a9783..625b6735fa 100644 --- a/pydantic/main.py +++ b/pydantic/main.py @@ -712,7 +712,7 @@ def validate_model( # noqa: C901 (ignore complexity) else: value = deepcopy(field.default) - if not model.__config__.validate_all and not field.validate_always: + if not config.validate_all and not field.validate_always: values[name] = value continue else: diff --git a/pydantic/validators.py b/pydantic/validators.py index ec82f14d86..6544034ce1 100644 --- a/pydantic/validators.py +++ b/pydantic/validators.py @@ -43,7 +43,7 @@ def str_validator(v: Any) -> Optional[str]: if isinstance(v, str): - if hasattr(v, 'value') and isinstance(v, Enum): + if isinstance(v, Enum): return v.value else: return v