From a0dacc830049a68ebe78008a0df74245daaa0d9e Mon Sep 17 00:00:00 2001 From: Jeff Dairiki Date: Fri, 23 Sep 2022 11:48:06 -0700 Subject: [PATCH] Cherry-pick PR #207: Fix broken user types after typing-inspect 0.8.0 This is cherry-picks PR#207 by @vit-zikmund --- marshmallow_dataclass/__init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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