From 1b857b66c92cd131c5efeb7c0c6ca18f8d43bbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20Tvrtkovi=C4=87?= Date: Wed, 6 Mar 2024 00:26:39 +0100 Subject: [PATCH] Handle TypeVars after all --- src/cattrs/gen/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cattrs/gen/__init__.py b/src/cattrs/gen/__init__.py index 13dea8ba..e7a93fd7 100644 --- a/src/cattrs/gen/__init__.py +++ b/src/cattrs/gen/__init__.py @@ -680,6 +680,8 @@ def make_iterable_unstructure_fn( # against IndexError. if getattr(cl, "__args__", None) not in (None, ()): type_arg = cl.__args__[0] + if isinstance(type_arg, TypeVar): + type_arg = getattr(type_arg, "__default__", Any) handler = converter.get_unstructure_hook(type_arg, cache_result=False) if handler == identity: # Save ourselves the trouble of iterating over it all.