Skip to content

Commit 7f720ba

Browse files
bibajzTinche
authored andcommitted
Fix unstructuring unannotated typing.Tuples
1 parent c353da3 commit 7f720ba

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cattrs/gen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,10 @@ def make_iterable_unstructure_fn(cl: Any, converter, unstructure_to=None):
412412

413413
fn_name = "unstructure_iterable"
414414

415-
# Let's try fishing out the type args.
416-
if getattr(cl, "__args__", None) is not None:
415+
# Let's try fishing out the type args
416+
# Unspecified tuples have `__args__` as empty tuples, so guard
417+
# against IndexError.
418+
if getattr(cl, "__args__", None) not in (None, ()):
417419
type_arg = cl.__args__[0]
418420
# We don't know how to handle the TypeVar on this level,
419421
# so we skip doing the dispatch here.

0 commit comments

Comments
 (0)