diff --git a/marshmallow_dataclass/__init__.py b/marshmallow_dataclass/__init__.py index f2014af..c7b1e0a 100644 --- a/marshmallow_dataclass/__init__.py +++ b/marshmallow_dataclass/__init__.py @@ -48,6 +48,7 @@ class User: Dict, List, Mapping, + NewType as typing_NewType, Optional, Set, Tuple, @@ -805,12 +806,8 @@ def NewType( marshmallow.exceptions.ValidationError: {'mail': ['Not a valid email address.']} """ - def new_type(x: _U): - return x - - new_type.__name__ = name # noinspection PyTypeHints - new_type.__supertype__ = typ # type: ignore + new_type = typing_NewType(name, typ) # type: ignore # noinspection PyTypeHints new_type._marshmallow_field = field # type: ignore # noinspection PyTypeHints