From 473428eebffb584dd894aabb331da861a6b60be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Thu, 14 Apr 2022 01:41:58 +0200 Subject: [PATCH] Walrus fix --- src/cattrs/_compat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cattrs/_compat.py b/src/cattrs/_compat.py index c9f615fa..73127da6 100644 --- a/src/cattrs/_compat.py +++ b/src/cattrs/_compat.py @@ -135,8 +135,9 @@ def is_union_type(obj): ) def get_newtype_base(typ: Any) -> Optional[type]: + supertype = getattr(type, "__supertype__", None) if ( - (supertype := getattr(type, "__supertype__", None)) is not None + supertype is not None and getattr(typ, "__qualname__", "") == "NewType..new_type" and typ.__module__ in ("typing", "typing_extensions") ):