From 341e50fcb8484d9a02cbf2615d613a0d043b13ce Mon Sep 17 00:00:00 2001 From: bibajz Date: Tue, 8 Feb 2022 13:25:11 +0100 Subject: [PATCH 1/3] Add forgotten Tuple check to is_sequence --- src/cattr/_compat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cattr/_compat.py b/src/cattr/_compat.py index 141fa537..1d64eed9 100644 --- a/src/cattr/_compat.py +++ b/src/cattr/_compat.py @@ -277,6 +277,7 @@ def is_sequence(type: Any) -> bool: TypingSequence, TypingMutableSequence, AbcMutableSequence, + Tuple, tuple, ) or ( From ba07612053fa69ff106793831070965349530b12 Mon Sep 17 00:00:00 2001 From: bibajz Date: Tue, 8 Feb 2022 13:26:19 +0100 Subject: [PATCH 2/3] Unstructure heterogenous tuples to list by default --- src/cattr/converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cattr/converters.py b/src/cattr/converters.py index 6bf4af8a..370e7e49 100644 --- a/src/cattr/converters.py +++ b/src/cattr/converters.py @@ -760,7 +760,7 @@ def gen_unstructure_iterable(self, cl: Any, unstructure_to=None): def gen_unstructure_hetero_tuple(self, cl: Any, unstructure_to=None): unstructure_to = self._unstruct_collection_overrides.get( - get_origin(cl) or cl, unstructure_to or tuple + get_origin(cl) or cl, unstructure_to or list ) h = make_hetero_tuple_unstructure_fn(cl, self, unstructure_to=unstructure_to) self._unstructure_func.register_cls_list([(cl, h)], direct=True) From 73054da0168fa37a7bb25735463d9b8e29d6ef7d Mon Sep 17 00:00:00 2001 From: bibajz Date: Tue, 8 Feb 2022 15:03:50 +0100 Subject: [PATCH 3/3] Add HISTORY.rst entry --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index b0bd5fe7..29351530 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,8 @@ History * Fix a wrong ``AttributeError`` of an missing ``__parameters__`` attribute. This could happen when inheriting certain generic classes – for example ``typing.*`` classes are affected. (`#217 `_) +* Fix unstructuring all tuples - unannotated, variable-length, homogenous and heterogenous - to `list`. + (`#226 `_) 1.10.0 (2022-01-04) -------------------