@@ -145,22 +145,25 @@ def __init__(self, cls_or_instance, **kwargs):
145
145
raise MarshallingException (error_msg )
146
146
self .container = cls_or_instance
147
147
148
+ def format (self , value ):
149
+ # Convert all instances in typed list to container type
150
+ if isinstance (value , set ):
151
+ value = list (value )
152
+
153
+ return [
154
+ self .container .output (idx ,
155
+ val if isinstance (val , dict ) and
156
+ not isinstance (self .container , Nested )
157
+ and not type (self .container ) is Raw
158
+ else value )
159
+ for idx , val in enumerate (value )
160
+ ]
161
+
148
162
def output (self , key , data ):
149
163
value = get_value (key if self .attribute is None else self .attribute , data )
150
164
# we cannot really test for external dict behavior
151
165
if is_indexable_but_not_string (value ) and not isinstance (value , dict ):
152
- # Convert all instances in typed list to container type
153
- if isinstance (value , set ):
154
- value = list (value )
155
-
156
- return [
157
- self .container .output (idx ,
158
- val if isinstance (val , dict ) and
159
- not isinstance (self .container , Nested )
160
- and not type (self .container ) is Raw
161
- else value )
162
- for idx , val in enumerate (value )
163
- ]
166
+ return self .format (value )
164
167
165
168
if value is None :
166
169
return self .default
0 commit comments